T-Test - Simply Explained - DATAtab
T-Test - Simply Explained - DATAtab
t-Test
The t-test is a statistical test procedure that tests whether there is a significant difference between the means of two groups.
The two groups could be, for example, patients who received drug A once and drug B once, and you want to know if there is a
difference in blood pressure between these two groups.
Types of t-test
There are three different types of t-tests. The one sample t-test, the independent-sample t-test and the paired-sample t-test.
https://datatab.net/tutorial/t-test 1/13
9/1/24, 3:14 PM t-Test - Simply explained - DATAtab
We can now perform a one sample t-test to see if the mean of 48 grams is significantly different from the claimed 50 grams.
https://datatab.net/tutorial/t-test 2/13
9/1/24, 3:14 PM t-Test - Simply explained - DATAtab
To do this, we randomly divide 60 test subjects into two groups. The first group receives drug A, the second group receives drug B. With
an independent t-test we can now test whether there is a significant difference in pain relief between the two drugs.
Now we can see for each person how big the weight difference is between before and after. With a dependent t-test we can now check
whether there is a significant difference.
https://datatab.net/tutorial/t-test 3/13
9/1/24, 3:14 PM t-Test - Simply explained - DATAtab
Tip
The t-test for dependent samples is very similar to the t-test for one sample. We can also think of the t-test for dependent samples as
having a sample that was measured at two different times. As shown in the following image, we then calculate the difference between
the paired values and get a value for one sample.
Once we get -5, once +2, once -1 and so on. Now we want to check whether the mean of the just calculated differences deviates from a
reference value. In this case, zero. And that is exactly what the t-test does for a sample.
Assumptions
What are the assumptions to be able to calculate a t-test in the first place? First, of course, we must have a suitable sample.
For the one sample t-test we need a sample and a reference value.
In an independent t-test, we need two independent samples.
And with the paired t-test, we need a dependent sample.
The variable for which it is to be tested whether there is a difference between the means must be metric. Metric variables are e.g. age,
body weight, income. A non-metric variable is, for example, a person's school-leaving qualification (Secondary School, High School,...).
Furthermore, the metric variable must be normally distributed in all three variants of the t-test.
https://datatab.net/tutorial/t-test 4/13
9/1/24, 3:14 PM t-Test - Simply explained - DATAtab
You can find out how to test whether your data are normally distributed in the tutorial on testing for normal distribution.
For the dependent t-test, the variances in the two groups must still be approximately equal. You can check whether the variances are
equal with the Levene test.
Hypotheses
So what are the hypotheses for the t-test? Let's start with the one sample t-test.
Null hypothesis: The sample mean is equal to the given reference value (so there is no difference).
Alternative hypothesis: The sample mean is not equal to the given reference value (so there is a difference).
Null hypothesis: The means in the two groups are equal (so there is no difference between the two groups).
Alternative hypothesis: The mean values in the two groups are not equal (i.e. there is a difference between the two groups).
Null hypothesis: The mean of the differences between the pairs is zero.
Alternative hypothesis: The mean of the differences between the pairs is non-zero.
There is a difference in the duration of studying between men and women in Germany.
Our basic population is therefore all graduates of a degree programme in Germany. Since we cannot, of course, survey all graduates,
we draw a sample that is as representative as possible.
https://datatab.net/tutorial/t-test 5/13
9/1/24, 3:14 PM t-Test - Simply explained - DATAtab
With the t-test we now test the null hypothesis that there is no difference in the population.
If there is no difference in the population, then we will certainly still see a difference in study duration in the sample. It would be very
unlikely that we would draw a sample where the difference is exactly zero.
In simple terms, we now want to know at what difference, measured in the sample, we can say that the length of study of men and
women is significantly different. And this is exactly what the t-test answers.
Calculate t-test
How do you calculate a t-test? First the t-value is needed:
To calculate the t-value, we need two values. First, we need the difference of the means and second, the standard deviation from the
mean. This value is called the standard error.
In the sample t-test, we calculate the difference between the sample mean and the known reference mean. s is the standard deviation
of the data collected and n is the number of cases.
https://datatab.net/tutorial/t-test 6/13
9/1/24, 3:14 PM t-Test - Simply explained - DATAtab
s divided by the square root of n is then the standard deviation from the mean or the standard error.
In the t-test for independent samples, the difference is simply calculated from the difference of the two sample means.
To calculate the standard error, we need the standard deviation and the number of cases of the first and the second sample.
Depending on whether we can assume equal or unequal variances for our data, there are different formulas for the standard error. More
on this in the tutorial on the t-test for independent samples.
With a paired samples t-test, we only need to calculate the difference of the paired values and calculate the mean from this. The
standard error is then the same as in the t-test for one sample.
Interpret t-value
Regardless of which t-test we calculate, the t-value becomes larger the greater the difference between the means. In the same
way, the t-value becomes smaller when the difference between the means is smaller.
https://datatab.net/tutorial/t-test 7/13
9/1/24, 3:14 PM t-Test - Simply explained - DATAtab
Also, the t-value becomes smaller if we have a larger dispersion of the mean values. So the greater the scatter of the data, the less
a given mean difference matters!
Let's start with the method involving the critical t-value, which we can read from a table. To do this, we first need the table of critical t-
values, which we can find on datatab.net, under "Tutorials" and "t-distribution". Let's start with the two-sided case first, which is a one-
sided or directed hypothesis. Below we see the table.
https://datatab.net/tutorial/t-test 8/13
9/1/24, 3:14 PM t-Test - Simply explained - DATAtab
First we have to determine which significance level we want to use. Here we choose a significance level of 0.05, i.e. 5%. Then we have
to look in the column at 1-0.05, so at 0.95.
Now we need the degrees of freedom. In the one sample t-test and the dependent-sample t-test, the degrees of freedom are simply the
number of cases minus 1. So if we have a sample of 10 people, we have 9 degrees of freedom. In the independent samples t-test, we
add the number of people from the two samples and calculate minus 2 because we have two samples. It should be noted that the
degrees of freedom can also be determined in other ways, depending on whether one assumes equal or unequal variance.
So if we have a significance level of 5% and 9 degrees of freedom, we get a critical t-value of 2.262.
On the one hand, we have now calculated a t-value with the t-test, and then we have the critical t-value. If the calculated t-value is
greater than the critical t-value, we reject the null hypothesis. Suppose we have calculated a t-value of 2.5. This value is greater than
2.262 and thus the two means are so far apart that we can reject the null hypothesis.
On the other hand, we can also calculate the p-value for the t-value we calculated. If we enter 2.5 for the t-value and 9 for the degrees of
freedom at the green marked region of the image, we get a p-value of 0.034. The p-value is smaller than 0.05 and thus we also reject
the null hypothesis in this way.
https://datatab.net/tutorial/t-test 9/13
9/1/24, 3:14 PM t-Test - Simply explained - DATAtab
As a check, if we enter the t-value of 2.262, we get exactly a p-value of 0.05, which is exactly the limit.
https://datatab.net/tutorial/t-test 10/13
9/1/24, 3:14 PM t-Test - Simply explained - DATAtab
For example, if you want to check whether gender has an influence on income, simply click on both variables and a t-test for
independent samples is automatically calculated. You can then read the p-value at the bottom.
https://datatab.net/tutorial/t-test 11/13
9/1/24, 3:14 PM t-Test - Simply explained - DATAtab
If you are still unsure how to interpret the results, you can simply click on "Interpretation in words":
A two tailed t-test for independent samples (equal variances assumed) showed that the difference between Female and Male with
respect to the dependent variable Salary was not statistically significant, t(10) = -2.16, p = .056, 95% confidence interval [-1445.23,
21.89]. Thus, the null hypothesis is not rejected.
https://datatab.net/tutorial/t-test 12/13
9/1/24, 3:14 PM t-Test - Simply explained - DATAtab
In this case, we are not interested in which of the two earns more, we only want to know whether there is a difference or not. With a
directed hypothesis, we are also interested in the direction of the difference. The alternative hypothesis is then, for example, men earn
more than women or women earn more than men.
If we look at this graphically with the t-distribution, we see that in the two-sided case we have one range on the left and one on the right.
We want to reject the null hypothesis if we are in either of them. At a significance level of 5%, both ranges have a probability of 2.5%, so
together they have 5%.
When we test a one-sided t-test, we only reject the null hypothesis if we are in this range, always depending on the sign (the side) we
are testing. In that case, With a significance level of 5%, the entire 5% then falls within this range.
Cite DATAtab: DATAtab Team (2024). DATAtab: Online Statistics Calculator. DATAtab e.U. Graz, Austria. URL https://datatab.net
https://datatab.net/tutorial/t-test 13/13