Welch test for the difference in means (2 samples, unequal variances)

Enter the name for this tabbed section: Description
This test is used to establish whether two samples have been extracted from populations that have the same mean and unknown and assumed different variances
From a biologist standpoint, it is possibly the most commonly performed test in experimental biology.
The test calculates the variance of the sampling distribution as a weighted mean of the variances of the two population estimated from their samples.
To take into consideration large variance of the sampling distribution of the mean (in comparison to the same test with equal variances), the degrees of freedom are reduced according to a formula developed by Welsh.
If the two samples provides identical estimates of the population variances, the converge towards a t-test with equal variances.
Enter the name for this tabbed section: R Syntax
In R, the test can be performed using two main syntax of the same function:

t.test{stats}

t.test(var1,var2,var.equal = FALSE, alternative = c(“two.sided, “less”, “greater”), paired = TRUE/FALSE)
or
t.test(var ~ factor, data = dataframe, var.equal = FALSE, alternative = c(“two.sided, “less”, “greater”), paired = TRUE/FALSE)
  • var.equal = TRUE / FALSE defines either this test (FALSE), the Welch test, or Student t-test with equal variances (TRUE).
  • alternative = one of “two.sided”, “less”, “greater”. The parameters defines to define the type of alternative hypothesis to be used: two.sided for bilateral test and “greater” or “less” for unilateral tests.
  • the paired indicates whether elements of the samples are linked.
Enter the name for this tabbed section: Code Example

The Welch test is a variant of the t.test and uses the same syntax. The main difference lies in the parameter var.equal = FALSE, in the body of the function.

# Lets create two variables Vw1 and vw2 corresponding to two samples
#
vw1 <- c(175, 162, 168, 190, 141, 181, 182, 194, 174, 179)
vw2 <- c(165, 169, 163, 163, 158, 166, 165, 154)

# We can compare the variances of the two populations estimated by their samples:
varvw1 <- var(vw1)
varvw2 <- var(vw2)
varvw1
## [1] 228.9333
varvw2
## [1] 22.69643
#  We can now carry out the t-test (assuming equality of variance)
#
t.test(vw1,vw2, var.equal = FALSE, alternative = "two.sided")
## 
##  Welch Two Sample t-test
## 
## data:  vw1 and vw2
## t = 2.3115, df = 11.149, p-value = 0.0409
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##   0.5786193 22.8713807
## sample estimates:
## mean of x mean of y 
##   174.600   162.875

Note in the example above, that had we applied the uncorrected equal variance test, the numbers of degrees of freedom would have been n1 + n2 -2 = 16. Because of the inequality in variance of the two samples (as estimates of the population variances), the degrees of freedom are strongly reduced to 11.