## Two sample proportion test

Suppose we want to compare two distinct populations $A$ and $B$ with respect to possessions of certain attribute among their members. Suppose take samples of sizes $n_1$ and $n_2$ from the population A and B respectively.

Let $X_1$ and $X_2$ be the observed number of successes i.e., number of units possessing the attributes, from the two samples respectively.

The hypothesis testing problem can be setup as:

Situation Hypothesis Testing Problem
Situation A : $H_0: p_1=p_2$ against $H_a : p_1 < p_2$ (Left-tailed)
Situation B : $H_0: p_1=p_2$ against $H_a : p_1 > p_2$ (Right-tailed)
Situation C : $H_0: p_1=p_2$ against $H_a : p_1 \neq p_2$ (Two-tailed)

## Formula

The test statistic for testing $H_0$ is

### $Z = \frac{(\hat{p}_1-\hat{p}_2)-(p_1-p_2)}{SE(\hat{p}_1-\hat{p}_2)}$

where

• $\hat{p}_1=\frac{X_1}{n_1}$ be the observed proportion of successes in the sample from population $A$,

• $\hat{p}_2=\frac{X_2}{n_2}$ be the observed proportion of successes in the sample from population $B$.

• $SE(\hat{p}_1-\hat{p}_2) = \sqrt{\frac{\hat{p}(1-\hat{p})}{n_1}+\frac{\hat{p}(1-\hat{p})}{n_2}}$ is the standard error of the difference between two proportions,

• $\hat{p} =\dfrac{X_1 +X_2}{n_1 + n_2}$ is the pooled estimate of sample proportion.

The test statistic $Z$ follows standard normal distribution $N(0,1)$.