A one proportion z-test is used to compare an observed proportion to a theoretical one.
This test uses the following null hypotheses:
- H0: p = p0 (population proportion is equal to hypothesized proportion p0)
The alternative hypothesis can be either two-tailed, left-tailed, or right-tailed:
- H1 (two-tailed): p ≠ p0 (population proportion is not equal to some hypothesized value p0)
- H1 (left-tailed): p < p0 (population proportion is less than some hypothesized value p0)
- H1 (right-tailed): p > p0 (population proportion is greater than some hypothesized value p0)
The test statistic is calculated as:
z = (p-p0) / √p0(1-p0)/n
- p: observed sample proportion
- p0: hypothesized population proportion
- n: sample size
If the p-value that corresponds to the test statistic z is less than your chosen significance level (common choices are 0.10, 0.05, and 0.01) then you can reject the null hypothesis.
One Proportion Z-Test in R
To perform a one proportion z-test in R, we can use one of the following functions:
- If n ≤ 30: binom.test(x, n, p = 0.5, alternative = “two.sided”)
- If n> 30: prop.test(x, n, p = 0.5, alternative = “two.sided”, correct=TRUE)
- x: The number of successes
- n: The number of trials
- p: The hypothesized population proportion
- alternative: The alternative hypothesis
- correct: Whether or not to apply Yates’ continuity correction
The following example shows how to carry out a one proportion z-test in R.
Example: One Proportion Z-Test in R
Suppose we want to know whether or not the proportion of residents in a certain county who support a certain law is equal to 60%. To test this, we collect the following data on a random sample:
- p0: hypothesized population proportion = 0.60
- x: residents who support law: 64
- n: sample size = 100
Since our sample size is greater than 30, we can use the prop.test() function to perform a one sample z-test:
prop.test(x=64, n=100, p=0.60, alternative="two.sided") 1-sample proportions test with continuity correction data: 64 out of 100, null probability 0.6 X-squared = 0.51042, df = 1, p-value = 0.475 alternative hypothesis: true p is not equal to 0.6 95 percent confidence interval: 0.5372745 0.7318279 sample estimates: p 0.64
From the output we can see that the p-value is 0.475. Since this value is not less than α = 0.05, we fail to reject the null hypothesis. We do not have sufficient evidence to say that the proportion of residents who support the law is different from 0.60.
The 95% confidence interval for the true proportion of residents in the county that support the law is also found to be:
95% C.I. = [0.5373, 7318]
Since this confidence interval contains the proportion 0.60, we do not have evidence to say that the true proportion of residents who support the law is different from 0.60. This matches the conclusion we came to using just the p-value of the test.
An Introduction to the One Proportion Z-Test
One Proportion Z-Test Calculator
How to Perform a One Proportion Z-Test in Excel