The Problem
Example #182: Let us estimate the difference in means between two populations using a confidence interval to indicate our uncertainty. To do this, we collect data from each of the two populations. The data from population 1 are:
41, 34, 27, 65, 61, 47, 58, 51, 27, 46, 45, 54, 48, 47, 23, 56, 38, 40
The data from population 2 are:
45, 47, 41, 34, 60, 55, 46, 52, 51, 45, 50, 45, 45, 58, 53, 53, 25, 30, 56
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 endpoints of the symmetric 98% confidence interval. Use the pooled variance.
Information given:
To summarize the above, the values of import are:
Summary statistics from the problem
\( \bar{x}_1 \)
| = |
44.8889 |
\( \bar{x}_2 \)
| = |
46.8947 |
| | |
\( n_1 \)
| = |
18 |
\( n_2 \)
| = |
19 |
| | |
\( s_1 \)
| = |
11.940484 |
\( s_2 \)
| = |
9.284962 |
\( s_p \)
| = |
10.65775 |
| | |
\( \alpha \)
| = |
0.02 |
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 endpoints to the 98% confidence: (-10.5523, 6.5406). 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}
\text{Both confidence limits:} &= (\bar{x}_1 - \bar{x}_2) \pm t(\alpha/2, \nu)\ s_p\ \sqrt{\ \frac{1}{n_1} + \frac{1}{n_2}\ } \\[1em]
&= (44.8889 - 46.8947) \pm t(0.02/2, 35)\ 10.65775\ \sqrt{\ \frac{1}{18} + \frac{1}{19}\ } \\[1em]
&= (-2.0058) \pm 2.438 \times 10.65775\ \sqrt{\ \left( 0.055556\right) + \left(0.052632\right)\ } \\[1em]
&= (-2.0058) \pm 2.438 \times 10.65775\ \left( 0.328918\right)\ \\[1em]
&= (-2.0058) \pm 8.546475 \\[1em]
\end{align} $$
Thus, we are 98% confident that the mean height for the population is between -10.5523 and 6.5406.
Note that the value following the plus/minus sign ± is known as the margin of error, \( E = 8.5465 \), and is always half of the width of the confidence interval. The margin of error is affected by the sample size, the level of confidence, and the variability of the population. If n increases, the margin of error shrinks. If the level of confidence increases, the margin of error expands. If the variability in the population increases, the margin of error expands.
Hide the R Code
Copy and paste the following code into your R script window, then run it from there.
samp1 = c(41, 34, 27, 65, 61, 47, 58, 51, 27, 46, 45, 54, 48, 47, 23, 56, 38, 40)
samp2 = c(45, 47, 41, 34, 60, 55, 46, 52, 51, 45, 50, 45, 45, 58, 53, 53, 25, 30, 56)
t.test(samp1, samp2, conf.level=0.98, var.equal=TRUE)
In the R output, the confidence limits are the numbers below the line “98 percent confidence interval:
.” Note that R will give you confidence intervals 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 | | |
41 |
45 |
s1: |
=STDEV.S(A:A) |
34 |
47 |
s2: |
=STDEV.S(B:B) |
27 |
41 |
sp: |
=SQRT(((COUNT(A:A)-1)*D2^2+(COUNT(B:B)-1)*D3^2)/(COUNT(A:A)+COUNT(B:B)-2)) |
65 |
34 |
|
|
61 |
60 |
lower: |
=AVERAGE(A:A)-AVERAGE(B:B)-ABS(T.INV((1-0.98)/2,COUNT(A:A)+COUNT(B:B)-2))*D4*SQRT(1/COUNT(A:A)+1/COUNT(B:B)) |
47 |
55 |
upper: |
=AVERAGE(A:A)-AVERAGE(B:B)+ABS(T.INV((1-0.98)/2,COUNT(A:A)+COUNT(B:B)-2))*D4*SQRT(1/COUNT(A:A)+1/COUNT(B:B)) |
58 |
46 |
|
|
51 |
52 |
|
|
27 |
51 |
|
|
46 |
45 |
|
|
45 |
50 |
|
|
54 |
45 |
|
|
48 |
45 |
|
|
47 |
58 |
|
|
23 |
53 |
|
|
56 |
53 |
|
|
38 |
25 |
|
|
40 |
30 |
|
|
|
56 |
|
|
The endpoints of the 98% confidence interval are given in cells D6 and D7. 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.