# Finding a confidence interval with two samples

Let $$X_1, X_2, \ldots, X_{n_1}$$ and $$Y_1, Y_2, \ldots, Y_{n_2}$$ be two different independent i.i.d. samples from $$N(\mu_1, \sigma^2)$$ and $$N(\mu_2, \sigma^2)$$, respectively. Note the variances are the same. How can I find a $$100(1 - \alpha)\%$$ confidence interval for $$4\mu_1 - 3\mu_2$$?

I know the following derivation for a confidence interval for difference of means (however, the variables not necessarily have to be normal).

If we have variables $$X$$ and $$Y$$, and we define $$\overline{X} = n_1^{-1} \sum_{i = 1}^{n_1} X_i$$ and $$\overline{Y} = n_2^{-1} \sum_{i = 1}^{n_2} Y_i$$ to be rthe sample means, then $$\hat{\Delta} = \overline{X} - \overline{Y}$$ is an unbiased estimator for $$\Delta = \mu_1 - \mu_2$$. Furthermore, by the independence of the samples, we have $$\text{Var}(\hat{\Delta}) = \frac{\sigma^2}{n_1} + \frac{\sigma^2}{n_2}$$ assuming the variances are the same.

Now if we define $$S_1^2 = (n_1 - 1)^{-1} \sum_{i = 1}^{n_1} (X_i - \overline{X})^2$$ and $$S_2^2 = (n_2 - 1)^{-1} \sum_{i = 1}^{n_2} (Y_i - \overline{Y})^{2}$$ to be the sample variances, we can estimate the variances by the sample variances and consider the random variable $$Z = (\hat{\Delta} - \Delta)/\left(\sqrt{\frac{S_1^2}{n_1} + \frac{S_2^2}{n_2}}\right)$$, which follows a $$N(0, 1)$$ distribution due to the Central Limit Theorem. This leads to a $$(1 - \alpha)100\%$$ confidence interval for $$\Delta = \mu_1 - \mu_2$$ given by

$$\left((\overline{x} - \overline{y} - z_{\alpha/2}\sqrt{\frac{s_1^2}{n_1} + \frac{s_2^2}{n_2}}, (\overline{x} - \overline{y}) \right) + z_{\alpha/2}\sqrt{\frac{s_1^2}{n_1} + \frac{s_2^2}{n_2}},$$

where the quantity $$\sqrt{\frac{s_1^2}{n_1} + \frac{s_2^2}{n_2}}$$ represents the standard error of $$\overline{X} - \overline{Y}$$.

However, I'm struggling to extend this to find a confidence interval for $$4\mu_1 - 3\mu_2$$ specifically when the samples come from normal distributions with a common sample variance. Can someone please help me approach this problem? Note that I would like to actually derive the interval myself and not just use R or some other software.

• Do you know the Delta method? Commented Mar 28, 2021 at 20:09
• Yes, I am aware of the Delta method, but I'm not sure how it can be applied here?
– user295786
Commented Mar 28, 2021 at 20:20
• You don't need the delta method for this: you can directly (and easily) compute the distribution of the estimator $4\bar X - 3\bar Y.$
– whuber
Commented Mar 28, 2021 at 20:34

You could estimate $$4\mu_1 - 3\mu_2$$ by $$\hat \Delta =4\bar X_1 - 3\bar X_2).$$ Then $$E(\hat\Delta) = E(4\bar X_1 - 3\bar X_2) = 4\mu_1 - 3\mu_2,$$ $$Var(\hat\Delta) = Var(4\bar X_1 - 3\bar X_2) = 16\frac{\sigma_1^2}{n_1} + 9\frac{\sigma_2^2}{n_2},$$ and $$SD(\hat\Delta) = \sqrt{16\frac{\sigma_1^2}{n_1} + 9\frac{\sigma_2^2}{n_2}} = \sigma\sqrt{\frac{16}{n_1}+\frac{9}{n_2}},$$ because the two variances are the same. In a balanced design with $$n = n_1 = n_2,$$
$$SD(\hat\Delta) = 5\sigma/\sqrt{n}.$$

You might estimate $$\sigma$$ by $$\hat\sigma_p = \sqrt{\frac{(n_1-1)S_1^2+(n_2 - 1)S_1^2}{n_1+n_2-2}},$$ or in the balanced case, $$\hat\sigma_p =\sqrt{(S_1^2 + S_2^2)/2}.$$

Thus a 95% confidence interval for $$\Delta$$ would be of the form $$\hat\Delta \pm t^*\left[\widehat{SD}(\hat\Delta)\right],$$ where $$t^*$$ cuts probability $$0.025$$ from the upper tail of $$\mathsf{T}(\nu =n_1+n_2-2),$$ Student's t distribution with degrees of freedom $$\nu = n_1+n_2-2,$$ and $$\widehat{SD}(\hat\Delta)$$ is the estimated standard error of $$\hat\Delta.$$

Simulation in R with $$n_1 = n_2 = 16, \sigma=3, \mu_1 = 50, \mu_2 = 53,$$ illustrates normal distribution of $$\Delta.$$

n = 16; sg=3
set.seed(1234)
Dlt.est = replicate(10^6, 4*mean(rnorm(n,50,sg))
-3*mean(rnorm(n,53,sg)))
mean(Dlt.est)
[1] 40.99765    # aprx 41
4*50-3*53
[1] 41          # exact
var(Dlt.est)
[1] 14.08624
sd(Dlt.est)
[1] 3.753164   # aprx 3.75
5*sg/sqrt(16)
[1] 3.75       # exact

hist(Dlt.est, prob=T, br=30, col="skyblue2")
curve(dnorm(x, 41, 3.75), add=T, col="orange", lwd=2)


• How did you get the expression for $\hat{\sigma_p}?$ And would $\overline{SD}(\hat{\Delta})$ just be equal to $\hat{\sigma_p}$ here?
– user295786
Commented Mar 28, 2021 at 22:29
• I got $\hat \sigma_p$ as the square root of of the "pooled variance" $\hat \sigma_p^2.$ In the balanced case $\sigma_p^2$ is just the average of the two sample variances $S_1^2$ and $S_2^2.$ If sample sizes are unequal, the slightly messier formula gives greater weight to the larger sample in estimating the common variance $\sigma^2.$ // The answer to your second question is NO. The estimate of $SD(\hat \Delta)$ needs to take into account how $\Delta$ is defined in terms of the two samples (with coefficients 4 and 3, instead of just the usual difference). Commented Mar 28, 2021 at 22:55
• Thank you. How can I compute $\overline{SD}(\hat{\Delta})$?
– user295786
Commented Mar 28, 2021 at 23:01
• System went down to be maintained as I was answering your comment and fixing an (unrelated) typo in my answer. I think I have restored everything, but ask again if unclear. Commented Mar 28, 2021 at 23:03
• I gave the formula for the standard error $SD(\hat\Delta)$ in terms of $\sigma.$ Then you get the estimated standard error $\widehat{SD}(\hat\Delta)$ by plugging in $\hat\sigma_p$ for $\sigma.$ Commented Mar 28, 2021 at 23:07