Published on January 31, 2020 by Rebecca Bevans. Revised on July 9, 2022. 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. You want to know whether the mean petal length
of iris flowers differs according to their species. You find two different species of irises growing in a garden and measure 25 petals of each species. You can test the difference between these two groups using a t-test and null and alterative hypotheses. 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?
In your test of whether petal length differs by species:
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 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:
From the output table, we can see that the difference in means for our sample data is −4.084 (1.456 − 5.540), and the confidence interval shows that the true difference in means is between −3.836 and −4.331. So, 95% of the time, the true difference in means will be different from 0. Our p-value of 2.2e–16 is much smaller than 0.05, so we can reject the null hypothesis of no difference and say with a high degree of confidence that the true difference in means is not equal to zero. 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 (Mean = 1.46; SD = 0.206) and iris species 2 (Mean = 5.54; SD = 0.569) was significant (t (30) = −33.7190; p < 2.2e-16). Frequently asked questions about t-testsWhat 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). Sources in this articleWe strongly encourage students to use sources in their work. You can cite our article (APA Style) or take a deep dive into the articles below. This Scribbr article
Is this article helpful?You have already voted. Thanks :-) Your vote is saved :-) Processing your vote... What test can be used to test the difference between twoA z-test is a statistical test to determine whether two population means are different when the variances are known and the sample size is large. A z-test is a hypothesis test in which the z-statistic follows a normal distribution.
What test can be used to test the difference between twoThe two-sample t-test (also known as the independent samples t-test) is a method used to test whether the unknown population means of two groups are equal or not.
What test can be used to test the difference between two means when the population standard deviation is unknown?The test comparing two independent population means with unknown and possibly unequal population standard deviations is called the Aspin-Welch t-test.
Which test is used to calculate differences in two means of population?Hypothesis test for the difference between means of two populations.
|