Table of Contents
The one proportion z-test is a fundamental statistical test utilized when researchers need to assess whether an observed sample proportion significantly differs from a hypothesized or known population proportion. This powerful technique is essential in fields ranging from quality control to public opinion polling, allowing us to make reliable inferences about a larger population based on the data collected from a smaller subset. It operates on the principle of the normal approximation to the binomial distribution, provided specific sample size criteria are met. Executing this test in R involves carefully defining the test parameters, selecting the correct function, and accurately interpreting the resulting statistical measures, such as the z-score and the associated P-value.
Introduction to the One Proportion Z-Test
A one proportion z-test is fundamentally designed to compare an observed sample proportion to a specified theoretical proportion. This comparison helps determine if the difference observed in the sample is statistically significant or merely due to random chance. It is a vital tool for hypothesis testing concerning binary outcomes—situations where an event either succeeds or fails (e.g., a coin flip landing heads, a patient recovering, or a voter supporting a candidate). Before we can calculate the test statistic, we must clearly define the null and alternative hypotheses, which form the entire basis of the statistical inquiry.
The test relies on the assumption that, under certain conditions (large sample size), the sampling distribution of the sample proportion approaches a normal distribution. If these conditions are violated, alternative methods, such as the binomial exact test, must be employed to maintain the validity of the conclusion. However, for most practical large-sample applications, the z-test provides an efficient and robust method for statistical inference regarding population proportions.
The Statistical Foundations: Hypotheses and Assumptions
The foundation of the one proportion z-test lies in defining the null hypothesis ($H_0$), which represents the status quo—the claim that there is no difference between the true population proportion ($p$) and the hypothesized value ($p_0$). We use our sample data to determine if there is enough evidence to reject this baseline assumption.
This test uses the following null hypothesis:
- H0: $p = p_0$ (The true population proportion is equal to the hypothesized proportion $p_0$).
The alternative hypothesis ($H_1$) defines the specific deviation we are seeking to prove. It must be selected prior to analysis and determines whether the test is two-tailed (seeking difference in either direction) or one-tailed (seeking difference in a specific direction, less than or greater than $p_0$).
The alternative hypothesis can be either two-tailed, left-tailed, or right-tailed:
- H1 (Two-tailed): $p ne p_0$ (The true population proportion is not equal to the hypothesized value $p_0$). This is the standard choice when directionality is not specified.
- H1 (Left-tailed): $p < p_0$ (The true population proportion is less than the hypothesized value $p_0$).
- H1 (Right-tailed): $p > p_0$ (The true population proportion is greater than the hypothesized value $p_0$).
Calculating the Z-Statistic
The test statistic, $z$, is the mathematical measure of how many standard errors the observed sample proportion ($p$) is away from the hypothesized proportion ($p_0$). A large absolute value of $z$ indicates a substantial discrepancy between the sample data and the null hypothesis, making rejection more likely. The calculation is based on the assumption that the null hypothesis is true, which informs the standard error calculation using $p_0$.
The test statistic is calculated as:
$z = (p – p_0) / sqrt{p_0(1 – p_0)/n}$
where the variables are defined as:
- $p$: The observed sample proportion, calculated as successes divided by sample size ($x/n$).
- $p_0$: The hypothesized population proportion specified by $H_0$.
- $n$: The total sample size, or the number of independent trials.
The denominator in this formula, $sqrt{p_0(1 – p_0)/n}$, represents the standard error of the sampling distribution of the proportion. Using $p_0$ in the standard error calculation, instead of the sample proportion $p$, is a critical component of hypothesis testing, ensuring the variability is measured under the conditions dictated by the null hypothesis.
Interpreting the P-Value and Significance Level
Once the $z$-score is determined, it is converted into a P-value. The P-value represents the probability of observing a sample result as extreme as, or more extreme than, the one calculated, assuming the null hypothesis ($H_0$) is true. A small P-value suggests that the observed data is very unlikely if $H_0$ were correct, providing evidence against the null hypothesis.
The interpretation hinges on the comparison between the P-value and the chosen significance level ($alpha$). Common choices for $alpha$ are 0.10, 0.05, and 0.01. The significance level defines the maximum acceptable risk of making a Type I error (falsely rejecting a true $H_0$).
If the P-value that corresponds to the test statistic $z$ is less than or equal to your chosen significance level ($alpha$), then you possess sufficient evidence to reject the null hypothesis. Conversely, if the P-value is greater than $alpha$, we fail to reject the null hypothesis. This crucial step translates the numerical result into a meaningful statistical conclusion regarding the population proportion.
Selecting the Appropriate R Function for Proportion Testing
To perform proportion tests in R, we must choose between two primary functions, depending heavily on the sample size ($n$) and the validity of the normal approximation assumption. Although both functions address proportion testing, prop.test() aligns with the Z-test methodology when conditions allow for normal approximation, whereas binom.test() performs the exact binomial test, suitable for smaller samples.
The guidelines for function selection are:
- If $n$ is small (or conditions $n cdot p_0 ge 10$ and $n cdot (1 – p_0) ge 10$ are violated): Use
binom.test(x, n, p = 0.5, alternative = “two.sided”). This exact test is preferable when the distribution is highly skewed due to small $n$. - If $n$ is large (typically $n > 30$ and conditions are met): Use
prop.test(x, n, p = 0.5, alternative = “two.sided”, correct=TRUE). This function uses the chi-squared distribution, which provides a result mathematically equivalent to the squared z-statistic for a single proportion test.
The key arguments required for these functions are:
- x: The number of successes (the count of observations matching the proportion being tested).
- n: The total number of trials or the sample size.
- p: The hypothesized population proportion ($p_0$).
- alternative: Specifies the direction of $H_1$ (
"two.sided","less", or"greater"). - correct: A logical value (TRUE/FALSE) indicating whether to apply Yates’ continuity correction, which is often recommended for better approximation.
Example: One Proportion Z-Test in R
Consider a scenario where a manufacturer claims that 60% of their produced widgets meet a strict quality standard. To test this claim, a quality control engineer takes a random sample of 100 widgets, finding that 64 of them meet the standard. We want to determine if the true proportion is different from 0.60 ($alpha = 0.05$).
The parameters for our test are:
- $p_0$: Hypothesized population proportion = 0.60
- x: Number of successes (widgets meeting standard) = 64
- n: Sample size = 100
Since our sample size $n=100$ is large, we use the prop.test() function, specifying the two-sided alternative because we are testing for any difference, not just an increase or decrease:
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 Interpreting the Results and Conclusion
The R output provides several key pieces of information essential for reaching a statistical conclusion. The primary value for our decision is the P-value, which summarizes the evidence against the null hypothesis. The calculated P-value in this test is 0.475.
We compare this value to our chosen significance level, $alpha = 0.05$. Since $0.475 > 0.05$, we fail to reject the null hypothesis. This outcome signifies that the observed sample proportion of 0.64 is not statistically far enough from the hypothesized proportion of 0.60 to conclude that the true proportion of acceptable widgets is different from 60%. The difference observed (4 percentage points) is likely attributable to random sampling variation.
The output also includes the 95% confidence interval for the true population proportion:
95% C.I. = [0.5373, 0.7318]
Since this confidence interval ranges from 53.73% to 73.18%, and it clearly contains the hypothesized proportion $p_0 = 0.60$, this method reinforces our conclusion. The fact that 0.60 is included within the interval indicates that it is a plausible value for the true population proportion. This consistency confirms that we do not have sufficient statistical evidence to claim that the true proportion of conforming widgets differs from the manufacturer’s claim of 60%.
An Introduction to the One Proportion Z-Test
Cite this article
stats writer (2025). How to Perform a One Proportion Z-Test in R (With Examples). PSYCHOLOGICAL SCALES. Retrieved from https://scales.arabpsychology.com/stats/how-to-perform-a-one-proportion-z-test-in-r-with-examples/
stats writer. "How to Perform a One Proportion Z-Test in R (With Examples)." PSYCHOLOGICAL SCALES, 20 Dec. 2025, https://scales.arabpsychology.com/stats/how-to-perform-a-one-proportion-z-test-in-r-with-examples/.
stats writer. "How to Perform a One Proportion Z-Test in R (With Examples)." PSYCHOLOGICAL SCALES, 2025. https://scales.arabpsychology.com/stats/how-to-perform-a-one-proportion-z-test-in-r-with-examples/.
stats writer (2025) 'How to Perform a One Proportion Z-Test in R (With Examples)', PSYCHOLOGICAL SCALES. Available at: https://scales.arabpsychology.com/stats/how-to-perform-a-one-proportion-z-test-in-r-with-examples/.
[1] stats writer, "How to Perform a One Proportion Z-Test in R (With Examples)," PSYCHOLOGICAL SCALES, vol. X, no. Y, ص Z-Z, December, 2025.
stats writer. How to Perform a One Proportion Z-Test in R (With Examples). PSYCHOLOGICAL SCALES. 2025;vol(issue):pages.
