T-Tests for Two Samples

Two Independent Samples

\boxed{ \sigma_1 = \sigma_2 \text{ if } \frac{ max(s_1, s_2) }{ min(s_1, s_2) } < 2 }

\boxed{ \begin{array}{cc} \begin{aligned} \sigma_1 = \sigma_2 &: \begin{cases} T &= \frac{\bar{X}_1 - \bar{X}_2}{SE_{\text{pooled}}} \\~\\ df^* &= n_1 + n_2 - 2 \end{cases} \\~\\ \sigma_1 \ne \sigma_2 &: \begin{cases} T &= \frac{\bar{X}_1 - \bar{X}_2}{SE_{\text{unpooled}}} \\~\\ df^* &= min(n_1 - 1, n_2 - 1) \end{cases} \end{aligned} & \begin{aligned} SE_{\text{unpooled}} &= \sqrt{ \frac{s_1^2}{n_1} + \frac{s_2^2}{n_2} } \\ S^2_{\text{pooled}} &= \frac{ (n_1 - 1)s_1^2 + (n_2 - 1) s_2^2 }{ n_1 + n_2 - 2 } \\ SE_{\text{pooled}} &= \sqrt{ s^2_{\text{pooled}} \left( \frac{1}{n_1} + \frac{1}{n_2} \right) } \end{aligned} \end{array} }

\boxed{ \text{Reject $H_0$ if: } \begin{cases} H_1 : \mu_1 \ne \mu_2 \leftrightarrow \mu_1 - \mu_2 \ne 0 &\quad |T| > t_{\alpha / 2 , df} &\quad \text{(two-tailed)} \\ H_1 : \mu_1 > \mu_2 \leftrightarrow \mu_1 - \mu_2 > 0 &\quad |T| > t_{\alpha , df} &\quad \text{(right-tailed)} \\ H_1 : \mu_1 < \mu_2 \leftrightarrow \mu_1 - \mu_2 < 0 &\quad |T| < - t_{\alpha , df} &\quad \text{(left-tailed)} \end{cases} }

On Notation:

Why?

Unpooled:

Hypotheses: \begin{aligned} H_0 : \mu_1 = \mu_2 \quad &\text{vs} \quad H_1: \mu_1 \ne \mu_2 \\ &\downarrow \\ H_0 : \mu_1 - \mu_2 = 0 \quad &\text{vs} \quad H_1: \mu_1 - \mu_2 \ne 0 \end{aligned}

Test Statistic: \begin{aligned} T &= \frac{(\bar{X}_1 - \bar{X}_2) - (\mu_1 - \mu_2)}{SE_{(\bar{X}_1 - \bar{X}_2)}} \\ &= \frac{\bar{X}_1 - \bar{X}_2}{SE_{(\bar{X}_1 - \bar{X}_2)}} \text{ under $H_0$} \end{aligned}

Degree of Freedom:

Pooled:

If the variances of the two samples are close enough, we can simplify by taking the weighted average of their SDs.

This gives us a test statistic that’s exactly on the t distribution, rather than a conservative estimate.
Example: Soybean Data

These are the stem lengths of soybeans under different fertilizers.

F120.222.923.320.019.422.022.122.021.921.519.721.520.9
F222.223.521.523.522.423.822.420.421.024.7

Q: Is there a significant difference between the two fertilizers?

A:

Let \mu_i: pop. mean of stem lengths of soybean with fertilizer i, i = 1,2

We can get:

Further:

From this, we can calculate T

\begin{aligned} T &= \frac{\bar{X}_1 - \bar{X}_2}{SE_{(\bar{X}_1 - \bar{X}_2)}} \\ &= \frac{21.34 - 22.54}{0.5447} \\ &= -2.203 \end{aligned}

We can see |T| < t, so we accept H_0 at \alpha = 0.05.

\boxed{ \text{C.I. for } \mu_1 - \mu_2 \text{ has } 0 \leftrightarrow \text{Accept $H_0$} }

Two Paired Samples

\boxed{ \text{Paired: } \begin{cases} H_0 : \text{use } \mu_d \\ d_i = x_{1i} - x_{2i} \forall i=1,...,n \\ \text{compute } \bar{d}, s_d, SE_{\bar{d}} \\ SE_{\bar{d}} = s_d / \sqrt{n} \\ T = \frac{\bar{d}}{SE_{\bar{d}}} \sim t(n-1) \end{cases} }

\boxed{ \text{Reject $H_0$ if: } \begin{cases} H_1 : \mu_d \ne 0 &\quad |T| > t_{\alpha / 2 , n - 1} &\quad \text{(two-tailed)} \\ H_1 : \mu_d > 0 &\quad T > t_{\alpha , n - 1} &\quad \text{(right-tailed)} \\ H_1 : \mu_d < 0 &\quad T < - t_{\alpha , n - 1} &\quad \text{(left-tailed)} \end{cases} }

Example: Weight Loss Data

The compound m-Faminol (mFAM) is thought to affect appetite and food intake in humans. Nine moderately obese women were given mFAM in a double-blind, placebo-controlled experiment.

The weight loss in kg for each woman was recorder under each condition. Assume the weight losses form a normal distribution.

Woman123456789meansd
mFAM1.11.30.81.71.40.10.51.6-0.50.88890.7373
placebo0.5-0.30.60.30.7-0.20.60.9-1.50.17780.7463

Q: Does mFAM have an effect? (\alpha = 0.05)

A:

Let H_0 : \mu_d = 0, \mu_d = \mu_{mFAM} - \mu_{placebo}

Now we will calculate d_i:

Woman123456789
mFAM (x_{1i})1.11.30.81.71.40.10.51.6-0.5
placebo (x_{2i})0.5-0.30.60.30.7-0.20.60.9-1.5
d_i = x_{1i} - x_{2i}0.61.60.21.40.70.3-0.10.71.0

We can calculate \bar{d} = 0.711 and s_d = 0.553 to get SE_{\bar{d}}:

\begin{aligned} SE_{\bar{d}} &= \frac{ s_d }{ \sqrt{n} } \\ &= \frac{ 0.553 }{ \sqrt{9} } \\ &= 0.1844 \end{aligned}

Now we can get T and t for two-tailed test:

\begin{aligned} T &= \frac{\bar{d}}{SE_{\bar{d}}} \\ &= \frac{0.711}{0.1844} \\ &= 3.8563 \end{aligned}

t_{\alpha / 2, n-1} = t_{0.025, 8} = 2.306

Because |T| > t, we reject H_0 at \alpha = 0.05

\boxed{ \text{Paired C.I.: } \bar{d} \pm t_{\alpha / 2, n-1} SE_{\bar{d}} } \\ \small\textit{accept $H_0$ if contains 0}