The Problem
Example #78: Let us test the null hypothesis that the success rate in the population is 9%. In symbols, this is:
H0 : p = 0.09
HA : p ≠ 0.09
To test this hypothesis, we collect data. The data are a series of “Success” and “Failure” values. In this sample, the data are
“Failure”, “Failure”, “Failure”, “Failure”, “Failure”, “Failure”, “Failure”, “Failure”, “Failure”, “Failure”, “Failure”, “Failure”, “Failure”, “Failure”, “Failure”, “Failure”, “Failure”, “Success”, “Failure”, “Failure”, “Failure”, “Success”, “Failure”, “Failure”, “Failure”, “Failure”, “Failure”, “Failure”, “Failure”, “Failure”, “Failure”, “Failure”, “Failure”, “Failure”, “Failure”, “Success”
With this information, calculate the test statistic corresponding to the null hypothesis. Use the Wald version of the test statistic.
Information given:
To summarize the above, the values of import are:
Summary statistics from the problem
\( p_0 \)
| = |
0.09 |
\( x \)
| = |
3 |
\( n \)
| = |
36 |
\( \hat{p} \)
| = |
0.0833 |
Calculate these values yourself then hover your mouse over the grey spaces to see if you calculated them correctly.
Assistance
Hide Solution
$$ \begin{align}
z &= \frac{ \hat{p} - p_0}{\sqrt{ \frac{ p_0 \left(1 - p_0\right) }{n}}} \\[3em]
&= \frac{ 0.0833 - 0.09}{\sqrt{ \frac{ 0.09\ \left(1 - 0.09 \right) }{36}}} \\[1em]
&= \frac{ -0.0067}{\sqrt{ \frac{ 0.09\ \left( 0.91\right) }{36}}} \\[1em]
&= \frac{ -0.0067}{\sqrt{ \frac{ 0.0819 }{36}}} \\[1em]
&= \frac{ -0.0067}{\sqrt{ 0.002275}} \\[1em]
&= \frac{ -0.0067}{ 0.047697} \\[1em]
&= -0.1398 \\[1em]
\end{align}
$$
And so, the test statistic is z = -0.1398. To use this, you would compare it to the ciritical value from the z-table.
For instance, let us specify α = 0.05. This is a two-tailed test, because the alternative hypothesis uses ≠. Because of these two facts, the two critical values are -1.96 and +1.96.
Since the test statistic is between the two critical values, it is not in the rejection region. Thus, we fail to reject the null hypothesis in favor of the alternative.
Hide the R Code
Like the Wald test, the Score test is pedagogically simple to understand. It, too, is based on the Normal approximation to the Binomial distribution. There are several improvements to the test. For these reasons, R does not have a built-in function to perform the Score test for proportions (although a few packages offer this function). The following code echoes the above calculations to provide the Score test statistic.
Copy and paste the following code into your R script window, then run it from there.
sample = c("Failure", "Failure", "Failure", "Failure", "Failure", "Failure", "Failure", "Failure", "Failure", "Failure", "Failure", "Failure", "Failure", "Failure", "Failure", "Failure", "Failure", "Success", "Failure", "Failure", "Failure", "Success", "Failure", "Failure", "Failure", "Failure", "Failure", "Failure", "Failure", "Failure", "Failure", "Failure", "Failure", "Failure", "Failure", "Success")
x = sum(sample=="Success")
n = length(sample)
p0 = 0.09
phat = x/n
se2 = p0*(1-p0)/n
ts = (phat - 0.09)/sqrt(se2)
ts
In the R output, the test statistic is the number output after running the “ts
” line. Note that R will give you calculations that are more accurate and more precise than doing the calculations by hand. As such, this computer-calculated test statistic will differ slightly from the one you calculate by hand.
Hide the Excel Code
Like the Wald test, the Score test is pedagogically simple to understand. It, too, is based on the Normal approximation to the Binomial distribution. There are several improvements to the test. For these reasons, Excel does not have a built-in function to perform the Score test for proportions. The following code echoes the above calculations to provide the Score test statistic.
Copy and paste the following code into your Excel window, making sure the value sample
ends up in A1
after pasting.
How to calculate the test statistic in Excel.
sample | | | |
Failure |
|
p0: |
0.09 |
Failure |
|
x: |
=COUNTIF(A:A,"Success") |
Failure |
|
n: |
=COUNTIF(A:A,"Success")+COUNTIF(A:A,"Failure") |
Failure |
|
p-hat: |
=D3/D4 |
Failure |
|
ts: |
=(D5-D2)/sqrt(D2*(1-D2)/D4) |
Failure |
|
|
|
Failure |
|
|
|
Failure |
|
|
|
Failure |
|
|
|
Failure |
|
|
|
Failure |
|
|
|
Failure |
|
|
|
Failure |
|
|
|
Failure |
|
|
|
Failure |
|
|
|
Failure |
|
|
|
Failure |
|
|
|
Success |
|
|
|
Failure |
|
|
|
Failure |
|
|
|
Failure |
|
|
|
Success |
|
|
|
Failure |
|
|
|
Failure |
|
|
|
Failure |
|
|
|
Failure |
|
|
|
Failure |
|
|
|
Failure |
|
|
|
Failure |
|
|
|
Failure |
|
|
|
Failure |
|
|
|
Failure |
|
|
|
Failure |
|
|
|
Failure |
|
|
|
Failure |
|
|
|
Success |
|
|
|
The Score test statistic is the number calculated in cell D6. Again, when you paste this code into Excel, make sure that you start the pasting in cell A1. To help with that, you may want to also copy this notice. It seems to help.