5.3 Confidence intervals on two normal populations

We assume now that we have two independent populations X1N(μ1,σ21) and X2N(μ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+σ22n2N(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(c1Zc2)=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+σ22n2zα/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ˉX2zα/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ˉX2zα/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

ˉX135.22,ˉX231.56.

Then, a confidence interval for μ1μ2 at the 0.95 confidence level is

CI0.95(μ1μ2)[(35.2231.56)1.96×4.691/9+1/9][3.664.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

(n11)S21σ2χ2n11,(n21)S22σ2χ2n21.

Besides, the two samples are independent, so by the additivity property of the χ2 distribution we know that

(n11)S21σ2+(n21)S22σ2χ2n1+n22.

Taking expectations, we have

E[(n11)S21σ2+(n21)S22σ2]=1σ2E[(n11)S21+(n21)S22]=n1+n22.

Solving for σ2, we obtain

E[(n11)S21+(n21)S22]=σ2(n1+n22).

From here we can easily deduce an unbiased estimator for σ2:

ˆσ2=(n11)S21+(n21)S22n1+n22=: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+n22)S2σ2=(n11)S21+(n21)S22σ2χ2n1+n22.

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+n22)S2σ2/(n1+n22)d=N(0,1)χ2n1+n22/(n1+n22)=tn1+n22.

Then, solving μ1μ2 within the following probability we find a confidence interval for μ1μ2:

1α=P(tn1+n22;α/2ˉX1ˉX2(μ1μ2)S2(1n1+1n2)tn1+n22;α/2)=P(tn1+n22;α/2S1n1+1n2ˉX1ˉX2(μ1μ2)tn1+n22;α/2S1n1+1n2)=P(ˉX1ˉX2tn1+n22;α/2S1n1+1n2μ1μ2ˉX1ˉX2+tn1+n22;α/2S1n1+1n2).

Therefore, a confidence interval for μ1μ2, At confidence level 1α is

CI1α(μ1μ2)=[ˉX1ˉX2tn1+n22;α/2S1n1+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

S21=195.56/8=24.445,S22=160.22/8=20.027.

Therefore, the pooled estimated variance is

S2=8×24.445+8×20.0279+9222.24,

and the standard deviation is S4.71. Then, a confidence interval at confidence level 0.95 for the difference of average times is

CI0.95(μ1μ2)[(35.2231.56)t16;0.0254.711/9+1/9][3.664.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 S21 and S22 are unbiased estimators for σ21 and σ22, respectively. Also, since both srs’s are independent, then so are S21 and S22. In addition, by Theorem 2.2, we know that

(n11)S21σ21χ2n11,(n21)S22σ22χ2n21.

A possible estimator for θ is ˆθ=S21/S22, but its distribution is not completely known, since it depends on σ21 and σ22. However, we do know the distribution of

F=S21/σ21S22/σ22=(n11)S21σ21/(n11)(n21)S22σ22/(n21)χ2n11/(n11)χ2n21/(n21)d=Fn11,n21.

Therefore, F is a pivot. Splitting evenly the probability α between both tails of the Fn11,n21 distribution, and solving for θ we get

1α=P(Fn11,n21;1α/2S21/S22σ21/σ22Fn11,n21;α/2)=P(S22S21Fn11,n21;1α/21σ21/σ22S22S21Fn11,n21;α/2)=P(S21/S22Fn11,n21;α/2σ21σ22S21/S22Fn11,n21;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\).

Figure 5.6: Representation of the probability P(Fn11,n21;1α/2Fn11,n21Fn11,n21;α/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)=[S21/S22Fn11,n21;α/2,S21/S22Fn11,n21;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 FFν1,ν2, then F=1/FFν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
S2i 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

S21=52,S22=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+14262.74.

Since the critical value is t23;0.0252.069, the interval is

CI0.95(μ1μ2)=[(6469)t23;0.025S111+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

  1. This is a particular case of Proposition 1.11.↩︎

  2. 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.↩︎