Stata Commands for Proportion Inference in Sociology: UNC Chapel Hill, Soci708-001, Study notes of Statistics

Stata commands and examples for conducting inference for proportions using one-sample and two-sample tests in the context of sociological research. The use of normal distribution functions, one-sample t-tests, and two-sample tests for proportions.

Typology: Study notes

2011/2012

Uploaded on 12/29/2012

sankait
sankait 🇮🇳

4.2

(13)

113 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
University of North Carolina
Chapel Hill
Soci708-001 Statistics for Sociologists
Fall 2009
Professor François Nielsen
Stata Commands for Module 8 Inference for Proportions
For further information on any command in this handout, simply type help
followed by the name of the command in Stata.
For confidence intervals, also see page 35 of the Stata and SAS Guide pdf
(click on Documents in side bar; guide is linked under Software Documenta-
tion).
1 Statistical Functions in Stata
1.1 Normal Distribution Functions
The function normal(z) returns P(Zz), the area under the standard normal
curve to the left of z. (Compare with Table A.)
. display normal(1.207)
.88628393
The function invnormal(p) returns zsuch that P(Zz) = p, i.e. such that
the area under the standard normal curve to the left of zis p. (Compare with
Table A and Table D (bottom row).)
. display invnormal(0.975)
1.959964
2 One Sample t-Test for Proportion in Stata
When inputting the data in summary form, i.e. we don’t have the individual
data, the syntax is either prtesti n p p0 where Stata expects that pis a
proportion, or prtesti n X p0, count where Stata expects Xis an integer
(number of successes).
. * Binge Drinking example p. 490
. * Note hypothesis p0 = 0.5 makes no sense here; we still get correct CI
. prtesti 13819 3140 0.5, level(95) count
One-sample test of proportion x: Number of obs = 13819
------------------------------------------------------------------------------
Variable | Mean Std. Err. [95% Conf. Interval]
-------------+----------------------------------------------------------------
x | .2272234 .0035646 .2202368 .2342099
------------------------------------------------------------------------------
p = proportion(x) z = -64.1321
1
pf3

Partial preview of the text

Download Stata Commands for Proportion Inference in Sociology: UNC Chapel Hill, Soci708-001 and more Study notes Statistics in PDF only on Docsity!

University of North Carolina Chapel Hill

Soci708-001 Statistics for Sociologists

Fall 2009

Professor François Nielsen

Stata Commands for Module 8 – Inference for Proportions

For further information on any command in this handout, simply type help

followed by the name of the command in Stata.

For confidence intervals, also see page 35 of the Stata and SAS Guide pdf

(click on Documents in side bar; guide is linked under Software Documenta-

tion).

1 Statistical Functions in Stata

1.1 Normal Distribution Functions

The function normal(z) returns P ( Z ≤ z ), the area under the standard normal

curve to the left of z. (Compare with Table A.)

. display normal(1.207) .

The function invnormal(p) returns z such that P ( Z ≤ z ) = p , i.e. such that

the area under the standard normal curve to the left of z is p. (Compare with

Table A and Table D (bottom row).)

. display invnormal(0.975)

2 One Sample t-Test for Proportion in Stata

When inputting the data in summary form, i.e. we don’t have the individual

data, the syntax is either prtesti n p p0 where Stata expects that p is a

proportion, or prtesti n X p0, count where Stata expects X is an integer

(number of successes).

. * Binge Drinking example p. 490 . * Note hypothesis p0 = 0.5 makes no sense here; we still get correct CI . prtesti 13819 3140 0.5, level(95) count

One-sample test of proportion x: Number of obs = 13819

Variable | Mean Std. Err. [95% Conf. Interval] -------------+---------------------------------------------------------------- x | .2272234 .0035646 .2202368.


p = proportion(x) z = -64.

Ho: p = 0.

Ha: p < 0.5 Ha: p != 0.5 Ha: p > 0. Pr(Z < z) = 0.0000 Pr(|Z| > |z|) = 0.0000 Pr(Z > z) = 1.

. * Work Stress example p. 494 . prtesti 100 68 0.75, level(95) count

One-sample test of proportion x: Number of obs = 100

Variable | Mean Std. Err. [95% Conf. Interval] -------------+---------------------------------------------------------------- x | .68 .0466476 .5885724.


p = proportion(x) z = -1. Ho: p = 0.

Ha: p < 0.75 Ha: p != 0.75 Ha: p > 0. Pr(Z < z) = 0.0530 Pr(|Z| > |z|) = 0.1060 Pr(Z > z) = 0.

. * Gallup Poll 22 Oct 2008, n=2788, 51% favor Obama (43% McCain, 6% Undecided) . prtesti 2788 0.51 0.5, level(95)

One-sample test of proportion x: Number of obs = 2788

Variable | Mean Std. Err. [95% Conf. Interval] -------------+---------------------------------------------------------------- x | .51 .0094675 .491444.


p = proportion(x) z = 1. Ho: p = 0.

Ha: p < 0.5 Ha: p != 0.5 Ha: p > 0. Pr(Z < z) = 0.8545 Pr(|Z| > |z|) = 0.2910 Pr(Z > z) = 0.

3 Two Sample Test for Proportions in Stata

The syntax for a two sample test, when inputting the data in summary form, is

either prtesti n1 p1 n2 p2 where Stata expects that p1 and p2 are propo-

tions, or prtesti n1 X1 n2 X2, count and then Stata expects that X1 and

X2 are integer.

. * sample of middle-ages men takin experimental drug or placebo . * n1=2051 taking drug, n2=2030 placebo . * X1=56, X2=84 are numbers with heart attack for drug and placebo, resp. . prtesti 2051 56 2030 84, count level(90)

Two-sample test of proportion x: Number of obs = 2051 y: Number of obs = 2030


Variable | Mean Std. Err. z P>|z| [90% Conf. Interval] -------------+---------------------------------------------------------------- x | .0273038 .0035985 .0213848. y | .0413793 .0044205 .0341083. -------------+---------------------------------------------------------------- diff | -.0140756 .0056999 -.0234511 -. | under Ho: .0056984 -2.47 0.