9.3 Two-Groups: Proportion
The hypothesis test for comparing the proportion between two groups is written as follows:
\[H_0: \hat{p}_1-\hat{p}_2=0\\
H_a: \hat{p}_1-\hat{p}_2 \neq 0\]
We first need to calculate the pooled estimate, i.e., the total number of success over the total number of observations. You can think of this as a weighted average. Let this weighted average be \(\hat{p}^*\).:
\[\hat{p}^*=\frac{p_1+p_2}{n_1+n_2}\]
Then, the standard error can be calculated as follows:
\[S.E. = \sqrt{\hat{p}^* \cdot (1-\hat{p}^*) \cdot \left( \frac{1}{n_1}+\frac{1}{n_2} \right)}\]
The resulting test statistic is written as
\[z = \frac{\hat{p}_1-\hat{p}_2}{S.E.}\]
Consider the hypothesis about the proportion of gun owners differentiated by male vs. female. The data is in gssgun
. A summary of the data is in the following table:
owngun | male | female |
---|---|---|
yes | 232 | 208 |
no | 335 | 501 |
The pooled proportion is calculated as follows: \[\hat{p}^*=\frac{232+208}{440+836}=0.345\] Given those numbers, the standard error is calculated as: \[S.E. = \sqrt{0.345 \cdot (1-0.345) \cdot \left( \frac{1}{440}+\frac{1}{836} \right)}=0.028\] The test statistic is: \[z = \frac{0.41-0.29}{0.028}=4.286\] Thus, we reject the hypothesis that the proportion of gun owners among males and females is the same.