# z test for a single proportion - overview

This page offers structured overviews of one or more selected methods. Add additional methods for comparisons by clicking on the dropdown button in the right-hand column. To practice with a specific method click the button at the bottom row of the table

$z$ test for a single proportion
Kruskal-Wallis test
Independent variableIndependent/grouping variable
NoneOne categorical with $I$ independent groups ($I \geqslant 2$)
Dependent variableDependent variable
One categorical with 2 independent groupsOne of ordinal level
Null hypothesisNull hypothesis
H0: $\pi = \pi_0$

Here $\pi$ is the population proportion of 'successes', and $\pi_0$ is the population proportion of successes according to the null hypothesis.
If the dependent variable is measured on a continuous scale and the shape of the distribution of the dependent variable is the same in all $I$ populations:
• H0: the population medians for the $I$ groups are equal
Else:
Formulation 1:
• H0: the population scores in any of the $I$ groups are not systematically higher or lower than the population scores in any of the other groups
Formulation 2:
• H0: P(an observation from population $g$ exceeds an observation from population $h$) = P(an observation from population $h$ exceeds an observation from population $g$), for each pair of groups.
Several different formulations of the null hypothesis can be found in the literature, and we do not agree with all of them. Make sure you (also) learn the one that is given in your text book or by your teacher.
Alternative hypothesisAlternative hypothesis
H1 two sided: $\pi \neq \pi_0$
H1 right sided: $\pi > \pi_0$
H1 left sided: $\pi < \pi_0$
If the dependent variable is measured on a continuous scale and the shape of the distribution of the dependent variable is the same in all $I$ populations:
• H1: not all of the population medians for the $I$ groups are equal
Else:
Formulation 1:
• H1: the poplation scores in some groups are systematically higher or lower than the population scores in other groups
Formulation 2:
• H1: for at least one pair of groups:
P(an observation from population $g$ exceeds an observation from population $h$) $\neq$ P(an observation from population $h$ exceeds an observation from population $g$)
AssumptionsAssumptions
• Sample size is large enough for $z$ to be approximately normally distributed. Rule of thumb:
• Significance test: $N \times \pi_0$ and $N \times (1 - \pi_0)$ are each larger than 10
• Regular (large sample) 90%, 95%, or 99% confidence interval: number of successes and number of failures in sample are each 15 or more
• Plus four 90%, 95%, or 99% confidence interval: total sample size is 10 or more
• Sample is a simple random sample from the population. That is, observations are independent of one another
If the sample size is too small for $z$ to be approximately normally distributed, the binomial test for a single proportion should be used.
• Group 1 sample is a simple random sample (SRS) from population 1, group 2 sample is an independent SRS from population 2, $\ldots$, group $I$ sample is an independent SRS from population $I$. That is, within and between groups, observations are independent of one another
Test statisticTest statistic
$z = \dfrac{p - \pi_0}{\sqrt{\dfrac{\pi_0(1 - \pi_0)}{N}}}$
Here $p$ is the sample proportion of successes: $\dfrac{X}{N}$, $N$ is the sample size, and $\pi_0$ is the population proportion of successes according to the null hypothesis.

$H = \dfrac{12}{N (N + 1)} \sum \dfrac{R^2_i}{n_i} - 3(N + 1)$

Here $N$ is the total sample size, $R_i$ is the sum of ranks in group $i$, and $n_i$ is the sample size of group $i$. Remember that multiplication precedes addition, so first compute $\frac{12}{N (N + 1)} \times \sum \frac{R^2_i}{n_i}$ and then subtract $3(N + 1)$.

Note: if ties are present in the data, the formula for $H$ is more complicated.
Sampling distribution of $z$ if H0 were trueSampling distribution of $H$ if H0 were true
Approximately the standard normal distribution

For large samples, approximately the chi-squared distribution with $I - 1$ degrees of freedom.

For small samples, the exact distribution of $H$ should be used.

Significant?Significant?
Two sided:
Right sided:
Left sided:
For large samples, the table with critical $X^2$ values can be used. If we denote $X^2 = H$:
• Check if $X^2$ observed in sample is equal to or larger than critical value $X^{2*}$ or
• Find $p$ value corresponding to observed $X^2$ and check if it is equal to or smaller than $\alpha$
Approximate $C\%$ confidence interval for $\pi$n.a.
Regular (large sample):
• $p \pm z^* \times \sqrt{\dfrac{p(1 - p)}{N}}$
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)
With plus four method:
• $p_{plus} \pm z^* \times \sqrt{\dfrac{p_{plus}(1 - p_{plus})}{N + 4}}$
where $p_{plus} = \dfrac{X + 2}{N + 4}$ 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 ton.a.
• When testing two sided: goodness of fit test, with a categorical variable with 2 levels.
• When $N$ is large, the $p$ value from the $z$ test for a single proportion approaches the $p$ value from the binomial test for a single proportion. The $z$ test for a single proportion is just a large sample approximation of the binomial test for a single proportion.
-
Example contextExample context
Is the proportion of smokers amongst office workers different from $\pi_0 = 0.2$? Use the normal approximation for the sampling distribution of the test statistic.Do people from different religions tend to score differently on social economic status?
SPSSSPSS
Analyze > Nonparametric Tests > Legacy Dialogs > Binomial...
• Put your dichotomous variable in the box below Test Variable List
• Fill in the value for $\pi_0$ in the box next to Test Proportion
If computation time allows, SPSS will give you the exact $p$ value based on the binomial distribution, rather than the approximate $p$ value based on the normal distribution
Analyze > Nonparametric Tests > Legacy Dialogs > K Independent Samples...
• Put your dependent variable in the box below Test Variable List and your independent (grouping) variable in the box below Grouping Variable
• Click on the Define Range... button. If you can't click on it, first click on the grouping variable so its background turns yellow
• Fill in the smallest value you have used to indicate your groups in the box next to Minimum, and the largest value you have used to indicate your groups in the box next to Maximum
• Continue and click OK
JamoviJamovi
Frequencies > 2 Outcomes - Binomial test
• Put your dichotomous variable in the white box at the right
• Fill in the value for $\pi_0$ in the box next to Test value
• Under Hypothesis, select your alternative hypothesis
Jamovi will give you the exact $p$ value based on the binomial distribution, rather than the approximate $p$ value based on the normal distribution
ANOVA > One Way ANOVA - Kruskal-Wallis
• Put your dependent variable in the box below Dependent Variables and your independent (grouping) variable in the box below Grouping Variable
Practice questionsPractice questions