# Is my work correct? (Easy problem, confidence intervals)

The r.v. $X$ represents the time taken by a computer in company $1$ in order to perform a certain job, and $Y$ represents the same thing but for company $2$. A sample of $n_X = 12$ computers are taken from company $1$, and we obtain: $\bar x = 65$, $s_X ^2 = 279$. A sample of $n_Y = 8$ computers are taken from company $2$ and we get $\bar y = 48$, $s_Y ^2 = 224$.

I am required to find a $.95$ confidence interval for the difference between the means of the two populations.

What I did:

Because $\bar x > \bar y$ let's find the C.I for the difference $\mu_X - \mu_Y$. To do this, we note that:

The variances are unknown, and $n_X + n_Y - 2 = 18 \le 30$ is small. Then, we must consider:

$$T = \frac{(\bar X - \bar Y) - (\mu_X - \mu_Y)}{\hat \sigma \sqrt{\frac1{n_X} + \frac1{n_Y}}}$$

Where:

$$\hat \sigma^2 = \frac{n_X S_X ^2 + n_Y S_Y ^2}{n_X + n_Y -2}$$

$T$ has a t-student distribution with degrees of freedom $\nu = n_X + n_Y - 2 = 18$.

$$- t \le T \le t \iff - t \le \frac{(\bar X - \bar Y) - (\mu_X - \mu_Y)}{\hat \sigma \sqrt{\frac1{n_X} + \frac1{n_Y}}} \le t \iff ... \iff \\ (\bar X - \bar Y) - t \hat \sigma \sqrt{\frac1{n_X} + \frac1{n_Y}} \le \mu_X - \mu_Y \le (\bar X - \bar Y) + t \hat \sigma \sqrt{\frac1{n_X} + \frac1{n_Y}}$$

Now we find $t$ from the table, and replace all the known values to get:

C.I $= \left[ 0.457, 33.542 \right]$

I don't care about the part with calculations, but my question is:

Is my work correct?

The next part of the question is asking to find whether we can say the company $1$ has faster computers than company $2$ at a risk $.05$. I know how to do this by testing the hypothesis $\mu_X = \mu_Y$ against $\mu_X > \mu_Y$. But is there a way to do it that makes use of the first part?

• if you have any comment please let me know. i am happy to have any feedback Sep 3, 2015 at 0:01
• Crossposted on stats: stats.stackexchange.com/q/169900/56303 Sep 3, 2015 at 13:37

Your formulas seem correct except that the pooled variance estimate should be

$$\hat \sigma^2 = \frac{(n_X-1) S_X ^2 + (n_Y-1) S_Y ^2}{n_X + n_Y -2}.$$

I put your summarized data into Minitab software, with the results below. Without doing the computations myself, it seems to me you are doing the computations correctly. You should re-do them with the corrected formula to see if your 95% CI matches theirs.

 MTB > TwoT 12 65 16.70 8 48 14.97;
SUBC>   Pooled.

Two-Sample T-Test and CI

Sample   N  Mean  StDev  SE Mean
1       12  65.0   16.7      4.8
2        8  48.0   15.0      5.3

Difference = mu (1) - mu (2)
Estimate for difference:  17.00
95% CI for difference:  (1.61, 32.39)
T-Test of difference = 0 (vs not =):
T-Value = 2.32  P-Value = 0.032  DF = 18
Both use Pooled StDev = 16.0494


If you were testing $H_0: \mu_X = \mu_Y$ against the two-sided alternative $H_a: \mu_X \ne \mu_Y$, then you could conclude directly from the 95% CI that $H_0$ is rejected, because the CI does not contain $0.$

However, because you are testing against a one-sided alternative, I think it is best for you to do the test. (The test shown in the Minitab printout is for the two-sided test. The test statistic (T-value in Minitab), and degrees of freedom will be the same, but the P-value will not be the same.

[Truthfully, you could show that rejecting in the two-sided test implies rejecting in the one-sided test, and in a round about way could logically use the CI as a substitute for the one-sided test, but that may be one logical step too far if you're just starting hypothesis testing.]

• As for the formula, my main confusion is whether I should use $n_X s_X ^2 + n_Y s_Y^2$ or $(n_X - 1) s_X^2 + (n_Y - 1) s_Y ^2$. According to my lecture notes, it's the former. But if we regard $s_X^2$ as the unbiased estimator of the population variance (instead of regarding it as the sample variance), then the latter formula matches my notes. So my question is: am I using a different notation than the standard one? Or is the formula in my hands an incorrect one? thanks for your time. Sep 3, 2015 at 2:56
• Without question, your formula for $\hat \sigma^2$ (often called $S_p^2,$ where p is for pooled) is incorrect; The idea is that $\hat \sigma^2$ is a 'weighted average' of the sample variances $S_x^2$ and $S_y^2,$ and the 'weights' are the degrees of freedom $n_X -1$ and $n_Y - 1.$ The denominator is the total degrees of freedom, $n_X + n_Y -2 = (n_X - 1)+(n_Y - 1).$ Sep 3, 2015 at 3:24
• I define $s_X ^2$ to be $\frac1{n} \sum(x_i - \bar x)^2$ instead of $\frac1{n-1} \sum(x_i - \bar x)^2$. Is this the same way that you define it? Sep 3, 2015 at 3:27
• No. That definition is not unheard of, but uncommon. Are you sure the sample variances given in this problem are computed from data with $n$ in the denominator? If so, you have many conflicts ahead with standard definitions of degrees of freedom for various CIs and tests as given in very many textbooks and implemented in every software package I know. Is there a textbook for this course? If so, what does it say. If not, maybe clarify these issues with your instructor. Sarcastic rule for students: "The instructor is always right while taking his/her course." Sep 3, 2015 at 3:33
• Unfortunately no references were available to us. I was self-studying from Hogg's but I later ran into conflicts with some notations, so I returned back to my lecture notes. If I would represent the data according to the standard notations, they would be: $s_X^2 = 304.36$ and $s_Y^2 = 256$. Sep 3, 2015 at 3:38