An Introduction To T-Tests - Definitions, Formula and Examples
An Introduction To T-Tests - Definitions, Formula and Examples
Table of contents
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.
The null hypothesis (H0) is that the true difference between these group means is
zero.
The alternate hypothesis (Ha) is that the true difference is different from zero.
https://www.scribbr.com/statistics/t-test/ 1/9
7/26/22, 10:41 AM An Introduction to T-Tests | Definitions, Formula and Examples
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:
1. are independent
2. are (approximately) normally distributed.
3. have a similar amount of variance within each group being compared (a.k.a.
homogeneity of variance)
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.
https://www.scribbr.com/statistics/t-test/ 2/9
7/26/22, 10:41 AM An Introduction to T-Tests | Definitions, Formula and Examples
Academic style
Vague sentences
Grammar
Style consistency
See an example
Performing a t-test
The 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 formula
The 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.
https://www.scribbr.com/statistics/t-test/ 3/9
7/26/22, 10:41 AM An Introduction to T-Tests | Definitions, Formula and Examples
A larger t-value shows that the difference between group means is greater than the pooled
standard error, indicating
Table of contentsa 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.
In your comparison of flower petal lengths, you decide to perform your t-test using R. The
code looks like this:
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.
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:
https://www.scribbr.com/statistics/t-test/ 5/9
7/26/22, 10:41 AM An Introduction to T-Tests | Definitions, Formula and Examples
flower.data %>%
Table of contents
group_by(Species) %>%
summarize(mean_length = mean(Petal.Length),
sd_length = sd(Petal.Length))
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).
What is a t-test?
1447
213
https://www.scribbr.com/statistics/t-test/ 6/9
7/26/22, 10:41 AM An Introduction to T-Tests | Definitions, Formula and Examples
Table of contents
Rebecca Bevans
Rebecca is working on her PhD in soil ecology and spends her free time writing. She's very
happy to be able to nerd out about statistics with all of you.
2183
1598
https://www.scribbr.com/statistics/t-test/ 7/9
7/26/22, 10:41 AM An Introduction to T-Tests | Definitions, Formula and Examples
177
Table of contents
Scribbr
Our editors
Jobs
FAQ
Partners
Our services
Plagiarism Checker
Proofreading Services
Citation Checker
APA Citation Generator
MLA Citation Generator
Knowledge Base
Contact
[email protected]
+1 (510) 822-8066
4.9
Terms of use
https://www.scribbr.com/statistics/t-test/ 8/9
7/26/22, 10:41 AM An Introduction to T-Tests | Definitions, Formula and Examples
Privacy Policy
https://www.scribbr.com/statistics/t-test/ 9/9