$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 how-to’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

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:

Variable types required for the $z$ test for the difference between two proportions :
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 (H0):

H0: $\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 (H1 or Ha):

H1 two sided: $\pi_1 \neq \pi_2$
H1 right sided: $\pi_1 > \pi_2$
H1 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. Non-parametric 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:

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 H0 were true:

Approximately the standard normal distribution
Significant?

This is how you find out if your test result is significant:

Two sided: Right sided: Left sided:
Approximate $C\%$ confidence interval for $\pi_1 - \pi_2$

Regular (large sample): With plus four method:
Equivalent to

The $z$ test for the difference between two proportions is equivalent to:

When testing two sided: chi-squared test for the relationship between two categorical variables, where both categorical variables have 2 levels
Example 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 chi-squared test instead. The $p$ value resulting from this chi-squared test is equivalent to the two sided $p$ value that would have resulted from the $z$ test. Go to:

Analyze > Descriptive Statistics > Crosstabs...
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 chi-squared test instead. The $p$ value resulting from this chi-squared 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