t test formula

This article has been updated, you are now consulting an old release of this article!

Introduction to Student’s t-test

Student t-test is a statistical test which is widely used to compare the mean of two groups of samples. It is therefore to evaluate whether the means of the two sets of data are statistically significantly different from each other.

There are many types of Student’s t-test :

  • The one-sample t-test, used to compare the mean of a population with a theoretical value.
  • The unpaired two sample t-test, used to compare the mean of two independent groups of samples.
  • The paired t-test, used to compare the means between two related groups of samples.

The aim of this article is to describe the formulas of the different types of Student’s t-test. Student’s t-test is a parametric test as the formulas depends on the mean and the standard deviation of the data being compared.

Note that an online software is available here to calculate Student’s t-test without any installation.

One-sample t-test

As mentioned above, one-sample t-test is used to compare the mean of a population to a specified theoretical mean (\(\mu\)).

Let X represents a set of values with size n, with mean m and with standard deviation S. The comparison of the observed mean (m) of the population to a theoretical value \(\mu\) is performed with the formula below :

\[ t = \frac{m-\mu}{s/\sqrt{n}} \]

To evaluate whether the difference is statistically significant, you first have to read in t table the critical value of Student’s t distribution corresponding to the significance level alpha of your choice (5%). The degrees of freedom (df) used in this test are :

\[ df = n - 1 \]

If the absolute value of the t statistic (|t|) is greater than the critical value, then the difference is significant. Otherwise it isn’t. The level of significance or (p-value) corresponds to the risk indicated by the t table for the calculated |t| value.

The test can be used only when the data is normally distributed.

Independent (or unpaired) two sample t-test

What is unpaired t-test ?

Unpaired two sample t-test is used to compare the means of two unrelated groups of samples.

As an example, we have a cohort of 100 individuals (50 women and 50 men). The question is to test whether the average weight of women is significantly different from that of men?

In this case, we have two independents groups of samples and unpaired Student’s t-test can be used to test whether the means are different.

Formula

  • Let A and B represent the two groups to compare.
  • Let \(m_A\) and \(m_B\) represent the means of groups A and B, respectively.
  • Let \(n_A\) and \(n_B\) represent the sizes of group A and B, respectively.

The Student’s t statistic value to test whether the means are different can be calculated as follow :

\[ t = \frac{m_A - m_B}{\sqrt{ \frac{S^2}{n_A} + \frac{S^2}{n_B} }} \]

\(S^2\) is an estimator of the common variance of the two samples. It can be calculated as follow :

\[ S^2 = \frac{\sum{(x-m_A)^2}+\sum{(x-m_B)^2}}{n_A+n_B-2} \]

Once t value is determined, you have to read in t table the critical value of Student’s t distribution corresponding to the significance level alpha of your choice (5%). The degrees of freedom (df) used in this test are :

\[ df = n_A + n_B -2 \]

If the absolute value of the t statistic (|t|) is greater than the critical value, then the difference is significant. Otherwise it isn’t. The level of significance or (p-value) corresponds to the risk indicated by the t table for the calculated |t| value.

The test can be used only when the two groups of samples (A and B) being compared follow bivariate normal distribution with equal variances.

If the variances of the two groups being compared are different, the Welch t test can be used.

Dependent Student’s t-test for paired samples

What is paired Student’s t-test ?

Paired Student’s t-test is used to compare the means of two related samples. That is when you have two values (pair of values) for the same samples.

For example, 20 mice received a treatment X for 3 months. The question is to test whether the treatment X has an impact on the weight of the mice at the end of the 3 months treatment. The weight of the 20 mice has been measured before and after the treatment. This gives us 20 sets of values before treatment and 20 sets of values after treatment from measuring twice the weight of the same mice.

In this case, paired Student’s t-test can be used as the two sets of values being compared are related. We have a pair of values for each mouse (one before and the other after treatment).

Formula

To compare the means of the two paired sets of data, the differences between all pairs must be, first, calculated.

Let d represent the differences between all pairs. The average of the difference d is compared to 0. If there is any significant difference between the two pairs of samples, then the mean of d is expected to be far from 0.

t statistic value can be calculated as follow :

\[ t = \frac{m}{s/\sqrt{n}} \]

m and s are the mean and the standard deviation of the difference (d), respectively. n is the size of d.

Once t value is determined, you have to read in t table the critical value of Student’s t distribution corresponding to the significance level alpha of your choice (5%). The degrees of freedom (df) used in this test are :

\[ df = n - 1 \]

If the absolute value of the t statistic (|t|) is greater than the critical value, then the difference is significant. Otherwise it isn’t. The level of significance or (p-value) corresponds to the risk indicated by the t table for the calculated |t| value.

The test can be used only when the difference d is normally distributed.

Online Student’s t-test

You no longer need SPSS or Excel to perform Student t-test.

An online calculator software is available here to perform Student’s t-test without any installation.

Depending on the types of Student’s t-test you want to do, click the following links :

Infos

This analysis has been done using R (ver. 3.1.0).


Enjoyed this article? I’d be very grateful if you’d help it spread by emailing it to a friend, or sharing it on Twitter, Facebook or Linked In.

Show me some love with the like buttons below... Thank you and please don't forget to share and comment below!!
Avez vous aimé cet article? Je vous serais très reconnaissant si vous aidiez à sa diffusion en l'envoyant par courriel à un ami ou en le partageant sur Twitter, Facebook ou Linked In.

Montrez-moi un peu d'amour avec les like ci-dessous ... Merci et n'oubliez pas, s'il vous plaît, de partager et de commenter ci-dessous!