The Problem
Example #479: Let us test whether the mean height of population 1 is 1 more than that of population 2. In symbols, this is:
H0 : μ1 − μ2 = 1
HA : μ1 − μ2 ≠ 1
To test this hypothesis, we collect data. The data from population 1 are:
34, 42, 61, 43, 55, 41, 48, 37, 55, 26, 27, 32, 36, 36, 45, 40, 41
The data from population 2 are:
31, 37, 31, 46, 54, 62, 38, 42, 26, 33, 52, 51, 65, 46, 28
In addition to these data, we also know one important thing: The data are generated from independent Normal processes; that is, the data in each sample come from independent Normal distributions. With this information, calculate the test statistic corresponding to the null hypothesis. Use the pooled variance.
Information given:
To summarize the above, the values of import are:
Summary statistics from the problem
\( \mu_d \)
| = |
1 |
| | |
\( \bar{x}_1 \)
| = |
41.1176 |
\( \bar{x}_2 \)
| = |
42.8 |
| | |
\( n_1 \)
| = |
17 |
\( n_2 \)
| = |
15 |
| | |
\( s_1 \)
| = |
9.616927 |
\( s_2 \)
| = |
12.225267 |
\( s_p \)
| = |
10.912019 |
Calculate these values yourself then hover your mouse over the grey spaces to see if you calculated them correctly.
Assistance
Hide Solution
First, let us calculate the pooled variance.
$$ \begin{align}
s_p^2 &= \frac{ \left(n_1-1\right)s_1^2 + \left(n_2-1\right)s_2^2\ }{ n_1 + n_2 - 2 } \\[1em]
&= \frac{ \left(17-1\right)9.616927^2 + \left(15-1\right)12.225267^2\ }{ 17 + 15 - 2 } \\[1em]
&= \frac{ \left(16\right)92.485294 + \left(14\right)149.457143\ }{ 30 } \\[1em]
&= 119.072157 \end{align} $$
And so, \( s_p = 10.912019 \). With that calculated, we thus have
$$ \begin{align}
t &= \frac{ \left(\bar{x}_1 - \bar{x}_2\right) - \mu_d}{ s_p \sqrt{ \frac{1}{n_1} + \frac{1}{n_2}} } \\[1em]
&= \frac{ \left(41.1176 - 42.8\right) - 1}{ 10.912019 \sqrt{ \frac{1}{17} + \frac{1}{15}} } \\[1em]
&= \frac{ -2.6824}{ 10.912019 \sqrt{ 0.12549} } \\[1em]
&= \frac{ -2.6824}{ 3.865539} \\[1em]
\end{align} $$
Thus, the test statistic for these data and this hypothesis is z = -0.6939.
Hide the R Code
Copy and paste the following code into your R script window, then run it from there.
samp1 = c(34, 42, 61, 43, 55, 41, 48, 37, 55, 26, 27, 32, 36, 36, 45, 40, 41)
samp2 = c(31, 37, 31, 46, 54, 62, 38, 42, 26, 33, 52, 51, 65, 46, 28)
t.test(samp1, samp2, mu=1, var.equal=TRUE)
In the R output, the test statistic is the number that follows “t =
” near the top. Note that R will give you test statistics that are more accurate and more precise than doing the calculations by hand. As such, these computer-calculated limits will differ slightly from those you calculate by hand.
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 sample1
ends up in A1
after pasting.
How to calculate the expected value in Excel.
sample1 | sample2 | | |
34 |
31 |
mu d: |
1 |
42 |
37 |
s1: |
=STDEV.S(A:A) |
61 |
31 |
s2: |
=STDEV.S(B:B) |
43 |
46 |
sp: |
=SQRT(((COUNT(A:A)-1)*D3^2+(COUNT(B:B)-1)*D4^2)/(COUNT(A:A)+COUNT(B:B)-2)) |
55 |
54 |
ts: |
=(AVERAGE(A:A)-AVERAGE(B:B)-D2)/D5/SQRT(1/COUNT(A:A)+1/COUNT(B:B)) |
41 |
62 |
|
|
48 |
38 |
|
|
37 |
42 |
|
|
55 |
26 |
|
|
26 |
33 |
|
|
27 |
52 |
|
|
32 |
51 |
|
|
36 |
65 |
|
|
36 |
46 |
|
|
45 |
28 |
|
|
40 |
|
|
|
41 |
|
|
|
The 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.