Skip to Main Content

t-tests: Maths and Stats

Overview of Different t-tests

t-test is a type of comparison test used in hypothesis testing to compare the means of two groups. Therefore, in such a test, your independent variable is the variable which consists of these groups. These can be:

  • the same group, measured at different time points, OR
  • two different groups

If you have more than two groups, you cannot use a t-test! Instead, you should use an ANOVA.

t-tests are parametric tests, which means they are used for data which is normally distributed, homogeneous and independent. Make sure you check these assumptions before attempting to perform a t-test, as if you have non-parametric data, you will need to use a non-parametric test!

Note that t-tests are most effective when you have greater than ten participants in each group: however, to retain statistical power, you should consider calculating the appropriate sample size for your study.


Guide contents

The tabs of this guide will support you in understanding t-tests. The sections are organised as follows:

  • Recap: Parametric Assumptions - what it means to have parametric data
  • Paired t-test - Student's t-test comparing one group of participants at two different time points
  • Independent Samples t-test - Student's t-test comparing two different groups of participants
  • Welch's t-test - a type of non-Student Independent t-test, as a variation of the Independent Samples t-test
  • One-Sample t-test - another non-Student t-test, which compares a group to a single measurement

Parametricity

t-tests are parametric tests, and although definitions of parametricity vary across sources you may come across, in general what this means is that your data should be:

  • Normally distributed
  • Homogeneous
  • Independent

You must check these assumptions before attempting to perform a t-test (or during, depending on the software you use). This is because, if any of these assumptions fail, you cannot continue with a t-test and must use a non-parametric equivalent.


Normally Distributed

Continuous data can be plotted in a histogram to display the shape the distribution takes. When this distribution is shown to be 'normal' we say that the data is 'normally distributed'.

A normally distributed set of data, with a normal curve placed on top to highlight this.

A Q-Q plot can also be used to check the distribution of your data.

Alternatively, instead of visually inspecting your data's distribution using a graph, you can use a test:

  • Shapiro-Wilk test
  • Anderson-Darling test.

Note that categorical data can never be normally distributed! This is because it is neither interval nor ratio data, and therefore does not make sense to check the distribution. Normality should be checked on your continuous data, e.g. measurements, discrete counts, etc.

If your data does not take the shape of the normal distribution, you can do either of two things:

  1. Use a non-parametric equivalent to the parametric test you wish to do
  2. Try and transform your data.

Homogeneity

Data which is homogeneous means that the groups contain roughly constant variance. You can test for homogeneity using:

  • Box plots
  • Bartlett's test
  • Levene's test.

If your data fails the homogeneity assumption, you need to use a non-parametric test equivalent to the one you wished to perform, otherwise your results will become untrustworthy.


Independence

Having independent data means that your data does not influence each other, so it is understandable that this should not happen in a hypothesis test! Independent data has no relationship between observations. This is controlled via your study design, and you can check for independence using:

  • Durbin-Watson test
  • Contingency table.

What Is This Test For?

A Paired t-test is used to compare the results of an intervention/event/etc. after a period of time has passed. In other words, you use a Paired t-test to compare the same group of participants which have been measured at two different time points.


When to Perform a Paired t-test

When you have a single group of:

  • participants,
  • patients,
  • animals,
  • etc.

and you are observing the effect of an:

  • intervention,
  • occurrence,
  • event,
  • etc. 

then you can use a Paired t-test. 

Your independent variable needs to be your intervention/event/etc. This means that your two groups can be 'before' and 'after', for example.

Your dependent variable needs to be the thing you are measuring, and therefore needs to be continuous data, for example, interval or ratio data. If you have ordinal data, you should consider using a Wilcoxon Signed Rank Test instead.

Your data needs to be parametric (normally distributed, homogeneous and independent), with no significant outliers in the differences between the groups.


SPSS How-To

In SPSS, lay out your data so that your two groups are two variables. Make sure that your data is paired, so that each participant's results are in the same row.

When you are ready to perform the test:

  • go to Analyse at the top, then choose Compare Means and Proportions and Paired-Samples T Test
  • In the dialogue box which pops up, add your two variables into the Paired Variables box, either by using the arrow button or clicking-and-dragging them over.
  • Click the Options button on the right hand side to make sure the Exclude cases analysis by analysis option is selected, and either keep the confidence interval percentage to be 95%, or change it to whatever confidence you require! Click Continue when finished.
  • Click OK

Your output will consist of two tables: the 'Paired Samples Statistics', which contains some descriptive statistics on your data, and the 'Paired Samples Test', which contains the results of your test. 

What Is This Test For?

An Independent (or Unpaired) t-test is used when comparing two population means. A study appropriate for the use of an Independent t-test would involve two separate groups of people, where each participant is involved in one group only (and not both, nor neither!).

As an example, an Independent t-test would be used to compare the percentage of students scoring 6 or more in GCSE Physics of schools in Yorkshire and Leicester: the measurements are the percentage of students, the participants are the schools, and the two groups are Yorkshire and Leicester. 


When To Use An Independent Samples t-test

You can perform an Independent Samples t-test when you have two distinct groups of

  • participants,
  • patients,
  • etc.

and you are observing the difference between them. This means that your independent variable needs to be your two separate groups.

Your dependent variable, like in other t-tests, needs to be the thing you are measuring, and therefore needs to be continuous data, for example, interval or ratio data. If you have ordinal data, you should consider using a Mann-Whitney U Test instead.

Your data needs to be parametric (normally distributed, homogeneous and independent), with no significant outliers in the differences between the groups.


SPSS How-To

In SPSS, lay out your data so that your independent variable (your groups) are one variable, and your dependent variable (the thing you are measuring) is another variable.

When you are ready to perform the test:

  • go to Analyse at the top, then choose Compare Means and Proportions and Independent-Samples T Test
  • In the corresponding dialogue box, add your dependent variable into the Test Variable by either using the arrow or dragging-and-dropping the variable into the box. Then add you independent variable into the Grouping Variable box.
  • Click Define Groups. In the resulting dialogue box, add your groups into the two Group box options.
    • For example, if you have listed your groups as 1 and 2, type '1' into the Group 1 box and '2' into the Group 2 box.
  • Click Continue to close this and go back to the initial dialogue box.
  • Click OK.

Your output will consist of two tables: 'Group Statistics', which contains descriptive statistics about each group you have, and 'Independent Samples Test', which contains the output of the test itself.

The results for the Independent t-test as well as the Welch's t-test are laid out on this table, so you need to read the top line of this table only.

What Is This Test For?

The t-tests discussed so far have been Student's t-tests, which assumes equal standard deviation between groups. Welch's t-test is an equivalent to the Independent Samples t-test, which does not make this assumption.

The Welch's t-test is argued to be the best for Independent Samples rather than Student's Independent Samples t-test, due to its lack of reliance of this assumption, which more likely matches the situation of real life data. Indeed, the Welch's t-test is the default Independent t-test in R.


When to use Welch's t-test

When you wish to use an Independent t-test but your sample sizes and variances are unequal between your groups, use a Welch's t-test instead.

In other words, use a Welch's t-test when your Levene's test comes back significant.


SPSS How-To

SPSS will compute a Welch's t-test at the same time as the Independent t-test, so the only difference is in which line of the 'Independent Samples Test' table you read: if you are assuming equal variance, you are reading the top line and you can completely ignore the bottom line. Otherwise, if you are not assuming equal variance (because the Levene's test is significant), you will need to be using the Welch's t-test and therefore read the bottom row.

What Is This Test For?

A One-Sample t-test is another example of a non-Student t-test, used to compare the mean of a population to one specific value. This value may have come from prior research, or a hypothesised value.

The groups used in this test therefore are:

  • the population you are measuring
  • one single mean value from elsewhere.

How To Recognise When a One-Sample t-test Is Appropriate

You can use a One-Sample t-test when you only have the measurements of one group, and you wish to compare this group's mean to an established (or hypothesised) mean value.


SPSS How-To

In SPSS, lay out your data so that your group measurements fall under one variable.

When you are ready to perform the test:

  • Go to Analyse at the top, then choose Compare Means and Proportions and One-Sample T Test
  • In the dialogue box, move your variable into the Test Variables box, either by using the arrow button to by clicking-and-dragging the variable over into the box.
  • Enter the established/hpothesised mean value you are comparing this group's mean value to in the Test Value box, and ensure the Estimate effect sizes tick-box is checked.
  • Click the Options button on the right hand side to make sure the Exclude cases analysis by analysis option is selected, and either keep the confidence interval percentage to be 95%, or change it to whatever confidence you require!
  • Click Continue to go back to the initial dialogue box.
  • Click OK

Your output will consist of two tables: the 'One Sample Statistics', which contains some descriptive statistics on your group data, and the 'One Sample Test', which contains the results of your test.