The two-proportion Z-test (also called the two-sample proportion Z-test) is a statistical hypothesis test for assessing whether two groups differ in the proportion of a binary outcome, in such a significant way that is beyond chance. For example, the proportion of patients responding positively to a treatment in a clinical trial versus control, the defect rate in quality control for two production lines, or the click-through rate in an A/B test of two alternative webpage designs. The test is appropriate when each observation is independent from another, can be classified as a success or failure (i.e., a Bernoulli trial) and the sample sizes are large enough that the sampling distribution of each sample proportion is well approximated by the central limit theorem. Under those conditions the observed difference of sample proportions can be converted to a standardized z-statistic (using a pooled standard error) and compared to the standard normal distribution to obtain p-values or form confidence intervals for the difference in proportions (derived slightly differently). This also allows to determine required sample-size for a minimum-detectable-effect calculations. The test is related to other well known tests such as Pearson's chi-squared test, Fisher's exact test for small samples, and McNemar's test for paired binary data.
Definition The two-proportion Z-test or two-sample proportion Z-test is a statistical method used to determine whether the difference between the proportions of two groups, coming from a binomial distribution is statistically significant. This approach relies on the observation that (for a sufficiently large samples) the sample proportions follow a normal distribution under the Central Limit Theorem, allowing the construction of a z-test for hypothesis testing (a Score test) and confidence interval estimation (a Wald test). It is used in various fields to compare success rates, response rates, or other proportions across different groups.
Hypothesis test The z-test for comparing two proportions is a frequentist statistical hypothesis test used to evaluate whether two independent samples have different population proportions for a binary outcome. Under mild regularity conditions (sufficiently large sample sizes and independent sampling), the sample proportions (which is the average of observations coming from a Bernoulli distribution) are approximately normally distributed under the central limit theorem, which permits using a z-statistic constructed from the difference of sample proportions and an estimated standard error. The test involves two competing hypotheses:
null hypothesis (H0): The proportions in the two populations are equal, i.e., p1=p2. alternative hypothesis (H1): The proportions in the two populations are not equal, i.e., p1≠p2 (two-tailed) or p1>p2 / p1<p2 (one-tailed). The z-statistic for comparing two proportions is computed using:z=p̂1−p̂2p̂(1−p̂)(1n1+1n2),where p̂1 and p̂2 are the sample proportion in the first and second sample, n1 and n2 are the size of the first and second sample, respectively, p̂ is pooled proportion, calculated as p̂=x1+x2n1+n2, where x1 and x2 are the counts of successes in the two samples The pooled proportion is used to estimate the shared probability of success under the null hypothesis, and the standard error accounts for variability across the two samples. The z-test determines statistical significance by comparing the calculated z-statistic to a critical value. E.g., for a significance level of α=0.05 we reject the null hypothesis if |z|>1.96 (for a two-tailed test). Or, alternatively, by computing the p-value and rejecting the null hypothesis if p<α.
Confidence interval The confidence interval for the difference between two proportions, based on the definitions above, is:(p̂1−p̂2)±zα/2p̂1(1−p̂1)n1+p̂2(1−p̂2)n2,where zα/2 is the critical value of the standard normal distribution (e.g., 1.96 for a 95% confidence level). This interval provides a range of plausible values for the true difference between population proportions. Notice how the variance estimation is different between the hypothesis testing and the confidence intervals. The first uses a pooled variance (based on the null hypothesis), while the second has to estimate the variance using each sample separately (so as to allow for the confidence interval to accommodate a range of differences in proportions). This difference may lead to slightly different results if using the confidence interval as an alternative to the hypothesis testing method.
Sample size determination and Minimum detectable effect Sample size determination is the act of choosing the number of observations to include in each group for running the statistical test. For the Two-proportion Z-test, this is closely-related with deciding on the minimum detectable effect. For finding the required sample size (given some effect size |p1−p2|, power π=(1−β), and type I error α), we define that n1=κn2, (when κ = 1, equal sample size is assumed for each group), then: n2=(Zα/2+Zβ)2(p1−p2)2×(p1(1−p1)κ+p2(1−p2)) The minimum detectable effect or MDE is the smallest difference between two proportions (p1 and p2) that a statistical test can detect for a chosen type I error level (α), statistical power (1−β), and sample sizes (n1 and n2). It is commonly used in study design to determine whether the sample sizes allows for a test with sufficient sensitivity to detect meaningful differences. The MDE for when using the (two-sided) z-test formula for comparing two proportions, incorporating critical values for α and 1−β, and the standard errors of the proportions:MDE=|p1−p2|=z1−α/2p0(1−p0)(1n1+1n2)+z1−βp1(1−p1)n1+p2(1−p2)n2,where z1−α/2 is critical value for the significance level, z1−β is quantile for the desired power, and p0=p1=p2 is when assuming the null is correct. The MDE depends on the sample sizes, baseline proportions (p1,p2), and test parameters. When the baseline proportions are not known, they need to be assumed or roughly estimated from a small study. Larger samples or smaller power requirements leads to a smaller MDE, making the test more sensitive to smaller differences. Researchers may use the MDE to assess the feasibility of detecting meaningful differences before conducting a study.
Assumptions and conditions To ensure valid results, the following assumptions must be met:
… excerpt ends here. Continue reading the full article.