close
close
two sample t test formula

two sample t test formula

3 min read 13-03-2025
two sample t test formula

The two-sample t-test is a fundamental statistical tool used to determine if there's a significant difference between the means of two independent groups. Understanding its formula is crucial for interpreting results and making informed decisions based on your data. This article will break down the formula, explain its components, and illustrate its application.

The Formula Unveiled: Two-Sample T-Test

There are two versions of the two-sample t-test formula, one assuming equal variances between the two groups and the other assuming unequal variances. Let's examine both:

1. Two-Sample T-Test Assuming Equal Variances (Pooled Variance)

This test is used when you have reason to believe that the variances (spreads) of the two populations are approximately equal. The formula is:

t = (M₁ - M₂) / √[(s²p/n₁) + (s²p/n₂)]

Where:

  • t: The calculated t-statistic. This value will be compared to a critical t-value from a t-distribution table to determine significance.

  • M₁: The mean of the first group.

  • M₂: The mean of the second group.

  • s²p: The pooled variance. This is a weighted average of the variances of the two groups, calculated as:

    s²p = [(n₁ - 1)s₁² + (n₂ - 1)s₂²] / (n₁ + n₂ - 2)

  • s₁²: The variance of the first group.

  • s₂²: The variance of the second group.

  • n₁: The sample size of the first group.

  • n₂: The sample size of the second group.

2. Two-Sample T-Test Assuming Unequal Variances (Welch's t-test)

This test is more robust and should be used when you suspect the population variances are unequal, or when you don't have strong evidence suggesting they are equal. The formula is slightly more complex:

t = (M₁ - M₂) / √[(s₁²/n₁) + (s₂²/n₂)]

Where:

  • t: The calculated t-statistic (as above).
  • M₁: The mean of the first group.
  • M₂: The mean of the second group.
  • s₁²: The variance of the first group.
  • s₂²: The variance of the second group.
  • n₁: The sample size of the first group.
  • n₂: The sample size of the second group.

Note: The key difference is that Welch's t-test doesn't pool the variances. This makes it more appropriate when dealing with unequal variances.

Interpreting the T-Statistic

Once you've calculated the t-statistic using either formula, you'll need to compare it to a critical t-value. This critical value is obtained from a t-distribution table based on:

  • Degrees of freedom (df): For the equal variances test, df = n₁ + n₂ - 2. For Welch's t-test, the calculation of degrees of freedom is more complex and usually obtained from statistical software.
  • Significance level (alpha): Typically set at 0.05 (5%).

If the absolute value of your calculated t-statistic is greater than the critical t-value, you reject the null hypothesis (that there's no significant difference between the means). This suggests a statistically significant difference between the two groups.

Example Calculation (Equal Variances)

Let's say we have two groups:

  • Group A: Mean (M₁) = 10, Variance (s₁²) = 4, Sample size (n₁) = 25
  • Group B: Mean (M₂) = 12, Variance (s₂²) = 5, Sample size (n₂) = 30
  1. Calculate the pooled variance (s²p):

    s²p = [(25 - 1) * 4 + (30 - 1) * 5] / (25 + 30 - 2) = 4.47

  2. Calculate the t-statistic:

    t = (10 - 12) / √[(4.47/25) + (4.47/30)] = -4.58

  3. Determine degrees of freedom:

    df = 25 + 30 - 2 = 53

  4. Compare to critical t-value: Using a t-distribution table with df = 53 and alpha = 0.05 (two-tailed test), the critical t-value is approximately ±2.006.

Since |-4.58| > 2.006, we reject the null hypothesis. There's a statistically significant difference between the means of Group A and Group B.

When to Use Which Test

Choosing between the equal variances and unequal variances t-test depends on the nature of your data. If you have a strong reason to believe the variances are equal (e.g., based on prior knowledge or a formal test of variance equality like Levene's test), use the equal variances test. Otherwise, it's safer and more robust to use Welch's t-test (unequal variances). Statistical software packages typically offer both options and often automatically select the appropriate test based on the data. Always consider the assumptions underlying each test before drawing conclusions.

Related Posts