A t test is a statistical test that is used to compare the means of two groups. It is often used in hypothesis testing to determine whether a process or treatment actually has an effect on the population of interest, or whether two groups are different from one another. Show
Table of contents
When to use a t testA t test can only be used when comparing the means of two groups (a.k.a. pairwise comparison). If you want to compare more than two groups, or if you want to do multiple pairwise comparisons, use an ANOVA test or a post-hoc test. The t test is a parametric test of difference, meaning that it makes the same assumptions about your data as other parametric tests. The t test assumes your data:
If your data do not fit these assumptions, you can try a nonparametric alternative to the t test, such as the Wilcoxon Signed-Rank test for data with unequal variances. What type of t test should I use?When choosing a t test, you will need to consider two things: whether the groups being compared come from a single population or two different populations, and whether you want to test the difference in a specific direction. One-sample, two-sample, or paired t test?
One-tailed or two-tailed t test?
Here's why students love Scribbr's proofreading servicesTrustpilot Discover proofreading & editing Performing a t testThe t test estimates the true difference between two group means using the ratio of the difference in group means over the pooled standard error of both groups. You can calculate it manually using a formula, or use statistical analysis software. T test formulaThe formula for the two-sample t test (a.k.a. the Student’s t-test) is shown below.
In this formula, t is the t value, x1 and x2 are the means of the two groups being compared, s2 is the pooled standard error of the two groups, and n1 and n2 are the number of observations in each of the groups. A larger t value shows that the difference between group means is greater than the pooled standard error, indicating a more significant difference between the groups. You can compare your calculated t value against the values in a critical value chart (e.g., Student’s t table) to determine whether your t value is greater than what would be expected by chance. If so, you can reject the null hypothesis and conclude that the two groups are in fact different. T test function in statistical softwareMost statistical software (R, SPSS, etc.) includes a t test function. This built-in function will take your raw data and calculate the t value. It will then compare it to the critical value, and calculate a p-value. This way you can quickly see whether your groups are statistically different. In your comparison of flower petal lengths, you decide to perform your t test using R. The code looks like this: t.test(Petal.Length ~ Species, data = flower.data)Download the data set to practice by yourself. Sample data set Interpreting test resultsIf you perform the t test for your flower hypothesis in R, you will receive the following output: The output provides:
Presenting the results of a t testWhen reporting your t test results, the most important values to include are the t value, the p value, and the degrees of freedom for the test. These will communicate to your audience whether the difference between the two groups is statistically significant (a.k.a. that it is unlikely to have happened by chance). You can also include the summary statistics for the groups being compared, namely the mean and standard deviation. In R, the code for calculating the mean and the standard deviation from the data looks like this: flower.data %>% In our example, you would report the results like this: The difference in petal length between iris species 1 (M = 1.46; SD = 0.206) and iris species 2 (M = 5.54; SD = 0.569) was significant (t (30) = −33.7190; p < 2.2e-16).Frequently asked questions about t testsWhat is a t-test? A t-test is a statistical test that compares the means of two samples. It is used in hypothesis testing, with a null hypothesis that the difference in group means is zero and an alternate hypothesis that the difference in group means is different from zero. What does a t-test measure? A t-test measures the difference in group means divided by the pooled standard error of the two group means. In this way, it calculates a number (the t-value) illustrating the magnitude of the difference between the two group means being compared, and estimates the likelihood that this difference exists purely by chance (p-value). Which t-test should I use? Your choice of t-test depends on whether you are studying one group or two groups, and whether you care about the direction of the difference in group means. If you are studying one group, use a paired t-test to compare the group mean over time or after an intervention, or use a one-sample t-test to compare the group mean to a standard value. If you are studying two groups, use a two-sample t-test. If you want to know only whether a difference exists, use a two-tailed test. If you want to know if one group mean is greater or less than the other, use a left-tailed or right-tailed one-tailed test. What is the difference between a one-sample t-test and a paired t-test? A one-sample t-test is used to compare a single population to a standard value (for example, to determine whether the average lifespan of a specific town is different from the country average). A paired t-test is used to compare a single population before and after some experimental intervention or at two different points in time (for example, measuring student performance on a test before and after being taught the material). Can I use a t-test to measure the difference among several groups? A t-test should not be used to measure differences among more than two groups, because the error structure for a t-test will underestimate the actual error when many groups are being compared. If you want to compare the means of several groups at once, it’s best to use another statistical test such as ANOVA or a post-hoc test. Cite this Scribbr articleIf you want to cite this source, you can copy and paste the citation or click the “Cite this Scribbr article” button to automatically add the citation to our free Citation Generator.
|