# [R] null hypothesis for two-way anova

Axel Rasche axel_rasche at gmx.de
Sun Aug 5 13:00:53 CEST 2007

```Dear R community,

Confused by some of my lab results I ask for the definition of the null
hypothesis of a two-way analysis of variance in R (anova() and aov()).
Starting with the following model
y = a_i + b_j , i in A and j in B
is the tested null hypothesis
H_0: a_i = 0  for all i in A
or
H_0: a_m = a_n  for any m and n in A?

Consequently the same questions for interaction effects. Starting with
the model
y = a_i + b_j + f_ij , i in A and j in B
is the tested null hypothesis
H_0: f_ij = 0  for all i in A and j in B
or
H_0: f_ij = f_mn  for any i and m in A and j and n in B?

More specific to R the questions is formulated as R code in the
appendix. Unfortunately I did not find this in the documentation.

Axel

Appendix:
=========

> A = factor(c(rep(1, 10), rep(0, 5)))
> B = factor(c(rep(0, 5), rep(1, 10)))
> y = c(rnorm(n = 5, mean = 2, sd = 1), rnorm(n = 5, mean = 6, sd = 1),
rnorm(n = 5, mean = 4, sd = 1))
> anova(lm(formula = y ~ 1 + A + B, data = data.frame(y, A, B)))
Analysis of Variance Table

Response: y
Df Sum Sq Mean Sq F value   Pr(>F)
A          1  5.041   5.041  5.5601  0.03618 *
B          1 58.643  58.643 64.6851 3.56e-06 ***
Residuals 12 10.879   0.907
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Which null hypothesis has been tested for the P-value in the fifth
column of the output ("Pr(>F)")? For example the P-value 0.03618 for
factor A.

> y = c(rnorm(n = 5, mean = 2, sd = 1), rnorm(n = 5, mean = 10, sd =
1), rnorm(n = 5, mean = 4, sd = 1))
> anova(lm(formula = y ~ 1 + A + B + A:B, data = data.frame(y, A, B)))
Analysis of Variance Table

Response: y
Df  Sum Sq Mean Sq F value    Pr(>F)
A          1   9.235   9.235  5.3243   0.03966 *
B          1 129.623 129.623 74.7321 1.686e-06 ***
Residuals 12  20.814   1.734
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

How do I draw a P-value for the interaction effect for the anova?

> sessionInfo()
Version 2.3.1 (2006-06-01)
i386-pc-mingw32

attached base packages:
 "methods"   "stats"     "graphics"  "grDevices" "utils"
"datasets"  "base"

--
*******************************************
Dipl. Math. ETH Axel Rasche
Max-Planck-Institute for Molecular Genetics
Department Lehrach (Vertebrate Genomics)
Ihnestrasse 63-73
D-14195 Berlin-Dahlem
GERMANY

Tel. ++49-30-8413-1647
Fax  ++49-30-8413-1128

```