Hypothesis TestingTopic #27 of 33

T-Test for Means

Testing means with unknown σ: one-sample, independent two-sample, and paired t-tests.

Overview

The t-test is used to test hypotheses about population means when the population standard deviation is unknown and must be estimated from sample data.

Types of T-Tests

TypePurpose
One-sampleCompare sample mean to hypothesized value
Independent two-sampleCompare means of two independent groups
Paired (dependent)Compare means of matched pairs or before/after

One-Sample T-Test

Test Statistic

t=xˉμ0s/nt = \frac{\bar{x} - \mu_0}{s/\sqrt{n}}

Degrees of Freedom

df=n1df = n - 1

Independent Two-Sample T-Test

Equal Variances Assumed (Pooled)

t=xˉ1xˉ2sp2(1n1+1n2)t = \frac{\bar{x}_1 - \bar{x}_2}{\sqrt{s_p^2\left(\frac{1}{n_1} + \frac{1}{n_2}\right)}}

Pooled variance:

sp2=(n11)s12+(n21)s22n1+n22s_p^2 = \frac{(n_1-1)s_1^2 + (n_2-1)s_2^2}{n_1 + n_2 - 2}

Degrees of freedom:

df=n1+n22df = n_1 + n_2 - 2

Unequal Variances (Welch's T-Test)

t=xˉ1xˉ2s12n1+s22n2t = \frac{\bar{x}_1 - \bar{x}_2}{\sqrt{\frac{s_1^2}{n_1} + \frac{s_2^2}{n_2}}}

Degrees of freedom (Welch-Satterthwaite):

df=(s12n1+s22n2)2(s12/n1)2n11+(s22/n2)2n21df = \frac{\left(\frac{s_1^2}{n_1} + \frac{s_2^2}{n_2}\right)^2}{\frac{(s_1^2/n_1)^2}{n_1-1} + \frac{(s_2^2/n_2)^2}{n_2-1}}

Paired T-Test

For differences d=x1x2d = x_1 - x_2:

t=dˉsd/nt = \frac{\bar{d}}{s_d/\sqrt{n}}

Where:

  • dˉ\bar{d} = mean of differences
  • sds_d = standard deviation of differences
  • df=n1df = n - 1

Assumptions

  1. Random sampling
  2. Independence (except for paired data)
  3. Normal population OR n30n \geq 30
  4. For two-sample: homogeneity of variance (if using pooled)

Examples

Example 1: One-Sample T-Test

Test if mean differs from 75. Sample: n=16n = 16, xˉ=78\bar{x} = 78, s=8s = 8. α=0.05\alpha = 0.05.

H0:μ=75,H1:μ75H_0: \mu = 75, \quad H_1: \mu \neq 75 t=78758/16=32=1.5t = \frac{78 - 75}{8/\sqrt{16}} = \frac{3}{2} = 1.5 df=15,tcrit=2.131df = 15, \quad t_{\text{crit}} = 2.131 1.5<2.131Fail to reject H0\lvert 1.5 \rvert < 2.131 \Rightarrow \text{Fail to reject } H_0

Example 2: Independent Two-Sample (Pooled)

Group A: n=12n = 12, xˉ=85\bar{x} = 85, s=6s = 6

Group B: n=15n = 15, xˉ=80\bar{x} = 80, s=8s = 8

Test H0:μ1=μ2H_0: \mu_1 = \mu_2 at α=0.05\alpha = 0.05.

sp2=(11)(36)+(14)(64)25=396+89625=51.68s_p^2 = \frac{(11)(36) + (14)(64)}{25} = \frac{396 + 896}{25} = 51.68 t=858051.68(112+115)=551.68(0.150)=52.78=1.80t = \frac{85 - 80}{\sqrt{51.68\left(\frac{1}{12} + \frac{1}{15}\right)}} = \frac{5}{\sqrt{51.68(0.150)}} = \frac{5}{2.78} = 1.80 df=25,tcrit=2.060df = 25, \quad t_{\text{crit}} = 2.060 1.80<2.060Fail to reject H0\lvert 1.80 \rvert < 2.060 \Rightarrow \text{Fail to reject } H_0

Example 3: Paired T-Test

Before/after measurements for 10 subjects:

SubjectBeforeAfterDifference (dd)
Mean--dˉ=4.5\bar{d} = 4.5
SD--sd=3.2s_d = 3.2

Test H0:μd=0H_0: \mu_d = 0 at α=0.05\alpha = 0.05.

t=4.53.2/10=4.51.01=4.45t = \frac{4.5}{3.2/\sqrt{10}} = \frac{4.5}{1.01} = 4.45 df=9,tcrit=2.262df = 9, \quad t_{\text{crit}} = 2.262 4.45>2.262Reject H0\lvert 4.45 \rvert > 2.262 \Rightarrow \text{Reject } H_0

Significant change from before to after.

Effect Size (Cohen's d)

d=xˉ1xˉ2spd = \frac{\bar{x}_1 - \bar{x}_2}{s_p}
ddInterpretation
0.2Small
0.5Medium
0.8Large

Confidence Interval

For difference in means:

(xˉ1xˉ2)±tα/2,df×SE(\bar{x}_1 - \bar{x}_2) \pm t_{\alpha/2, df} \times SE