The Z Test for two dependent proportions

$Z$ Test for two dependent proportions is used in situations similar to the **McNemar's Test**, i.e. when we have 2 dependent groups of measurements ($X^{(1)}$ i $X^{(2)}$), in which we can obtain 2 possible results of the studied feature ((+)(–)).

\begin{tabular}{|c|c||c|c|c|}
\hline
\multicolumn{2}{|c||}{Observed sizes}& \multicolumn{3}{|c|}{$X^{(2)}$} \\\cline{3-5}
\multicolumn{2}{|c||}{$O_{ij}$}&\textbf{(+)}&\textbf{(--)}& \textbf{Suma}\\\hline \hline
\multirow{3}{*}{$X^{(1)}$} & \textbf{(+)} & $O_{11}$ & $O_{12}$ & $O_{11}+O_{12}$ \\\cline{2-5}
&\textbf{(--)}& $O_{21}$ & $O_{22}$ & $O_{21}+O_{22}$\\\cline{2-5}
&\textbf{Sum} & $O_{11}+O_{21}$ & $O_{12}+O_{22}$ & $n=O_{11}+O_{12}+O_{21}+O_{22}$\\\hline
\end{tabular}

We can also calculated distinguished proportions for those groups $p_1=\frac{O_{11}+O_{12}}{n}$ i $p_2=\frac{O_{11}+O_{21}}{n}$. The test serves the purpose of verifying the hypothesis that the distinguished proportions $P_1$ and $P_2$ in the population from which the sample was drawn are equal.
Basic assumptions:

Hypotheses:

$\begin{array}{cl}
\mathcal{H}_0: & P_1-P_2=0,\\
\mathcal{H}_1: & P_1-P_2\neq 0,
\end{array}$

where:

$P_1$, $P_2$ fractions for the first and the second measurement.

The test statistic has the form presented below:

\begin{displaymath}
Z=\frac{p_1-p_2}{\sqrt{O_{21}+O_{12}}}\cdot n,
\end{displaymath}

The $Z$ Statistic asymptotically (for the large sample size) has the normal distribution.

The p-value, designated on the basis of the test statistic, is compared with the significance level $\alpha$:

\begin{array}{ccl}
$ if $ p \le \alpha & \Longrightarrow & $ reject $ \mathcal{H}_0 $ and accept $ 	\mathcal{H}_1, \\
$ if $ p > \alpha & \Longrightarrow & $ there is no reason to reject $ \mathcal{H}_0. \\
\end{array}

Note

Confidence interval for the difference of two dependent proportions is estimated on the basis of the Newcombe-Wilson method.

The window with settings for Z-Test for two dependent proportions is accessed via the menu StatisticsNonparametric testsZ-Test for two dependent proportions.

EXAMPLE cont. (opinion.pqs file)

When we limit the study to people who have a specific opinion about the professor (i.e. those who only have a positive or a negative opinion) we will have 152 such students. The data for calculations are: $O_{11}=50$, $O_{12}=4$, $O_{21}=44$, $O_{22}=54$. We know that $\frac{50+4}{152}=35.53\%$ students expressed a negative opinion before the exam. After the exam the percentage was $\frac{50+44}{152}=61.84%$.

Hypotheses:

$\begin{array}{cl}
\mathcal{H}_0: & $a lack of a difference between the number of negative evaluations of $\\
&$the professor before and after the exam,$\\
\mathcal{H}_1: & $there is a difference between the number of negative evaluations of $\\
&$the professor before and after the exam.$\\
\end{array}$

The difference in proportions distinguished in the sample is 26.32%, and the confidence interval of 95% for the sample (18.07%, 33.88%) does not contain 0.

On the basis of a $Z$ test (p<0.0001), on the significance level of $\alpha$=0.05 (similarly to the case of McNemar's test) we accept the alternative hypothesis. Therefore, the proportion of negative evaluations before the exam differs from the proportion of negative evaluations after the exam. Indeed, after the exam there are more negative evaluations of the professor.