The Problem
Example #92: Let us test the null hypothesis that the success rate in the population is 62%. In symbols, this is:
H0 : p = 0.62
HA : p ≠ 0.62
To test this hypothesis, we collect data. The data are a series of “Success” and “Failure” values. In this sample, the data are
“Failure”, “Success”, “Success”, “Failure”, “Failure”, “Success”, “Success”, “Failure”, “Success”, “Success”, “Success”, “Failure”, “Success”, “Failure”, “Failure”, “Success”, “Success”, “Success”, “Success”, “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.62 |
\( x \)
| = |
13 |
\( n \)
| = |
20 |
\( \hat{p} \)
| = |
0.65 |
Calculate these values yourself then hover your mouse over the grey spaces to see if you calculated them correctly.
Your Answer
You got the correct answer of z = 0.2764. Congratulations!
Unfortunately, your answer was not correct. Either try again or click on “Show Solution” below to see how to obtain the correct answer.
Assistance
Hide Solution
$$ \begin{align}
z &= \frac{ \hat{p} - p_0}{\sqrt{ \frac{ p_0 \left(1 - p_0\right) }{n}}} \\[3em]
&= \frac{ 0.65 - 0.62}{\sqrt{ \frac{ 0.62\ \left(1 - 0.62 \right) }{20}}} \\[1em]
&= \frac{ 0.03}{\sqrt{ \frac{ 0.62\ \left( 0.38\right) }{20}}} \\[1em]
&= \frac{ 0.03}{\sqrt{ \frac{ 0.2356 }{20}}} \\[1em]
&= \frac{ 0.03}{\sqrt{ 0.01178}} \\[1em]
&= \frac{ 0.03}{ 0.108536} \\[1em]
&= 0.2764 \\[1em]
\end{align}
$$
And so, the test statistic is z = 0.2764. 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", "Success", "Success", "Failure", "Failure", "Success", "Success", "Failure", "Success", "Success", "Success", "Failure", "Success", "Failure", "Failure", "Success", "Success", "Success", "Success", "Success")
x = sum(sample=="Success")
n = length(sample)
p0 = 0.62
phat = x/n
se2 = p0*(1-p0)/n
ts = (phat - 0.62)/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.62 |
Success |
|
x: |
=COUNTIF(A:A,"Success") |
Success |
|
n: |
=COUNTIF(A:A,"Success")+COUNTIF(A:A,"Failure") |
Failure |
|
p-hat: |
=D3/D4 |
Failure |
|
ts: |
=(D5-D2)/sqrt(D2*(1-D2)/D4) |
Success |
|
|
|
Success |
|
|
|
Failure |
|
|
|
Success |
|
|
|
Success |
|
|
|
Success |
|
|
|
Failure |
|
|
|
Success |
|
|
|
Failure |
|
|
|
Failure |
|
|
|
Success |
|
|
|
Success |
|
|
|
Success |
|
|
|
Success |
|
|
|
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.