Statistics and research

T-test calculator

One-sample, independent two-sample (Welch and pooled) and paired t-tests from raw data or summary statistics, with confidence intervals and Cohen’s d.

Runs in your browser. What you enter stays on this page and is not uploaded.

Separate values with spaces, commas, tabs or new lines (paste a spreadsheet column). Use a point for decimals.
For paired data, list the values in the same order as sample 1.

Results

t (Welch)-1.8608df17.776p-value0.07939
Mean difference (1 − 2)
-1.58
Hypothesis
two-sided, difference ≠ 0
Cohen’s d (pooled SD)
-0.83218
Hedges’ g (bias-corrected)
-0.79694
Conclusion (Welch)
The difference is not significant at the 5% level.
Groups
GroupnMeanSDSE
Sample 1100.751.789010.565735
Sample 2102.332.002250.633167
Two-sample t-tests
Testtdfp-valueEstimateSE95% CI lower95% CI upper
Welch (unequal variances)-1.8608117.77650.07939-1.580.849091-3.365480.205483
Student (pooled variance)-1.86081180.07919-1.580.849091-3.363870.203874

Welch’s test is the default (as in R): it does not assume equal variances and loses little when they are equal. Student’s pooled test is shown for comparison.

Method and limits

How to use it

Choose the test, then paste raw data or enter summary statistics (n, mean, SD). For paired data list both samples in the same order — each position is one pair. Set the hypothesized difference (usually 0), the alternative and the confidence level.

Formulas

  • One sample: t = (x̄ − μ₀) / (s / √n), df = n − 1.
  • Paired: a one-sample t-test on the differences d = x₁ − x₂.
  • Welch: t = (x̄₁ − x̄₂ − Δ₀) / √(s₁²/n₁ + s₂²/n₂), with Welch–Satterthwaite df = (v₁ + v₂)² / (v₁²/(n₁ − 1) + v₂²/(n₂ − 1)), vi = si²/ni.
  • Student (pooled): sp² = ((n₁ − 1)s₁² + (n₂ − 1)s₂²) / (n₁ + n₂ − 2), t = (x̄₁ − x̄₂ − Δ₀) / (sp √(1/n₁ + 1/n₂)), df = n₁ + n₂ − 2.
  • Confidence interval: estimate ± tcrit × SE (one-sided intervals for one-sided alternatives, as R).
  • Cohen’s d = (x̄₁ − x̄₂) / sp; Hedges’ g = J d with J = Γ(ν/2) / (√(ν/2) Γ((ν − 1)/2)).

Assumptions and limits

  • Independent observations (within and between groups for the two-sample test).
  • Approximately normal data, or differences for the paired test; with 30 or more per group the test is robust to moderate non-normality. For small skewed samples use the Mann–Whitney or Wilcoxon test.
  • Welch’s test is the default because it does not need equal variances and loses almost nothing when they are equal (as R’s t.test).

Worked example

R’s sleep data (extra hours of sleep with two drugs, 10 patients each): Welch’s t = −1.861 with 17.78 df, p = 0.0794, 95% CI −3.365 to 0.205; the pooled test gives p = 0.0792. Treated as paired (the same patients took both drugs), t = −4.062 with 9 df, p = 0.00283, CI −2.460 to −0.700 — identical to R’s t.test.

References

Related tools

Share this page

Remind me to visit Contifield

Adds a repeating reminder to your calendar, titled “Contifield Reminder: Visit www.contifield.com”.