The Problem
Example #193: 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:
33, 34, 29, 37, 32, 37, 41, 34, 42, 39, 39, 37, 42, 39, 34, 33
The data from population 2 are:
29, 29, 56, 40, 39, 21, 21, 64, 35, 23, 44, 21, 33, 34
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 90% 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 \)
| = |
36.375 |
\( \bar{x}_2 \)
| = |
34.9286 |
| | |
\( n_1 \)
| = |
16 |
\( n_2 \)
| = |
14 |
| | |
\( s_1 \)
| = |
3.827532 |
\( s_2 \)
| = |
13.047041 |
\( s_p \)
| = |
9.321018 |
| | |
\( \alpha \)
| = |
0.1 |
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 90% confidence: (-4.3559, 7.2488). 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]
&= (36.375 - 34.9286) \pm t(0.1/2, 28)\ 9.321018\ \sqrt{\ \frac{1}{16} + \frac{1}{14}\ } \\[1em]
&= (1.4464) \pm 1.701 \times 9.321018\ \sqrt{\ \left( 0.0625\right) + \left(0.071429\right)\ } \\[1em]
&= (1.4464) \pm 1.701 \times 9.321018\ \left( 0.365963\right)\ \\[1em]
&= (1.4464) \pm 5.802355 \\[1em]
\end{align} $$
Thus, we are 90% confident that the mean height for the population is between -4.3559 and 7.2488.
Note that the value following the plus/minus sign ± is known as the margin of error, \( E = 5.8024 \), 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(33, 34, 29, 37, 32, 37, 41, 34, 42, 39, 39, 37, 42, 39, 34, 33)
samp2 = c(29, 29, 56, 40, 39, 21, 21, 64, 35, 23, 44, 21, 33, 34)
t.test(samp1, samp2, conf.level=0.9, var.equal=TRUE)
In the R output, the confidence limits are the numbers below the line “90 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 | | |
33 |
29 |
s1: |
=STDEV.S(A:A) |
34 |
29 |
s2: |
=STDEV.S(B:B) |
29 |
56 |
sp: |
=SQRT(((COUNT(A:A)-1)*D2^2+(COUNT(B:B)-1)*D3^2)/(COUNT(A:A)+COUNT(B:B)-2)) |
37 |
40 |
|
|
32 |
39 |
lower: |
=AVERAGE(A:A)-AVERAGE(B:B)-ABS(T.INV((1-0.9)/2,COUNT(A:A)+COUNT(B:B)-2))*D4*SQRT(1/COUNT(A:A)+1/COUNT(B:B)) |
37 |
21 |
upper: |
=AVERAGE(A:A)-AVERAGE(B:B)+ABS(T.INV((1-0.9)/2,COUNT(A:A)+COUNT(B:B)-2))*D4*SQRT(1/COUNT(A:A)+1/COUNT(B:B)) |
41 |
21 |
|
|
34 |
64 |
|
|
42 |
35 |
|
|
39 |
23 |
|
|
39 |
44 |
|
|
37 |
21 |
|
|
42 |
33 |
|
|
39 |
34 |
|
|
34 |
|
|
|
33 |
|
|
|
The endpoints of the 90% 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.