Z test for Two Proportions

The Z test for Two Proportions tests whether two independent group proportions are significantly different — for example, comparing infection rates between two hospitals (15/200 vs 25/200).

Note: Because this test only needs four numbers (the events and totals for each group), there is no Sample Data Generator — you simply enter the values directly or upload a file.


Step 1 — Choose data input method

Option What it means
Manual Data Entry Type the number of events and total sample size for each group
File Upload Upload an Excel or CSV file containing raw patient-level data

Step 2A — Manual entry

Four fields:

  • Group 1: Events (e.g. 15 infections)
  • Group 1: Total (e.g. 200 patients)
  • Group 2: Events
  • Group 2: Total

Step 2B — File Upload

After upload, a column selector asks you to map:

  • A Group column — must contain exactly 2 distinct values
  • An Outcome column — must contain exactly 2 distinct values

Once valid, a Loaded Data Summary panel shows proportions for each group.


Step 3 — Calculate

Click the calculate button.


Step 4 — Read the results

Headline cards:

  • Proportion Difference (p₁ − p₂) with 95% CI
  • Statistical Power of the current test
  • Sample Size (80% Power) — n per group needed

Group Proportions block shows each group's p̂, n, and 95% CI.

Difference in Proportions block shows point estimate, 95% CI, and significance summary.

Statistical Interpretation includes significance verdict and notes on whether t-test approximation was used (for small samples).


Step 5 — Post-hoc power and effect size

  • Current Power
  • Effect Size (Cohen's h) with interpretation label
  • Plain-language interpretation of power adequacy

Step 6 — Sample size analysis

  • Sample size recommendations for 80%, 90%, and 95% power
  • Data Adequacy Assessment — adaptive text describing where your study stands relative to power targets
  • Professional Recommendations tailored to your status

Step 7 — Discuss

A UniversalChatBot is available at the bottom.


Statistical methods used

Automatic Z-test vs t-test switching

Condition Test used
n₁ ≥ 30 AND n₂ ≥ 30 Pure Z-test with normal distribution
n₁ < 30 OR n₂ < 30 t-test approximation with df = n₁ + n₂ − 2

Test statistic formula

Component Formula
Pooled proportion p̂ = (events₁ + events₂) / (n₁ + n₂)
Standard error SE = √(p̂ × (1 − p̂) × (1/n₁ + 1/n₂))
Z-statistic Z = (p̂₁ − p̂₂) / SE

Hypothesis statement

  • H₀: p₁ = p₂ (no difference)
  • H₁: p₁ ≠ p₂ (two-tailed)
  • Significance level: α = 0.05

Effect size — Cohen's h

φ₁ = 2 × arcsin(√p̂₁)
φ₂ = 2 × arcsin(√p̂₂)
h  = |φ₁ − φ₂|
Cohen's h Label
< 0.2 Small
0.2 – 0.5 Medium
0.5 – 0.8 Large
≥ 0.8 Very Large

Required sample size — Fleiss formula

Per-group sample size for target power using the Fleiss formula for comparing two proportions.

File-upload validation

Rule Error if violated
File type must be .xlsx, .xls, or .csv Error shown
Group column must have exactly 2 distinct values "Found: N values..."
Outcome column must have exactly 2 distinct values "Found: N values..."