Two-Proportion Z-Test Calculator
The two-proportion test (the two-sample z test for proportions) checks whether the rate at which an event occurs differs between two independent groups. It is the test behind comparisons such as the recovery rate in a treatment group versus a control group, the conversion rate of two ad variants, or the share of people holding an opinion in two districts. The null hypothesis states that the two population proportions are equal (π₁ = π₂); the alternative states that they differ.
This calculator returns more than the z value: it reports the pooled proportion, the standard error of the difference, the critical value, the Newcombe score confidence interval for the difference, and Cohen h as the effect size. It also lays out the observed and expected frequencies in a contingency table, tells you when the smallest expected frequency drops below 5 and you should switch to Fisher's exact test, and reports Fisher's exact p-value alongside.
Two-Proportion Test Formulas
Sample proportions: p̂₁ = x₁ / n₁ , p̂₂ = x₂ / n₂ Pooled proportion: p̄ = (x₁ + x₂) / (n₁ + n₂) Standard error (H₀): SE = √[ p̄(1 − p̄) · (1/n₁ + 1/n₂) ] Test statistic: z = (p̂₁ − p̂₂) / SE Unpooled SE: SEᵤ = √[ p̂₁(1−p̂₁)/n₁ + p̂₂(1−p̂₂)/n₂ ] Confidence interval: Newcombe square-and-add (from two Wilson intervals) Effect size: h = 2·arcsin√p̂₁ − 2·arcsin√p̂₂ Expected frequency: Eᵢⱼ = (row total × column total) / N
The test statistic uses the pooled proportion because under H₀ the two population proportions are equal; the confidence interval carries no such constraint, so it uses the separate proportions. Cohen h thresholds: 0.20 small, 0.50 medium, 0.80 large.
How to Calculate
- Enter the event count (how many times the outcome of interest — a success, a recovery, a click — occurred) and the total sample size for both groups.
- Choose the hypothesis direction: stay with two-tailed unless you can justify the direction of the difference in advance.
- Set the significance level (α); the confidence interval is produced automatically at the 1 − α level.
- Compare the z value, the p-value, and the critical value; the decision line states the conclusion directly.
- Check the smallest expected frequency in the contingency table: if it is below 5, report Fisher's exact p-value instead.
- Report the confidence interval for the difference in proportions together with Cohen h; the p-value alone says nothing about the practical importance of the difference.
Worked Examples
Recovery rate in a treatment and a control group
In the treatment group 48 of 120 patients recovered (40.00%), and in the control group 30 of 110 (27.27%). The pooled proportion is 33.91%, the standard error is 0.0625, and z = 2.037; with a two-tailed p = 0.042 the difference is significant at α = 0.05. The 95% confidence interval for the difference runs from 0.48% to 24.37%, and Cohen h = 0.271 (a small effect).
z statistic: 2.037 · Degrees of freedom: — · p-value: p = 0.042
Conversion rate of two ad variants (A/B test)
Variant A converted at 10.50% and variant B at 9.00%. With z = 1.599 and p = 0.110, the 1.50-point gap is not statistically significant; the 95% confidence interval runs from -0.34% to 3.34% and therefore contains zero. Cohen h = 0.051 is negligible — note how a small difference can stay non-significant even in a large sample.
z statistic: 1.599 · Degrees of freedom: — · p-value: p = 0.110
Small sample — Fisher's exact test is required
The proportions are 13.33% and 56.25%, giving z = -2.496 and p = 0.013. Even though the smallest expected frequency is 5.32, the cell counts are small and Fisher's exact test returns p = 0.023. Because the normal approximation can make the p-value look smaller than it is in small samples, the Fisher result should be preferred in the report.
z statistic: -2.496 · Degrees of freedom: — · p-value: p = 0.013