You are on page 1of 1

School of Health Systems and Public Health

HME 712 Week 3 Fact sheet bos_9

The Stata commands for the prtest

WE NEVER PERFORM A t-TEST FOR TWO PROPORTIONS


THIS IS BECAUSE THE DATA FOR THE PROPORTIONS CONSIST ENTIRELY OF 1s and 0s:

They cannot by any stretch of imagination be considered to have a normal, or even approximately
normal, frequency distribution. Therefore, we need other tests to compare two proportions: We
use the chi square test and/ or the “prtest” (others use a “pure” z-test but Stata has modified the
z-test outputs very slightly and calls it a “prtest”.)

The 2x2 chi square test may be used to test the null hypothesis:

H0: π1 = π2
However, this only gives you a p-value (no 95% CI for the difference)

If you want a p-value and a 95% CI for the difference between the proportions, use the Stata prtest

<prtest binary_outcome variable, by(binary_group identifier)

For example, if you want to compare the proportion of vegans who experience a heart attack to the
proportion of meat-eaters who experience a heart attack, you would follow up cohorts of vegans
and meat-eaters for, say, 20 years and then compare the proportions with heart attacks in each
group.

The outcome variable is binary: heart attack yes/no or 1/0. We call this “mi” for myocardial infarct

The group identifier (vegan or meat-eater) is also binary and 1/0. Let’s call this “vegan”

Then, with your data entered as 1/0 for both mi and vegan, we use the Stata command:

<prtest mi, by(vegan)>


If we do not have the individual data points we need:

• The sample sizes (how many vegans (nv)? How many meat-eaters (nm)? ; and
• The proportions of vegans (miv) and meat-eaters (mim) who had a heart attack

<prtesti nv miv nm mim>

You might also like