EZ Statistics

One Proportion Z-Test

Calculator

Input Your Values

Learn More

One-Proportion Z-Test

Definition

One-Proportion Z-Test is used to test if a population proportion is significantly different from a hypothesized value. It's commonly used for analyzing success rates, percentages, or proportions in a single group.

Formula

Test Statistic:

z=p^p0p0(1p0)nz = \frac{\hat{p} - p_0}{\sqrt{\frac{p_0(1-p_0)}{n}}}

Where:

  • p^\hat{p} = sample proportion
  • p0p_0 = hypothesized population proportion
  • nn = sample size

Confidence Interval:

Two-sided: CI=p^±zα/2p^(1p^)n\text{Two-sided: }CI = \hat{p} \pm z_{\alpha/2}\sqrt{\frac{\hat{p}(1-\hat{p})}{n}}One-sided: CI=p^+zαp^(1p^)n\text{One-sided: }CI = \hat{p} + z_{\alpha}\sqrt{\frac{\hat{p}(1-\hat{p})}{n}}

Where zα/2z_{\alpha/2} and zαz_{\alpha} are the critical values for the desired confidence level.

Key Assumptions

Random Sample: Data must be a random sample from the population
Independence: Observations must be independent
Sample Size: Both np₀ and n(1-p₀) should be ≥ 10

Common Pitfalls

  • Using the test when sample size conditions aren't met
  • Not checking for independence of observations
  • Confusing statistical significance with practical importance

Practical Example

Testing if a new manufacturing process meets quality standards:

Step 1: State the Data
  • Sample size: nn = 100 units
  • Defect-free units: xx = 45 units
  • Sample proportion: p^=45/100=0.45\hat p = 45/100 = 0.45
Step 2: State Hypotheses
  • H0:p=0.50H_0: p = 0.50 (standard quality level)
  • Ha:p0.50H_a: p \neq 0.50 (different from standard)
  • α=0.05\alpha = 0.05
Step 3: Calculate Test Statistic

Z-statistic:

z=0.450.500.50(10.50)100=1.00z = \frac{0.45 - 0.50}{\sqrt{\frac{0.50(1-0.50)}{100}}} = -1.00
Step 4: Calculate P-value

For two-tailed test:

p-value=2(1Φ(z))=2(1Φ(1.00))=0.317p\text{-value} = 2(1 - \Phi(|z|)) = 2(1 - \Phi(1.00)) = 0.317
Step 5: Calculate Confidence Interval
CI: 0.45±1.960.45(10.45)100=[0.352,0.548]\text{CI: } 0.45 \pm 1.96\sqrt{\frac{0.45(1-0.45)}{100}} = [0.352, 0.548]
Step 6: Draw Conclusion

Critical value at 5% significance level:

zα/2=1.96z_{\alpha/2} = 1.96

Since z<zα/2|z| < z_{\alpha/2} and p-value>0.05p\text{-value} > 0.05, we fail to reject H0H_0. There is insufficient evidence to conclude that the process quality differs from the standard level.

Effect Size

Cohen's h for one proportion:

h=2arcsinp^2arcsinp0h = 2\arcsin\sqrt{\hat{p}} - 2\arcsin\sqrt{p_0}

Interpretation:

  • Small effect: h0.2|h| \approx 0.2
  • Medium effect: h0.5|h| \approx 0.5
  • Large effect: h0.8|h| \approx 0.8

Power Analysis

Required sample size for desired power:

n=(z1α/2+z1β)2p0(1p0)(pap0)2n = \frac{(z_{1-\alpha/2} + z_{1-\beta})^2 p_0(1-p_0)}{(p_a-p_0)^2}

Where:

  • pap_a = alternative proportion
  • β\beta = Type II error rate
  • α\alpha = significance level

Code Examples

R
1x <- 45    # Number of successes
2n <- 100   # Number of trials
3p <- 0.5   # Null hypothesis proportion
4
5# Perform one-proportion test
6result <- prop.test(
7  x = x,
8  n = n,
9  p = p,
10  alternative = "two.sided",
11  correct = FALSE  # No continuity correction
12)
13
14# Print results
15print(result)
Python
1from statsmodels.stats.proportion import proportions_ztest
2import numpy as np
3from scipy import stats
4
5# Example data
6p0 = 0.5
7success1, n1 = 45, 100
8p1 = success1 / n1
9
10# Perform one-proportion z-test
11zstat, pvalue = proportions_ztest(
12    success1, n1, value=p0, alternative='two-sided'
13)
14
15print(f'z-statistic: {zstat:.4f}')
16print(f'p-value: {pvalue:.4f}')
17
18# construct confidence interval
19alpha = 0.05
20z_critical = stats.norm.ppf(1 - alpha / 2)
21margin_of_error = z_critical * np.sqrt((p1 * (1 - p1) / n1))
22prop_diff = p1
23ci_lower = prop_diff - margin_of_error
24ci_upper = prop_diff + margin_of_error
25print(f'Confidence interval: ({ci_lower:.4f}, {ci_upper:.4f})')

Alternative Tests

Consider these alternatives when assumptions are violated:

  • Exact Binomial Test: For small samples
  • Chi-square Goodness of Fit: For categorical data
  • Bootstrap Methods: When sample size conditions aren't met

Related Calculators

Contingency Table Calculator

Two Proportion Z-Test Calculator

Sample Size Calculator

Chi-Square Test for Goodness of Fit Calculator

Help us improve

Found an error or have a suggestion? Let us know!