How to do a t-test in Google Sheets
A t-test compares two means. Which version you need depends on how the data was collected.
| Situation | Test | T.TEST type |
|---|---|---|
| The same people measured twice (before and after) | Paired Two Sample for Means | 1 |
| Two separate groups, similar spread | Two-Sample Assuming Equal Variances | 2 |
| Two separate groups, different spread | Two-Sample Assuming Unequal Variances (Welch) | 3 |
Paired example
Ten students took a test with Method A and later with Method B.
| A | B | |
|---|---|---|
| 1 | Method A | Method B |
| 2 | 78 | 71 |
| 3 | 85 | 79 |
| 4 | 69 | 65 |
| 5 | 91 | 84 |
| 6 | 74 | 70 |
| 7 | 88 | 76 |
| 8 | 82 | 73 |
| 9 | 77 | 69 |
| 10 | 80 | 75 |
| 11 | 86 | 78 |
In StatPak choose t-Test: Paired Two Sample for Means, set Variable 1 to A1:A11, Variable 2 to B1:B11, tick Labels and click Run.
| t-Test: Paired Two Sample for Means | ||
| Method A | Method B | |
| Mean | 81 | 74 |
| Variance | 45.55556 | 30.88889 |
| Observations | 10 | 10 |
| Pearson Correlation | 0.9389553 | |
| Hypothesized Mean Difference | 0 | |
| df | 9 | |
| t Stat | 9.036961 | |
| P(T<=t) one-tail | 4.1282E-6 | |
| t Critical one-tail | 1.833113 | |
| P(T<=t) two-tail | 8.2564E-6 | |
| t Critical two-tail | 2.262157 |
P(T<=t) two-tail is 8.2564E-6, far below 0.05, so the average score changed between methods. The same p-value comes from =T.TEST(A2:A11, B2:B11, 2, 1).
Two independent groups
Comparing Method A with a separate group taught with Method C, assuming equal variances:
| t-Test: Two-Sample Assuming Equal Variances | ||
| Method A | Method C | |
| Mean | 81 | 65 |
| Variance | 45.55556 | 21.11111 |
| Observations | 10 | 10 |
| Pooled Variance | 33.33333 | |
| Hypothesized Mean Difference | 0 | |
| df | 18 | |
| t Stat | 6.196773 | |
| P(T<=t) one-tail | 3.7754E-6 | |
| t Critical one-tail | 1.734064 | |
| P(T<=t) two-tail | 7.5509E-6 | |
| t Critical two-tail | 2.100922 |
With unequal variances (Welch's test), the degrees of freedom change. Excel's ToolPak rounds Welch's degrees of freedom to a whole number, and StatPak does the same so results match course answer keys: here df is 16 and the two-tail p-value is 1.2803E-5. =T.TEST(A2:A11, C2:C11, 2, 3) uses the unrounded value, so it can differ slightly in later digits.
One tail or two?
Use the two-tail p-value unless you decided before looking at the data that only one direction matters. The one-tail p-value is half the two-tail value when the difference goes in the predicted direction.