← back to statistics

Inference for Proportions

OpenIntro Statistics · CC BY-SA 3.0 · Chapter 6

When data are counts or categories, proportions replace means. The Z-test for proportions uses the normal approximation to the binomial. The chi-square test extends this to tables with many categories.

Try comparing two sign-up rates and shuffling treatment labels. The formulas below extend the comparison to common proportion procedures. Read the guided introduction β†’

Two versions of a sign-up page

Each visitor receives exactly one randomly assigned version, A or B; the outcome is whether they sign up. This simulated world has sign-up probability 30% for A. You control B’s true difference.

No study yet. Predict whether one study’s observed difference will equal the true difference.

For the randomization test, keep every observed sign-up and non-sign-up fixed. Shuffle them between equally sized groups, as if assignment had no effect on anyone’s outcome. Count shuffled differences at least as far from zero as the observed difference, in either direction.

Differences after shuffling under no effect
Differences after shuffling under no effect. 0 values; exact bin counts are available below.012Frequency-1000100B βˆ’ A (percentage points)Run an experiment to add values.
Read the chart as a table
Differences after shuffling under no effect
Value rangeCount
-100.0–-95.00
-95.0–-90.00
-90.0–-85.00
-85.0–-80.00
-80.0–-75.00
-75.0–-70.00
-70.0–-65.00
-65.0–-60.00
-60.0–-55.00
-55.0–-50.00
-50.0–-45.00
-45.0–-40.00
-40.0–-35.00
-35.0–-30.00
-30.0–-25.00
-25.0–-20.00
-20.0–-15.00
-15.0–-10.00
-10.0–-5.00
-5.0–0.00
0.0–5.00
5.0–10.00
10.0–15.00
15.0–20.00
20.0–25.00
25.0–30.00
30.0–35.00
35.0–40.00
40.0–45.00
45.0–50.00
50.0–55.00
55.0–60.00
60.0–65.00
65.0–70.00
70.0–75.00
75.0–80.00
80.0–85.00
85.0–90.00
90.0–95.00
95.0–100.00

Each range includes its lower end and excludes its upper end, except the last range, which includes both.

0 shuffled assignments.

At most the latest 10,000 shuffles are retained. The Monte Carlo calculation is (extreme shuffles + 1) / (shuffles + 1), so finite simulation never claims a zero p-value. A new study or setting clears the old reference distribution.

One-proportion Z-test

Test whether a sample proportion p-hat differs from a hypothesized value p0. The test statistic is Z = (p-hat - p0) / sqrt(p0 * (1 - p0) / n). Under the null, Z follows a standard normal distribution when n is large enough (np0 and n(1 - p0) both at least 10).

Scheme

Two-proportion Z-test

Compare proportions from two independent groups. Under the null hypothesis p1 = p2, pool the data to estimate the common proportion, then compute the standard error from the pooled value.

0.3 0.5 0.7 Group 1 0.45 Group 2 0.58 overlap
Scheme

Chi-square goodness of fit

Test whether observed counts across k categories match expected proportions. The test statistic sums (observed - expected)^2 / expected across all cells. It follows a wpchi-square distribution with k - 1 degrees of freedom.

Scheme

Chi-square test for independence

Test whether two categorical variables are associated. Arrange data in a contingency table, compute expected counts from row and column totals, then apply the chi-square formula. Degrees of freedom = (rows - 1)(cols - 1).

Scheme

Notation reference

Symbol Formula Meaning
Z(p̂ - p0) / SETest statistic for proportions
SEsqrt(p0(1-p0)/n)Standard error under H0
p̂x / nSample proportion
χ²Σ(O-E)²/EChi-square test statistic
df(r-1)(c-1)Degrees of freedom (independence)
Neighbors

Foundations (Wikipedia)