7. Hypothesis Testing: Hypothesis Test for a Population Proportion
Hypothesis Test for a Proportion and Confidence Intervals
Recall that there exists a direct connection between a two-sided hypothesis test for #\mu# and a #(1-\alpha)\cdot 100\%# confidence interval for #\mu#.
This same connection does not apply precisely when we are testing hypotheses about a population proportion #\pi#:
- When performing the hypothesis test, we use #\pi_0# to compute the test statistic.
- When constructing a confidence interval, we use #\hat{p}# to compute the margin of error.
However, if you compute the #(1-\alpha)\cdot 100\%# confidence interval for #\pi# using #\pi_0# instead of #\hat{p}# to calculate the margin of error, the connection is reestablished.
#\phantom{0}#
Connecting Hypothesis Testing and Confidence Intervals
If you compute a #(1 - \alpha)\cdot 100\%\,CI# for #\pi# using
\[CI_{\pi}=\bigg(\hat{p}- z^*\cdot \sqrt{\cfrac{\pi_0\cdot(1-\pi_0)}{n}},\,\,\,\, \hat{p} + z^*\cdot \sqrt{\cfrac{\pi_0\cdot(1-\pi_0)}{n}} \bigg)\]
Then:
- If #\pi_0# falls inside the #(1 - \alpha)\cdot 100\%\,CI#, then #H_0: \pi=\pi_0# should not be rejected at the #\alpha# level of significance.
- If #\pi_0# falls outside of the #(1 - \alpha)\cdot 100\%\,CI#, then #H_0: \pi=\pi_0# should be rejected at the #\alpha# level of significance.
In a random sample of #94# residents of the land of Oz, #44# of them were in favor of deposing the Wizard.
Construct a #97\%# confidence interval for the proportion #\pi# of the population of Oz that favors deposing the Wizard, using #\pi_0 = 0.55# in the computation of the margin of error. Round your answers to #3# decimal places.
#CI_{\pi,\,97\%}=(0.357,\,\,\, 0.579)#
Based on this confidence interval, the null hypothesis #H_0: \pi = 0.55# should not be rejected at the #\alpha = 0.03# level of significance because #\pi_0 = 0.55# falls inside the confidence interval.
There are a number of different ways we can compute the confidence interval. Click on one of the panels to toggle a specific solution.
Calculate the sample proportion #\hat{p}#:
\[\hat{p}=\cfrac{X}{n}=\cfrac{44}{94}=0.4681\]
When using #\pi_0# to calculate the margin of error, the general formula for a #C\%\,CI# for the population proportion #\pi# is:
\[CI_{\pi}=\bigg(\hat{p}- z^*\cdot \sqrt{\cfrac{\pi_0\cdot(1-\pi_0)}{n}},\,\,\,\, \hat{p} + z^*\cdot \sqrt{\cfrac{\pi_0\cdot(1-\pi_0)}{n}} \bigg)\]
For a given confidence level #C# (in #\%#), the critical value #z^*# of the standard normal distribution is the value such that #\mathbb{P}(-z^* \leq Z \leq z^*)=\cfrac{C}{100}#.
To calculate this critical value #z^*# in Excel, make use of the following function:
NORM.INV(probability, mean, standard_dev)
- probability: A probability corresponding to the normal distribution.
- mean: The mean of the distribution.
- standard_dev: The standard deviation of the distribution.
Here, we have #C=97#. Thus, to calculate #z^*# such that #\mathbb{P}(-z^* \leq Z \leq z^*)=0.97#, run the following command:
\[\begin{array}{c}
=\text{NORM.INV}((100+C)/200, 0, 1)\\
\downarrow\\
=\text{NORM.INV}(197/200, 0, 1)
\end{array}\]
This gives:
\[z^* = 2.1701\]
When using #\pi_0# to calculate the margin of error, we calculate the lower bound #L# of the confidence interval:
\[L = \hat{p} - z^*\cdot \sqrt{\cfrac{\pi_0\cdot(1-\pi_0)}{n}} = 0.4681 - 2.1701 \cdot \sqrt{\cfrac{0.55 \cdot (1-0.55)}{94}} = 0.357\]
When using #\pi_0# to calculate the margin of error, we calculate the lower bound #U# of the confidence interval:
\[U = \hat{p} + z^*\cdot \sqrt{\cfrac{\pi_0\cdot(1-\pi_0)}{n}} = 0.4681 + 2.1701 \cdot \sqrt{\cfrac{0.55 \cdot (1-0.55)}{94}} = 0.579\]
Thus, the #97\%# confidence interval for the population proportion #\pi# is:
\[CI_{\pi,\,97\%}=(0.357,\,\,\, 0.579)\]
Based on this confidence interval, the null hypothesis #H_0: \pi = 0.55# should not be rejected at the #\alpha = 0.03# level of significance because #\pi_0 = 0.55# falls inside the confidence interval.
Calculate the sample proportion #\hat{p}#:
\[\hat{p}=\cfrac{X}{n}=\cfrac{44}{94}=0.4681\]
When using #\pi_0# to calculate the margin of error, the general formula for a #C\%\,CI# for the population proportion #\pi# is:
\[CI_{\pi}=\bigg(\hat{p}- z^*\cdot \sqrt{\cfrac{\pi_0\cdot(1-\pi_0)}{n}},\,\,\,\, \hat{p} + z^*\cdot \sqrt{\cfrac{\pi_0\cdot(1-\pi_0)}{n}} \bigg)\]
For a given confidence level #C# (in #\%#), the critical value #z^*# of the standard normal distribution is the value such that #\mathbb{P}(-z^* \leq Z \leq z^*)=\cfrac{C}{100}#.
To calculate this critical value #z^*# in R, make use of the following function:
qnorm(p, mean, sd, lower.tail)
- p: A probability corresponding to the normal distribution.
- mean: The mean of the distribution.
- sd: The standard deviation of the distribution.
- lower.tail: If TRUE (default), probabilities are #\mathbb{P}(X \leq x)#, otherwise, #\mathbb{P}(X \gt x)#.
Here, we have #C=97#. Thus, to calculate #z^*#such that #\mathbb{P}(-z^* \leq Z \leq z^*)=0.97#, run the following command:
\[\begin{array}{c}
\text{qnorm}(p = (100+C)/200, mean = 0, sd = 1, lower.tail = \text{TRUE})\\
\downarrow\\
\text{qnorm}(p =197/200, mean = 0, sd = 1, lower.tail = \text{TRUE})
\end{array}\]
This gives:
\[z^* = 2.1701\]
When using #\pi_0# to calculate the margin of error, we calculate the lower bound #L# of the confidence interval:
\[L = \hat{p} - z^*\cdot \sqrt{\cfrac{\pi_0\cdot(1-\pi_0)}{n}} = 0.4681 - 2.1701 \cdot \sqrt{\cfrac{0.55 \cdot (1-0.55)}{94}} = 0.357\]
When using #\pi_0# to calculate the margin of error, we calculate the lower bound #U# of the confidence interval:
\[U = \hat{p} + z^*\cdot \sqrt{\cfrac{\pi_0\cdot(1-\pi_0)}{n}} = 0.4681 + 2.1701 \cdot \sqrt{\cfrac{0.55 \cdot (1-0.55)}{94}} = 0.579\]
Thus, the #97\%# confidence interval for the population proportion #\pi# is:
\[CI_{\pi,\,97\%}=(0.357,\,\,\, 0.579)\]
Based on this confidence interval, the null hypothesis #H_0: \pi = 0.55# should not be rejected at the #\alpha = 0.03# level of significance because #\pi_0 = 0.55# falls inside the confidence interval.