How to run a 2-proportion test
- Copy the group column, the event count column and the total count column together with the header (several rows per day or lot are fine).
- Set the three columns and choose the test method. With very few events, Fisher's exact test is safer.
- Press Analyze and check the proportion difference, p-value, odds ratio forest plot and interpretation.
Worked example with sample data
The sample data are daily defect counts from line A and line B over 8 days, with 200 items inspected per day. Using the line column as the group and the defects and inspected columns as events and totals sums each line to 1600 items.
The defect rates are 24/1600 = 1.5% for line A and 54/1600 = 3.375% for line B. The normal-approximation Z test (pooled proportion) gives a very small p-value of 0.0005839, so the defect rates of the two lines differ; choosing Fisher's exact test gives the same conclusion (p=0.000779).
The proportion difference (A - B) is -1.875 percentage points with a 95% confidence interval of -2.942 to -0.808 points. The relative risk of 0.4444 means line A's defect rate is about 44% of line B's, and the odds ratio of 0.436 (95% CI 0.2682 to 0.7088) is also below 1.
In the result chart, the Wilson confidence intervals of the two lines (A 1.01-2.22%, B 2.60-4.38%) do not overlap. Daily defect counts are also generally higher on line B (3 to 10) than on line A (0 to 8), so the next step is to find what differs in line B's equipment, materials or working conditions.
Test methods
With a reference difference of 0, the normal approximation (default) computes Z with a standard error from the pooled proportion of both groups. The continuity correction subtracts 0.5(1/n1+1/n2) from the difference to make it conservative, and Fisher's exact test computes an exact p-value from the hypergeometric distribution of the 2×2 table.
Proportion difference, relative risk and odds ratio
The confidence interval of the proportion difference (group 1 - group 2) uses the Wald method (95%). The relative risk is p1/p2 and the odds ratio is (a·d)/(b·c), with confidence intervals on the log scale. The odds ratio is not calculated when a group has 0 events or only events.
Group order
The group names are sorted and the first becomes group 1. In the one-sided option 'Group 1 proportion > group 2 proportion', group 1 is the group that comes first in sort order, or the first group entered in manual mode.
How to read the comparison of two proportions
- A p-value below the significance level means the two proportions differ, and the interpretation tells you which group's proportion is higher and by how much.
- In the odds ratio forest plot, the difference is significant when the confidence interval does not cross 1 (dashed line). Below 1 means group 1 has lower odds of the event.
- Also check whether the confidence interval of the proportion difference contains 0. The more items inspected, the narrower the interval.
Frequently asked questions
Is it the same as a chi-square test?
The square of the normal-approximation Z without continuity correction equals the 2×2 chi-square statistic, so the two-sided p-values are the same.
When should I use Fisher's exact test?
When events are so few that some cells have an expected count below 5. It also works for large samples but gives somewhat conservative results.
How do relative risk and odds ratio differ?
The relative risk is the ratio of proportions (p1/p2) and the odds ratio is the ratio of odds (p/(1-p)). For small proportions such as defect rates the two are close.