The Problem
Example #73: Let us test whether the mean height of population 1 is the same as that of population 2. In symbols, this is:
H0 : μ1 − μ2 = 0
HA : μ1 − μ2 ≠ 0
To test this hypothesis, we collect data. The data from population 1 are:
35, 37, 44, 28, 48, 31, 37, 41, 54, 36, 37, 44, 35, 48
The data from population 2 are:
34, 48, 44, 31, 42, 43, 40, 42, 18, 49, 49, 45
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 \)
| = |
0 |
| | |
\( \bar{x}_1 \)
| = |
39.6429 |
\( \bar{x}_2 \)
| = |
40.4167 |
| | |
\( n_1 \)
| = |
14 |
\( n_2 \)
| = |
12 |
| | |
\( s_1 \)
| = |
7.196229 |
\( s_2 \)
| = |
8.959082 |
\( s_p \)
| = |
8.052254 |
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(14-1\right)7.196229^2 + \left(12-1\right)8.959082^2\ }{ 14 + 12 - 2 } \\[1em]
&= \frac{ \left(13\right)51.785714 + \left(11\right)80.265152\ }{ 24 } \\[1em]
&= 64.83879 \end{align} $$
And so, \( s_p = 8.052254 \). 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(39.6429 - 40.4167\right) - 0}{ 8.052254 \sqrt{ \frac{1}{14} + \frac{1}{12}} } \\[1em]
&= \frac{ -0.7738}{ 8.052254 \sqrt{ 0.154762} } \\[1em]
&= \frac{ -0.7738}{ 3.16774} \\[1em]
\end{align} $$
Thus, the test statistic for these data and this hypothesis is z = -0.2443.
Hide the R Code
Copy and paste the following code into your R script window, then run it from there.
samp1 = c(35, 37, 44, 28, 48, 31, 37, 41, 54, 36, 37, 44, 35, 48)
samp2 = c(34, 48, 44, 31, 42, 43, 40, 42, 18, 49, 49, 45)
t.test(samp1, samp2, mu=0, 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 | | |
35 |
34 |
mu d: |
0 |
37 |
48 |
s1: |
=STDEV.S(A:A) |
44 |
44 |
s2: |
=STDEV.S(B:B) |
28 |
31 |
sp: |
=SQRT(((COUNT(A:A)-1)*D3^2+(COUNT(B:B)-1)*D4^2)/(COUNT(A:A)+COUNT(B:B)-2)) |
48 |
42 |
ts: |
=(AVERAGE(A:A)-AVERAGE(B:B)-D2)/D5/SQRT(1/COUNT(A:A)+1/COUNT(B:B)) |
31 |
43 |
|
|
37 |
40 |
|
|
41 |
42 |
|
|
54 |
18 |
|
|
36 |
49 |
|
|
37 |
49 |
|
|
44 |
45 |
|
|
35 |
|
|
|
48 |
|
|
|
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.