Are one-way ANOVA and t-test equivalent?

Yes. Assume we know the variance \sigma. Let t be the t-test statistic and F be the one-way ANOVA statistic. One can reasonably easly show that t^2 = F. Therefore, for a two-sided test corresponding quantiles are equivalent. However, there is no equivalent one-sided test in anova since we are looking at a ‘squared’ value.

# generate some data
A = rnorm(10,0)
B = rnorm(10,0,2)

# change it to the format which we can use for lm
C = rbind(cbind(A,1),cbind(B,2))
colnames(C) = c("value", "group")
C = data.frame(C)

# run tests
M1 = t.test(A,B,var.equal = TRUE)
M2 = anova(lm(value ~ group ,C))

# compare p-values

As we can see, p-values are equal. Note however, that ANOVA is run on the linear model, whereas t-test compares two groups. Although they are equivalent in this context, they are used differently and they are based on different principles.

For ANOVA we brought the data to another format

         value group
1  -1.22252768     1
10 -1.27401195     1
11  1.64572910     2
20 -0.79178332     2

so that we can run lm() method. The model in this example is
\text{group} = \beta \text{value} + \varepsilon.

We estimate \hat \beta by lm() and, using anova(), we test if \beta = 0, which intuitively corresponds to no significance of the group variable. This is a vary different approach than t-test, but, as mentioned in the beginning of this post, it leads to exactly the same result.

Finally, note that in R we also have a function oneway.test which embraces all these functionalities:

  • If number of groups is 2 it runs t-test,
  • If number of groups is larger 2 it runs ANOVA,
  • In both cases it estimates variances if needed.

So, in this example, we can have

M3 = oneway.test(value ~ group, data=C, var.equal = TRUE)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>