The Problem
Example #52: Let us test the null hypothesis that the mean height of a population is 3 cm. In symbols, this is:
H0 : μ = 3 cm
To test this hypothesis, we collect data. These data are the heights of a sample from this population. The sample values are:
9, -1, 8, -2, 1, 2, -15, 1, 21, 4, 36, 6, -3, -15, -23, 3, 12, 12, -27, 0, 28
In addition to these data, we also know that the data are generated from a Normal process (they come from a Normally distributed population). With this information, calculate the test statistic corresponding to the null hypothesis.
Information given:
To summarize the above, the values of import are:
Summary statistics from the problem
\( \mu_0 \)
| = |
3 |
\( \bar{x} \)
| = |
2.7143 |
\( s \)
| = |
15.146428 |
\( n \)
| = |
21 |
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 t = -0.0864. 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}
t &= \frac{ \bar{x} - \mu_0}{s}\ \sqrt{\phantom{I}n\phantom{^-}} \\[1em]
&= \frac{ 2.7143 - 3}{ 15.146428}\ \sqrt{\phantom{I}21\phantom{^-}} \\[1em]
&= \frac{ -0.2857}{ 15.146428}\ \times\ 4.5826 \\
\end{align} $$
Thus, the t test statistic for these data and this hypothesis is -0.0864.
Hide the R Code
The following code makes use of R’s built-in t-test function. Copy and paste the following code into your R script window, then run it from there.
sample = c(9, -1, 8, -2, 1, 2, -15, 1, 21, 4, 36, 6, -3, -15, -23, 3, 12, 12, -27, 0, 28)
t.test(sample, mu=3)
The test statistic follows “t =
” near the top of the output. Note that this function also calculates the number of degrees of freedom for you. It is the number following “df =
” near the top.
Hide the Excel Code
The z-procedures are sensitive to knowing the population variance. Logic dictates that if we do not know the population mean, then we will not know the population variance. As such, the z-procedures are rarely used now. As such, there is no z-test in the base Excel program.
Copy and paste the following code into your Excel spreadsheet window, making sure the value sample
ends up in A1
after pasting.
How to calculate the test statistic in Excel.
sample | | |
9 |
mu0: |
3 |
-1 |
s: |
=STDEV.S(A:A) |
8 |
ts: |
=(AVERAGE(A:A)-C2)/C3*SQRT(COUNT(A:A)) |
-2 |
|
|
1 |
|
|
2 |
|
|
-15 |
|
|
1 |
|
|
21 |
|
|
4 |
|
|
36 |
|
|
6 |
|
|
-3 |
|
|
-15 |
|
|
-23 |
|
|
3 |
|
|
12 |
|
|
12 |
|
|
-27 |
|
|
0 |
|
|
28 |
|
|
The t test statistic is the number calculated in cell C4.
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.