T-test
Dr. Duong Thi Binh An
Source: https://datatab.net/tutorial/t-test
Contents
• What a T-test is and when you use it?
• What types of T-test there are?
• What the hypotheses and the assumption are?
• How a T-test is calculated and how to interpret the results.
What a T-test is and when you use
it?
• T-test is a statistical procedure used to determine if there is a
significant difference between the means of two groups.
What types of T-test there are?
Dependent vs. independent sample
• In a dependent sample (i.e. paired sample), the measured values are
available in pairs. The pairs are created, for example, by repeated
measurements on the same persons. Independent samples (ie.e
unpaired sample) result from persons and measurements that are
independent of each other.
One sample T-testOne sample T-test is used if we want to compare
mean value of a sample with a known reference mean
(e.g. population mean).
Example: A manufacturer of chocolate bars claims
that its chocolate bars weigh 50 grams on average. To
verify this, a sample of 30 bars is taken and weighed.
The mean value of this sample is 48 grams.
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.
One sample T-testHypotheses:
- 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).
Independent samples T-test
Independent samples T-test is used when we want to
compare the means of two independent groups or
samples.
Example: we would like to compare the effectiveness of
two painkillers, drug A and drug B.
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
Independent samples T-test
Hypotheses:
- 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).
Pared samples T-test
The t-test for dependent samples (paired t-test) is used
to compare the means of two dependent groups.
Example: We want to know how effective a diet is. To
do this, we weigh 30 people before the diet and exactly
the same people after the diet.
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.
Pared samples T-test
Hypotheses:
- 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.
Assumptions
• Suitable sample:
1. For the one sample t-test we need a sample and a reference value.
2. In an independent t-test, we need two independent samples (Levene’s test)
3. And with the paired t-test, we need a dependent sample.
• Normally distributed metric variable (testing for normal distribution)
• Variance within the groups should be similar; i.e. homogeneity;
(Levene’s test) (for Independent T-test)
Doing T-test
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.
T-value
The t-value becomes smaller if we have a larger dispersion of the mean values.
Therefore, the greater the scatter of the data, the less a given mean difference
matters!
Doing T-test
Whether the null hypothesis is rejected or not?
Read critical T-value Calculate P-value
Example Calculation
The p-value measures the probability that the
independent samples T-test with 𝛼=0.05 and
Suppose you are conducting a two-tailed
observed data (or something more extreme) would
df = 20: occur under the null hypothesis.
1.Look up the critical T-value for α/2=0.025
•If , reject the null hypothesis.
and df = 20 in a T-distribution table.
•If , fail to reject the null hypothesis.
2.The table might show that the critical T-
value is approximately ±2.086.
( is level of Significance Level; commonly
Interpretation used values are 0.05, 0.01, and 0.10)
•If the calculated T-statistic is greater than
+2.086 or less than -2.086, you reject the
null hypothesis.
•If the calculated T-statistic falls between -
2.086 and +2.086, you fail to reject the null
Example:
• Let's consider an example where we want to compare the test scores
of two independent groups of students: Group A and Group B. We
want to determine if there is a significant difference in the mean test
scores between the two groups.
Example:
• Input Data:
• Enter the test scores for each student in the respective groups into SPSS.
• Create two columns: one for the test scores and another for the group
designation (e.g., Group A or Group B).
• Run Independent Samples T-Test:
• Go to Analyze -> Compare Means -> Independent-Samples T Test.
• Move the test score variable to the Test Variable(s) box.
• Move the group variable to the Grouping Variable box.
• Define groups (e.g., 1 for Group A, 2 for Group B).
• Click OK to run the test.
Example:
SPSS will produce several tables in the output window. Here, we'll focus
on the most relevant tables for interpreting the T-test results.
Group Statistics
--------------------------------------------------------
Group | N | Mean | Std. Deviation | Std. Error Mean
--------------------------------------------------------
Group A | 30 | 85.30 | 6.29 | 1.15
Group B | 30 | 82.10 | 7.42 | 1.36
Example:
Independent Samples Test
---------------------------------------------------------------------------------
| Levene's Test for Equality of Variances | t-test for Equality of Means
| ---------------------------------------- | ---------------------------
|F | Sig. | t | df | Sig. (2-tailed) | Mean Diff | Std. Error Diff | 95% CI of the Diff
---------------------------------------------------------------------------------
Equal variances assumed| 0.984| 0.325 | 1.856 | 58 | 0.068 | 3.20 | 1.72 | -0.23 to 6.63
Equal variances not assumed | | | 1.856 | 57.13 | 0.068 | 3.20 | 1.72 | -0.23 to 6.63
Interpretation of Results
The standard deviation for Group A is
6.29, and for Group B is 7.42.
Group A has a
mean score of
85.30, while Group The standard error
B has a mean score of the mean is 1.15
of 82.10. for Group A and
1.36 for Group B.
Interpretation of Results
The standard deviation for Group A is
6.29, and for Group B is 7.42.
Group A has a
mean score of
85.30, while Group The standard error
B has a mean score of the mean is 1.15
of 82.10. for Group A and
1.36 for Group B.
Levene's Test for Equality of Variances:
F = 0.984, Sig. = 0.325: The significance
value (0.325) is greater than 0.05,
indicating that the variances are equal.
Therefore, we use the row "Equal
variances assumed" for the t-test
interpretation.
Interpretation of Results
t = 1.856, df = 58, Sig. (2-tailed) = 0.068:
- The t-value is 1.856.
- Degrees of freedom (df) is 58.
- The two-tailed significance (p-value) is
0.068.
- Since the p-value (0.068) is greater than
the common alpha level (0.05), we fail to
reject the null hypothesis. This suggests
that there is no statistically significant
difference in the mean test scores
between Group A and Group B.
Interpretation of Results
Mean Difference: The difference in means 95% CI of the Difference: The 95% confidence
between Group A and Group B is 3.20. interval for the mean difference ranges from -0.23
to 6.63, indicating that the true mean difference
could lie within this range.
Conclusion
Based on the SPSS output:
• The mean test scores of Group A and Group B are not significantly
different at the 0.05 significance level.
• The p-value of 0.068 indicates that there is not enough evidence to
conclude that the mean scores of the two groups are different.