The previous module covered inference for a continuous mean. Now we handle proportions -- when the response variable is binary (yes/no, success/failure, heads/tails).
The logic is the same as for means: use p̂ to estimate p, quantify uncertainty with a confidence interval, and test claims with a hypothesis test.
When to use proportion inference: When your response variable is categorical and binary. "What fraction of UW students prefer R over Python?" is a proportion question. "What is the average GPA of UW students?" is a mean question.
By the Central Limit Theorem, for large n:
Conditions for this to hold:
Why these conditions? The normal approximation breaks down when the distribution is too skewed. If p = 0.01 and n = 50, you'd expect 0.5 successes -- the distribution can't look bell-shaped there.
Note: we use z (not t) because we're using the normal approximation and SE is fully determined by p̂.
Reading prop.test output: Our estimate is p̂ = 0.43, and we're 95% confident the true proportion is between 0.333 and 0.531. Since 0.5 is inside the interval, we don't have evidence to reject p = 0.5.
To test a specific claim H₀: p = p₀:
Notice: we use p₀ (the null value) in the denominator, not p̂. Under H0, we assume p = p₀ is true.
Before collecting data, how large a sample do you need for your desired margin of error m?
Using p = 0.5 (the most conservative choice -- maximizes variance):
Why p = 0.5 is conservative: p(1-p) is maximized at p = 0.5, giving p(1-p) = 0.25. Using this gives you the largest sample size, ensuring your interval will be narrow enough no matter what p turns out to be.
Two-sided test:
One-sided test:
Output gives the 95% CI and p-value.
To test a proportion using simulation:
This gives you the empirical p-value from the simulation.
For the normal approximation to p̂ to be valid:
np >= 10 AND n(1-p) >= 10
If either condition fails, use exact binomial methods or simulation instead.
Setup: Chimp A made prosocial choices (helping a partner) 60 out of 90 trials.
Hypotheses:
Check conditions: np0 = 90 x 0.5 = 45 ✓, n(1-p₀) = 45 ✓ (both >= 10)
Interpretation: p̂ = 0.667. p-value ≈ 0.0008 < 0.05 -> reject H0. Strong evidence that Chimp A makes prosocial choices at above-chance rates.
For x successes out of n trials:
1. p̂ = x/n
2. SE = sqrt(p̂(1-p̂)/n)
3. z* = 1.96 (for 95% confidence)
4. CI: p̂ +/- z* x SE
Example: x=60, n=90
95% CI: (0.570, 0.764)
When comparing proportions between two groups, we conduct inference on the difference p1 - p2.
Point estimate:
p̂₁ - p̂₂
Standard Error (using individual proportions, NOT pooled):
Confidence interval:
Example: Chimp A with vs without partner
95% CI: approximately (-0.051, 0.319)
Interpretation: The CI includes 0, so we have no strong evidence that the proportions differ significantly between the two conditions.
To test H₀: p1 = p2, we use a pooled proportion in the standard error:
Pooled proportion:
Standard Error (pooled for hypothesis test):
Test statistic:
Key difference: For the CI we use individual proportions in SE. For the hypothesis test we use the pooled proportion.
Example: Comparing chimp's prosocial choices with vs without partner
Manual calculation:
Interpretation: p-value = 0.246 > 0.05, so we fail to reject H0. There is no significant evidence that Chimp A's prosocial choice rates differ between the with-partner and without-partner conditions.
For confidence intervals: We use p̂₁ and p̂₂ (observed proportions) to reflect the uncertainty in each sample.
For hypothesis tests: We assume H0 is true (p1 = p2 = p-pool), so we use the pooled proportion in the SE.
1. State hypotheses: H₀: p1 = p2 vs Hₐ: p1 != p2 (or > or <)
2. Check conditions: n₁ x p₀ >= 10, n₁ x (1-p₀) >= 10, and similarly for group 2
3. For CI: Use individual proportions in SE
4. For hypothesis test: Use pooled proportion in SE
5. Interpretation: If CI for (p1-p2) contains 0, no significant difference
1. State hypotheses: H₀: p = p₀ vs Hₐ: p != p₀ (or > or <)
2. Check conditions: np0 >= 10 AND n(1-p₀) >= 10
3. Compute test statistic: z = (p̂ - p₀) / sqrt(p₀(1-p₀)/n)
4. Get p-value: Use prop.test() or pnorm()
5. Conclude: Compare p-value to alpha, state conclusion in context