T-Test
calculator.
Test whether a mean differs from a target, or two means differ from each other.
- Sample mean − target
- −0.3
- 95% interval
- −3.838 to 3.238
- Cohen's d
- −0.061
The mean is 0.3 below 170, which chance alone could easily produce with this much spread. That is not proof of no difference: the 95% interval still runs from −3.838 to 3.238.
Where your t falls
If the true difference were zero, t would follow this curve with 9 degrees of freedom. Your t of −0.192 is short of the critical value of ±2.262, and the shaded area, 0.8521, is the p-value.
How big is the difference?
- |d| below 0.2
- negligible, yours
- |d| 0.2 to 0.5
- small
- |d| 0.5 to 0.8
- medium
- |d| 0.8 or more
- large
Cohen's rough benchmarks, set for behavioral research. Yours is 0.06. For one sample, d is the gap over the sample SD.
Group statistics
| Group | n | Mean | SD | SE of mean |
|---|---|---|---|---|
| Your samplen 10 | 10 | 169.7 | 4.9453SE 1.5638 | 1.5638 |
Every test on these numbers
| Test | t | df | p | Significant |
|---|---|---|---|---|
| One sample, yours | −0.192df 9 | 9 | 0.8521Not significant | No |
| Welch, two samples | 2.361df 15.58 | 15.58 | 0.0316Significant | Yes |
| Pooled, two samples | 2.341df 16 | 16 | 0.0325Significant | Yes |
For the same t, two-tailed p is 0.8521, right-tailed p is 0.5739, left-tailed p is 0.4261. Choose the test from your design, before you see these figures.
Two tails against one
The one-tailed p is half the two-tailed p when t points the chosen way. That is valid only if you fixed the direction before seeing the data.
Your data as a grid
| # | Values |
|---|---|
| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 |
Working
- 1Mean and SD of the sampleMean = 169.7s = 4.9453, n = 10
- 2Standard error: s over the root of nSE =4.9453√10= 1.5638
- 3Divide by the standard error, with 9 degrees of freedomt =169.7 − 1701.5638= −0.1918
- 4Read the two-tailed p-valuep = 0.8521, so do not reject equal means at α = 0.05
- 5The 95% interval is the gap ± t × SE−0.3 ± 2.262 × 1.5638 = −3.838 to 3.238
- 6Check: t times the standard error gives the gap back−0.1918 × 1.5638 = −0.3The interval holds 0, and the test does not reject: they agree
How it's worked out
Every version of the test divides a gap by its standard error, which is how much that gap would wobble from sample to sample. A large t means the gap is big compared with that wobble. The p-value is the chance of a t at least this extreme if the true gap were zero.
One sample. Compare one mean with a target , such as a fill weight of 500 g. Here is the sample mean, its standard deviation, and the count, with degrees of freedom.
Paired. Use this for the same subjects measured twice. It takes each second value minus its first, then runs the one sample test on those differences against zero. The R notes on Student's sleep data stress that this classic set is 10 people, not two groups.
Welch. Use this for two separate groups. It gives each group its own variance, and its degrees of freedom usually are not whole numbers. Call the two variance terms and .
Pooled. This is the classic Student test. It assumes the two groups share one variance, combines them into , and uses degrees of freedom.
The interval is the gap plus or minus a critical t times the standard error. It is always two-sided at your confidence level, even for a one-tailed test. Cohen's d is the gap in standard deviation units: over the sample SD for one sample, over the pooled SD for two samples, and over the SD of the differences for paired data, where it is called dz.
Worked examples
Student's sleep drugs, tested as pairs
In Student's 1908 data, ten patients each tried two sleeping drugs, and the numbers are extra hours of sleep. The second drug gives a mean of 1.58 extra hours over the first. With a standard error of 0.389, t is 4.062 on 9 degrees of freedom.
That gives p = 0.0028, and the 95% interval for the gain runs from 0.7 to 2.46 hours. It leaves out 0, as it must when a two-tailed test at the same level rejects. At 1.28, dz is large.
The same numbers, tested as two groups
Treat those lists as if they came from 20 different people, and Welch's test gives t = −1.861 and p = 0.079, no longer significant at 5%. The pooled version agrees, with p = 0.079. The gap in means is the same 1.58 hours, but its standard error rises from 0.389 to 0.849.
The extra wobble comes from the large differences between patients, and pairing is what removes them. Here the design, not the arithmetic, decides the conclusion. The test has to match how the data were collected.
Ten heights against 170 cm
Ten people have a mean height of 169.7 cm, which is 0.3 cm below the target. With an SD of 4.95 cm, t is only −0.192, and p = 0.852. The 95% interval for the gap runs from −3.84 to 3.24 cm, so these data fit a true mean of 170 cm and several others nearby.
Reading your result
Compare t with the critical value. With 9 degrees of freedom at the 5% level, a two-tailed test needs t beyond ±2.262, and a one-tailed test needs 1.833 in the chosen direction. The p-value holds the same information, in a form that does not depend on the degrees of freedom.
Use the interval to judge size. A narrow interval far from 0 is strong and useful evidence. A wide one that barely misses 0 tells you little about how big the effect is. The interval also has the units of your data, which p does not.
Read d against what matters to you. Cohen's bands call 0.20 small, 0.50 medium and 0.80 large, and Lakens warns against applying them rigidly. A very large sample can give a tiny p for a d too small to care about.
Read the sign as a direction only. Swap the two lists in the sleep data and t goes from 4.062 to −4.062, with the same p. The size of t decides significance in a two-tailed test.
Common mistakes
- Treating paired data as independent. The sleep data show the cost: a clear result turns into a nonsignificant one. The reverse mistake, pairing unrelated lists, is worse, as it invents a link that is not there.
- Testing variances first, then choosing. Delacre, Lakens and Leys say this two-step habit should not be used, because the variance test often has too little power to warn you. They recommend Welch as the default.
- Choosing a one-tailed test after seeing the data. A one-tailed test puts all of α in one direction, so the sleep data's p falls from 0.0028 to 0.0014. UCLA's guidance is that picking one just to reach significance is not appropriate.
- Running many t-tests on several groups. With several groups, every pair you test is one more chance to be fooled at the 5% level. For three or more groups, use the one-way ANOVA calculator and follow up from there.
- Ignoring outliers in a small sample. The test works from means and SDs, and one wild value can move both. Look at the values first, and try the Mann-Whitney calculator if the data are strongly skewed.
Questions people ask
Sources
- NIST/SEMATECH e-Handbook of Statistical Methods, section 1.3.5.3, Two-Sample t-Test for Equal Means
- R documentation, Student's sleep data
- Delacre, M., Lakens, D. and Leys, C. (2017), Why psychologists should by default use Welch's t-test, International Review of Social Psychology
- Lakens, D. (2013), Calculating and reporting effect sizes, Frontiers in Psychology 4, 863
- Cohen, J. (1992), A power primer, Psychological Bulletin 112(1), 155-159
- UCLA OARC, What are the differences between one-tailed and two-tailed tests?
- MRC Cognition and Brain Sciences Unit, statistics wiki, normality and sample size