5.3 Confidence intervals on two normal populations
We assume now that we have two independent populations X1∼N(μ1,σ21) and X2∼N(μ2,σ22) from which two respective srs’s (X11,…,X1n1) and (X21,…,X2n2) of sizes n1 and n2 are extracted. As in Section 5.2, the confidence intervals derived in this section arise from the sampling distributions obtained in Section 2.2 for normal populations.
5.3.1 Confidence interval for the difference of means with known variances
Assume that the mean populations μ1 and μ2 are unknown and the variances σ21 and σ22 are known. We wish to construct a confidence interval for the difference θ=μ1−μ2.
For that, we consider an estimator of θ. An unbiased estimator is
ˆθ=ˉX1−ˉX2.
Since ˆθ is a linear combination of normal rv’s, then it is normally distributed. Its mean is easily computed as
E[ˆθ]=E[ˉX1]−E[ˉX2]=μ1−μ2.
Thanks to the independence between X1 and X2, the variance is68
Var[ˆθ]=Var[ˉX1]+Var[ˉX2]=σ21n1+σ22n2.
Then, a possible pivot is
Z:=ˉX1−ˉX2−(μ1−μ2)√σ21n1+σ22n2∼N(0,1).
Again, if we split evenly the significance level α between the two tails, then we look for constants c1 and c2 such that
P(c1≤Z≤c2)=1−α,
that is, c1=−zα/2 and c2=zα/2. Solving for μ1−μ2, we obtain
1−α=P(−zα/2≤ˉX1−ˉX2−(μ1−μ2)√σ21n1+σ22n2≤zα/2)=P(−zα/2√σ21n1+σ22n2≤ˉX1−ˉX2−(μ1−μ2)≤zα/2√σ21n1+σ22n2)=P(−(ˉX1−ˉX2)−zα/2√σ21n1+σ22n2≤−(μ1−μ2)≤−(ˉX1−ˉX2)+zα/2√σ21n1+σ22n2)=P(ˉX1−ˉX2−zα/2√σ21n1+σ22n2≤μ1−μ2≤ˉX1−ˉX2+zα/2√σ21n1+σ22n2).
Therefore, a confidence interval for μ1−μ2 at the confidence level 1−α is
CI1−α(μ1−μ2)=[ˉX1−ˉX2∓zα/2√σ21n1+σ22n2].
Example 5.5 A new training method for an assembly operation is being tested at a factory. For that purpose, two groups of nine employees were trained during three weeks. One group was trained with the usual procedure and the other with the new method. The assembly time (in minutes) that each employee required after the training period is collected in the table below. Assuming that the assembly times are normally distributed with both variances equal to 22 minutes, obtain a confidence interval at significance level 0.05 for the difference of average assembly times for the two kinds of training.
Procedure | Measurements |
---|---|
Standard | 323735284144353134 |
New | 353129253440273231 |
The average assembly times of the two groups are
ˉX1≈35.22,ˉX2≈31.56.
Then, a confidence interval for μ1−μ2 at the 0.95 confidence level is
CI0.95(μ1−μ2)≈[(35.22−31.56)∓1.96×4.69√1/9+1/9]≈[3.66∓4.33]=[−0.67,7.99].
In R:
# Samples
X_1 <- c(32, 37, 35, 28, 41, 44, 35, 31, 34)
X_2 <- c(35, 31, 29, 25, 34, 40, 27, 32, 31)
# n1, n2, Xbar1, Xbar2, sigma2_1, sigma2_2, alpha, z_{alpha/2}
n_1 <- length(X_1)
n_2 <- length(X_2)
X_bar_1 <- mean(X_1)
X_bar_2 <- mean(X_2)
sigma2_1 <- sigma2_2 <- 22
alpha <- 0.05
z <- qnorm(alpha / 2, lower.tail = FALSE)
# CI
(X_bar_1 - X_bar_2) + c(-1, 1) * z * sqrt(sigma2_1 / n_1 + sigma2_2 / n_2)
## [1] -0.6669768 8.0003101
5.3.2 Confidence interval for the difference of means, with unknown and equal variances
Assume that we are in the situation of the previous section but now both variances σ21 and σ22 are equal and unknown, that is, σ21=σ22=σ2 with σ2 unknown.
We want to construct a confidence interval for θ=μ1−μ2. As in the previous section, an unbiased estimator is
ˆθ=ˆμ1−ˆμ2=ˉX1−ˉX2
whose distribution is
ˆθ∼N(μ1−μ2,σ2(1n1+1n2)).
However, since σ2 is unknown, then
Z=ˉX1−ˉX2−(μ1−μ2)√σ2(1n1+1n2)∼N(0,1)
is not a pivot. We need to estimate in the first place σ2.
For that, we know that
(n1−1)S′21σ2∼χ2n1−1,(n2−1)S′22σ2∼χ2n2−1.
Besides, the two samples are independent, so by the additivity property of the χ2 distribution we know that
(n1−1)S′21σ2+(n2−1)S′22σ2∼χ2n1+n2−2.
Taking expectations, we have
E[(n1−1)S′21σ2+(n2−1)S′22σ2]=1σ2E[(n1−1)S′21+(n2−1)S′22]=n1+n2−2.
Solving for σ2, we obtain
E[(n1−1)S′21+(n2−1)S′22]=σ2(n1+n2−2).
From here we can easily deduce an unbiased estimator for σ2:
ˆσ2=(n1−1)S′21+(n2−1)S′22n1+n2−2=:S2.
Note that ˆσ2 is just a pooled sample quasivariance stemming from the two sample quasivariances. The weights of each quasivariance are relative to the sample sizes. In addition, we know the distribution of ˆσ2, since
(n1+n2−2)S2σ2=(n1−1)S′21+(n2−1)S′22σ2∼χ2n1+n2−2.
If we replace σ2 in (5.5) with S2 and we apply Theorem 2.3, we obtain the probability distribution
T=ˉX1−ˉX2−(μ1−μ2)√S2(1n1+1n2)=ˉX1−ˉX2−(μ1−μ2)√σ2(1n1+1n2)√(n1+n2−2)S2σ2/(n1+n2−2)d=N(0,1)√χ2n1+n2−2/(n1+n2−2)=tn1+n2−2.
Then, solving μ1−μ2 within the following probability we find a confidence interval for μ1−μ2:
1−α=P(−tn1+n2−2;α/2≤ˉX1−ˉX2−(μ1−μ2)√S2(1n1+1n2)≤tn1+n2−2;α/2)=P(−tn1+n2−2;α/2S√1n1+1n2≤ˉX1−ˉX2−(μ1−μ2)≤tn1+n2−2;α/2S√1n1+1n2)=P(ˉX1−ˉX2−tn1+n2−2;α/2S√1n1+1n2≤μ1−μ2≤ˉX1−ˉX2+tn1+n2−2;α/2S√1n1+1n2).
Therefore, a confidence interval for μ1−μ2, At confidence level 1−α is
CI1−α(μ1−μ2)=[ˉX1−ˉX2∓tn1+n2−2;α/2S√1n1+1n2].
Example 5.6 Compute the same interval asked in Example 5.5, but now assuming that the assembly variances are unknown and equal for the two training methods.
The sample quasivariances for each of the methods are
S′21=195.56/8=24.445,S′22=160.22/8=20.027.
Therefore, the pooled estimated variance is
S2=8×24.445+8×20.0279+9−2≈22.24,
and the standard deviation is S≈4.71. Then, a confidence interval at confidence level 0.95 for the difference of average times is
CI0.95(μ1−μ2)≈[(35.22−31.56)∓t16;0.0254.71√1/9+1/9]≈[3.66∓4.71]=[−1.05,8.37].
In R:
# Samples
X_1 <- c(32, 37, 35, 28, 41, 44, 35, 31, 34)
X_2 <- c(35, 31, 29, 25, 34, 40, 27, 32, 31)
# n1, n2, Xbar1, Xbar2, S^2, alpha, t_{alpha/2;n1-n2-2}
n_1 <- length(X_1)
n_2 <- length(X_2)
X_bar_1 <- mean(X_1)
X_bar_2 <- mean(X_2)
S2_prime_1 <- var(X_1)
S2_prime_2 <- var(X_2)
S <- sqrt(((n_1 - 1) * S2_prime_1 + (n_2 - 1) * S2_prime_2) / (n_1 + n_2 - 2))
alpha <- 0.05
t <- qt(alpha / 2, df = n_1 + n_2 - 2, lower.tail = FALSE)
# CI
(X_bar_1 - X_bar_2) + c(-1, 1) * t * S * sqrt(1 / n_1 + 1 / n_2)
## [1] -1.045706 8.379039
5.3.3 Confidence interval for the ratio of variances
Assume that neither the mean nor the variances are known. We wish to construct a confidence interval for the ratio of variances, θ=σ21/σ22.
In order to find a pivot, we need to consider an estimator for θ. We know that S′21 and S′22 are unbiased estimators for σ21 and σ22, respectively. Also, since both srs’s are independent, then so are S′21 and S′22. In addition, by Theorem 2.2, we know that
(n1−1)S′21σ21∼χ2n1−1,(n2−1)S′22σ22∼χ2n2−1.
A possible estimator for θ is ˆθ=S′21/S′22, but its distribution is not completely known, since it depends on σ21 and σ22. However, we do know the distribution of
F=S′21/σ21S′22/σ22=(n1−1)S′21σ21/(n1−1)(n2−1)S′22σ22/(n2−1)∼χ2n1−1/(n1−1)χ2n2−1/(n2−1)d=Fn1−1,n2−1.
Therefore, F is a pivot. Splitting evenly the probability α between both tails of the Fn1−1,n2−1 distribution, and solving for θ we get
1−α=P(Fn1−1,n2−1;1−α/2≤S′21/S′22σ21/σ22≤Fn1−1,n2−1;α/2)=P(S′22S′21Fn1−1,n2−1;1−α/2≤1σ21/σ22≤S′22S′21Fn1−1,n2−1;α/2)=P(S′21/S′22Fn1−1,n2−1;α/2≤σ21σ22≤S′21/S′22Fn1−1,n2−1;1−α/2).
![Representation of the probability \(\mathbb{P}(\mathcal{F}_{n_1-1,n_2-1;1-\alpha/2}\leq \mathcal{F}_{n_1-1,n_2-1}\leq \mathcal{F}_{n_1-1,n_2-1;\alpha/2})=1-\alpha\) (in green) and its complementary (in orange) for \(\alpha=0.10\) and \(n_1=n_2=10\).](inference_files/figure-html/ci-falpha-1.png)
Figure 5.6: Representation of the probability P(Fn1−1,n2−1;1−α/2≤Fn1−1,n2−1≤Fn1−1,n2−1;α/2)=1−α (in green) and its complementary (in orange) for α=0.10 and n1=n2=10.
Then, a confidence interval for θ=σ21/σ22 is
CI1−α(σ21/σ22)=[S′21/S′22Fn1−1,n2−1;α/2,S′21/S′22Fn1−1,n2−1;1−α/2].
Remark. When using the tabulated probabilities for the Snedecor’s F distribution, usually the critical values of the distribution are only available for small probabilities α. However, a useful fact is that if F∼Fν1,ν2, then F′=1/F∼Fν2,ν1. Therefore, if Fν1,ν2;α is the critical value α of Fν1,ν2, then
P(Fν1,ν2>Fν1,ν2;α)=α⟺P(Fν2,ν1<1/Fν1,ν2;α)=α⟺P(Fν2,ν1>1/Fν1,ν2;α)=1−α.
This means that
Fν2,ν1;1−α=1/Fν1,ν2;α.
Obtaining the critical values for the F distribution can be easily done with the function qf()
, as illustrated in Example 2.12.
Example 5.7 Two learning methods are applied for teaching children in the school how to read. The results of both methods were compared in a reading test at the end of the learning period. The resulting means and quasivariances of the tests are collected in the table below. Assuming that the results have a normal distribution, we want to obtain a confidence interval with confidence level 0.95 for the mean difference.
Statistic | Method 1 | Method 2 |
---|---|---|
ni | 11 | 14 |
ˉXi | 64 | 69 |
S′2i | 52 | 71 |
In the first place we have to verify if the two unknown variances are equal to see if we can apply the confidence intervals seen in Section 5.3.2. For that, we compute the confidence interval for the ratio of variances, and if that confidence interval contains the one, then this would indicate that there is no evidence against the assumption of equal variances. If that was the case, we can construct the confidence interval given in Section 5.3.2.69
The sample quasivariances are
S′21=52,S′22=71.
Then, since F10,13;0.975=1/F13,10;0.025, the confidence interval at 0.95 for the ratio of variances is
[52/71F10,13;0.025,52/71F10,13;0.975]≈[0.733.25,0.731/3.58]≈[0.22,2.61].
In R, the confidence interval for the ratio of variances can be computed as:
# n1, n2, S1'^2, S2'^2, alpha, c1, c2
n_1 <- 11
n_2 <- 14
S2_prime_1 <- 52
S2_prime_2 <- 71
alpha <- 0.05
c1 <- qf(1 - alpha / 2, df1 = n_1 - 1, df2 = n_2 - 1, lower.tail = FALSE)
c2 <- qf(alpha / 2, df1 = n_1 - 1, df2 = n_2 - 1, lower.tail = FALSE)
# CI
(S2_prime_1 / S2_prime_2) / c(c2, c1)
## [1] 0.2253751 2.6243088
The value one is inside the confidence interval, so the confidence interval does not provide any evidence against the hypothesis of the equality of variances. Therefore, we can use the confidence interval for unknown and equal variances.
The estimated variance is
S2=10×52+13×7111+14−2≈62.74.
Since the critical value is t23;0.025≈2.069, the interval is
CI0.95(μ1−μ2)=[(64−69)∓t23;0.025S√111+114]≈[−11.6,1.6].
In R:
# Xbar1, Xbar2, S^2, t_{alpha/2;n1-n2-2}
X_bar_1 <- 64
X_bar_2 <- 69
S2 <- ((n_1 - 1) * S2_prime_1 + (n_2 - 1) * S2_prime_2) / (n_1 + n_2 - 2)
t <- qt(1 - alpha / 2, df = n_1 + n_2 - 2, lower.tail = TRUE)
# CI
(X_bar_1 - X_bar_2) + c(-1, 1) * t * sqrt(S2 * (1 / n_1 + 1 / n_2))
## [1] -11.601878 1.601878
This reasoning is not fully rigorous. Using confidence intervals in a chained way may result in a confidence level that is not the nominal one. A more rigorous approach is possible with a confidence interval for μ1−μ2 with σ21≠σ22 unknown, but it is beyond the scope of this course.↩︎