$z$ test for the difference between two proportions
This page offers all the basic information you need about the $z$ test for the difference between two proportions. It is part of Statkat’s wiki module, containing similarly structured info pages for many different statistical methods. The info pages give information about null and alternative hypotheses, assumptions, test statistics and confidence intervals, how to find p values, SPSS howto’s and more.
To compare the $z$ test for the difference between two proportions with other statistical methods, go to Statkat's or practice with the $z$ test for the difference between two proportions at Statkat's
Contents
 1. When to use
 2. Null hypothesis
 3. Alternative hypothesis
 4. Assumptions
 5. Test statistic
 6. Sampling distribution
 7. Significant?
 8. Approximate $C\%$ confidence interval for $\pi_1  \pi_2$
 9. Equivalent to
 10. Example context
 11. SPSS
 12. Jamovi
When to use?
Deciding which statistical method to use to analyze your data can be a challenging task. Whether a statistical method is appropriate for your data is partly determined by the measurement level of your variables. The $z$ test for the difference between two proportions requires the following variable types:
Independent/grouping variable: One categorical with 2 independent groups  Dependent variable: One categorical with 2 independent groups 
Note that theoretically, it is always possible to 'downgrade' the measurement level of a variable. For instance, a test that can be performed on a variable of ordinal measurement level can also be performed on a variable of interval measurement level, in which case the interval variable is downgraded to an ordinal variable. However, downgrading the measurement level of variables is generally a bad idea since it means you are throwing away important information in your data (an exception is the downgrade from ratio to interval level, which is generally irrelevant in data analysis).
If you are not sure which method you should use, you might like the assistance of our method selection tool or our method selection table.
Null hypothesis
The $z$ test for the difference between two proportions tests the following null hypothesis (H_{0}):
H_{0}: $\pi_1 = \pi_2$$\pi_1$ is the population proportion of 'successes' for group 1; $\pi_2$ is the population proportion of 'successes' for group 2
Alternative hypothesis
The $z$ test for the difference between two proportions tests the above null hypothesis against the following alternative hypothesis (H_{1} or H_{a}):
H_{1} two sided: $\pi_1 \neq \pi_2$H_{1} right sided: $\pi_1 > \pi_2$
H_{1} left sided: $\pi_1 < \pi_2$
Assumptions
Statistical tests always make assumptions about the sampling procedure that's been used to obtain the sample data. So called parametric tests also make assumptions about how data are distributed in the population. Nonparametric tests are more 'robust' and make no or less strict assumptions about population distributions, but are generally less powerful. Violation of assumptions may render the outcome of statistical tests useless, although violation of some assumptions (e.g. independence assumptions) are generally more problematic than violation of other assumptions (e.g. normality assumptions in combination with large samples).
The $z$ test for the difference between two proportions makes the following assumptions:
 Sample size is large enough for $z$ to be approximately normally distributed. Rule of thumb:
 Significance test: number of successes and number of failures are each 5 or more in both sample groups
 Regular (large sample) 90%, 95%, or 99% confidence interval: number of successes and number of failures are each 10 or more in both sample groups
 Plus four 90%, 95%, or 99% confidence interval: sample sizes of both groups are 5 or more
 Group 1 sample is a simple random sample (SRS) from population 1, group 2 sample is an independent SRS from population 2. That is, within and between groups, observations are independent of one another
Test statistic
The $z$ test for the difference between two proportions is based on the following test statistic:
$z = \dfrac{p_1  p_2}{\sqrt{p(1  p)\Bigg(\dfrac{1}{n_1} + \dfrac{1}{n_2}\Bigg)}}$$p_1$ is the sample proportion of successes in group 1: $\dfrac{X_1}{n_1}$, $p_2$ is the sample proportion of successes in group 2: $\dfrac{X_2}{n_2}$, $p$ is the total proportion of successes in the sample: $\dfrac{X_1 + X_2}{n_1 + n_2}$, $n_1$ is the sample size of group 1, $n_2$ is the sample size of group 2
Note: we could just as well compute $p_2  p_1$ in the numerator, but then the left sided alternative becomes $\pi_2 < \pi_1$, and the right sided alternative becomes $\pi_2 > \pi_1$
Sampling distribution
Sampling distribution of $z$ if H_{0} were true:Approximately the standard normal distribution
Significant?
This is how you find out if your test result is significant:
Two sided: Check if $z$ observed in sample is at least as extreme as critical value $z^*$ or
 Find two sided $p$ value corresponding to observed $z$ and check if it is equal to or smaller than $\alpha$
 Check if $z$ observed in sample is equal to or larger than critical value $z^*$ or
 Find right sided $p$ value corresponding to observed $z$ and check if it is equal to or smaller than $\alpha$
 Check if $z$ observed in sample is equal to or smaller than critical value $z^*$ or
 Find left sided $p$ value corresponding to observed $z$ and check if it is equal to or smaller than $\alpha$
Approximate $C\%$ confidence interval for $\pi_1  \pi_2$
Regular (large sample):
$(p_1  p_2) \pm z^* \times \sqrt{\dfrac{p_1(1  p_1)}{n_1} + \dfrac{p_2(1  p_2)}{n_2}}$
where the critical value $z^*$ is the value under the normal curve with the area $C / 100$ between $z^*$ and $z^*$ (e.g. $z^*$ = 1.96 for a 95% confidence interval)

$(p_{1.plus}  p_{2.plus}) \pm z^* \times \sqrt{\dfrac{p_{1.plus}(1  p_{1.plus})}{n_1 + 2} + \dfrac{p_{2.plus}(1  p_{2.plus})}{n_2 + 2}}$
where $p_{1.plus} = \dfrac{X_1 + 1}{n_1 + 2}$, $p_{2.plus} = \dfrac{X_2 + 1}{n_2 + 2}$, and the critical value $z^*$ is the value under the normal curve with the area $C / 100$ between $z^*$ and $z^*$ (e.g. $z^*$ = 1.96 for a 95% confidence interval)
Equivalent to
The $z$ test for the difference between two proportions is equivalent to:
When testing two sided: chisquared test for the relationship between two categorical variables, where both categorical variables have 2 levelsExample context
The $z$ test for the difference between two proportions could for instance be used to answer the question:
Is the proportion of smokers different between men and women? Use the normal approximation for the sampling distribution of the test statistic.SPSS
How to perform the $z$ test for the difference between two proportions in SPSS:
SPSS does not have a specific option for the $z$ test for the difference between two proportions. However, you can do the chisquared test instead. The $p$ value resulting from this chisquared test is equivalent to the two sided $p$ value that would have resulted from the $z$ test. Go to:Analyze > Descriptive Statistics > Crosstabs...
 Put your independent (grouping) variable in the box below Row(s), and your dependent variable in the box below Column(s)
 Click the Statistics... button, and click on the square in front of Chisquare
 Continue and click OK
Jamovi
How to perform the $z$ test for the difference between two proportions in jamovi:
Jamovi does not have a specific option for the $z$ test for the difference between two proportions. However, you can do the chisquared test instead. The $p$ value resulting from this chisquared test is equivalent to the two sided $p$ value that would have resulted from the $z$ test. Go to:Frequencies > Independent Samples  $\chi^2$ test of association
 Put your independent (grouping) variable in the box below Rows, and your dependent variable in the box below Columns