Premed · Premed · Statistics Biostatistics
Lecture 15: One-Sample and Two-Sample t-Tests
Statistics / Biostatistics
Learning Objectives
By the end of this lecture, students will be able to:
- Perform and interpret a one-sample t-test
- Perform and interpret an independent two-sample t-test (pooled and Welch)
- Perform and interpret a paired t-test
- Verify the assumptions of each test and identify when violations are problematic
- Report t-test results in a clinical research format
Lecture Content
I. One-Sample t-Test
The one-sample t-test is used to test whether the population mean differs from a specified value mu_0. The hypotheses are H0: mu = mu_0 versus H1: mu does not equal mu_0 (two-sided), or a one-sided alternative. The test statistic is t = (x-bar - mu_0) / (s / sqrt(n)), with df = n - 1. The assumptions are that the data are a simple random sample and that the population is approximately normally distributed (or n is sufficiently large for the CLT to apply).
As an example, a laboratory claims its mean hemoglobin measurement is 14.0 g/dL. A sample of 20 measurements yields x-bar = 14.8 and s = 1.5. The test statistic is t = (14.8 - 14.0) / (1.5 / sqrt(20)) = 0.8 / 0.335 = 2.385. With df = 19 and a critical value of t_(0.025, 19) = 2.093, since 2.385 > 2.093, we reject H0 and conclude that the mean is significantly different from 14.0.
II. Independent Two-Sample t-Test
The independent two-sample t-test compares the means of two independent groups. The hypotheses are H0: mu_1 = mu_2 (or equivalently, mu_1 - mu_2 = 0) versus H1: mu_1 does not equal mu_2. Two versions exist.
Pooled t-Test
The pooled (Student's) t-test assumes equal population variances. The pooled variance is s_p^2 = [(n1-1)s1^2 + (n2-1)s2^2] / (n1 + n2 - 2), and the test statistic is t = (x-bar1 - x-bar2) / [s_p * sqrt(1/n1 + 1/n2)], with df = n1 + n2 - 2. This version should be used when there is good reason to believe variances are equal, such as when Levene's test is non-significant.
Welch's t-Test
Welch's t-test does not assume equal variances. It uses SE = sqrt(s1^2/n1 + s2^2/n2), and the test statistic is t = (x-bar1 - x-bar2) / SE, with degrees of freedom calculated using the Welch-Satterthwaite equation (usually resulting in a non-integer). Welch's test is more robust and is recommended as the default two-sample t-test.
<image>A side-by-side comparison of two independent groups. Panel A: Two overlapping histograms (or density curves) for Group 1 and Group 2, with vertical dashed lines at each group mean. The difference between means is annotated. Panel B: A summary table showing n, mean, SD for each group, the test statistic, df, and p-value. Panel C: A number line showing the 95% CI for the difference in means, with zero marked to indicate significance.</image>
III. Paired t-Test
The paired t-test compares means when observations are naturally paired, such as before versus after treatment on the same patients or matched pairs in a twin study. The procedure calculates differences d_i = x_after,i - x_before,i for each pair, then computes d-bar and s_d. The test statistic is t = d-bar / (s_d / sqrt(n)), with df = n - 1, which is equivalent to a one-sample t-test on the differences. The paired design has the advantage of eliminating between-subject variability, thereby increasing statistical power.
As an example, blood glucose was measured before and after a dietary intervention in 12 patients. With d-bar = -15 mg/dL and s_d = 20 mg/dL, the test statistic is t = -15 / (20 / sqrt(12)) = -15 / 5.77 = -2.60, with df = 11 and a p-value of approximately 0.025 (two-sided). We reject H0 and conclude that the intervention significantly reduced blood glucose.
IV. Assumptions and Diagnostics
The normality assumption requires that the data (or differences for the paired test) are approximately normally distributed. This can be checked with a histogram, Q-Q plot, or Shapiro-Wilk test. The t-test is robust to moderate violations when n is large (n >= 30). Independence requires that observations are independent within and between groups, which is violated if patients are clustered (for example, multiple measurements per patient). Equal variances are assumed only for the pooled t-test and can be checked with Levene's test or by comparing standard deviations (a rule of thumb is s_max / s_min < 2). When in doubt, use Welch's t-test. Outliers can heavily influence the mean and t-statistic and should be investigated; sensitivity analyses or nonparametric alternatives may be warranted.
<image>A diagnostic panel for t-test assumptions. Panel A: A Q-Q plot of residuals showing points approximately on the diagonal line -- normality assumption met. Panel B: Side-by-side boxplots of two groups with similar spreads -- equal variance assumption met. Panel C: A Q-Q plot with systematic curvature -- normality assumption violated. Panel D: Side-by-side boxplots with one group much more variable than the other -- unequal variances, use Welch's test. Each panel is annotated with the interpretation.</image>
V. Effect Size: Cohen's d
The p-value depends on sample size, but effect size does not, making it an essential complement to significance testing. Cohen's d for two independent groups is calculated as d = (x-bar1 - x-bar2) / s_p, while for paired data it is d = d-bar / s_d. Cohen's guidelines provide benchmarks: d = 0.2 is a small effect, d = 0.5 is a medium effect, and d = 0.8 is a large effect. Always report effect size alongside the p-value for clinical interpretability.
VI. Reporting Results
Results from t-tests should be reported in a standard format. An example: "The mean SBP in the treatment group (128.5 +/- 12.3 mmHg) was significantly lower than in the control group (135.2 +/- 14.1 mmHg); t(58) = -2.12, p = 0.038, Cohen's d = 0.51." The report should include descriptive statistics for each group (mean, SD, n), the test statistic and degrees of freedom, the exact p-value (not just "< 0.05"), the confidence interval for the difference, and an effect size measure. CONSORT guidelines for clinical trials recommend reporting CIs in addition to p-values.
<image>A forest plot showing the results of several t-test comparisons from a clinical study. Each row represents a different outcome variable (SBP, DBP, heart rate, BMI). For each, the point estimate (difference in means) is shown as a square, and the 95% CI is shown as a horizontal line. A vertical line at zero represents "no difference." Outcomes whose CIs exclude zero are highlighted. Sample sizes and p-values are listed to the right of each row.</image>


