# [R] Function to separate effect in AOV

Ronaldo Reis Junior chrysopa at gmail.com
Tue Jul 24 00:04:55 CEST 2007

```Hi,

I have a dummy question.

Suppose that I have two explanatory variable, T1 (A, B) and T2 (C, D) and one
response variable.

> tapply(Y,list(T1,T2),mean)
C        D
A 2.200000 10.20000
B 2.223333 20.26667

In this case, "A" and "B" inside "C" have no difference, but have differences
inside "D"

I make this model:

> m <- aov(Y~T1*T2)
>
> summary(m)
Df Sum Sq Mean Sq F value    Pr(>F)
T1           1  76.36   76.36  5617.9 1.119e-12 ***
T2           1 508.69  508.69 37426.7 5.704e-16 ***
T1:T2        1  75.65   75.65  5566.0 1.161e-12 ***
Residuals    8   0.11    0.01
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

This result don't show the reality of the data, because I cant see that "A"
and "B" inside "C" are the same.

The anova result is the same of an full different levels, like this:

>
> tapply(Y,list(T1,T2),mean)
C        D
A 6.100000 10.20000
B 2.223333 20.26667
>
> m <- aov(Y~T1*T2)
>
> summary(m)
Df Sum Sq Mean Sq F value    Pr(>F)
T1           1  28.74   28.74  2114.3 5.529e-11 ***
T2           1 367.75  367.75 27056.7 2.088e-15 ***
T1:T2        1 145.81  145.81 10728.1 8.433e-14 ***
Residuals    8   0.11    0.01
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

In this case all level are different, C to D and A to B.

The question is:

The only way to find this real difference is:

1) make T1 and T2 like a Treatment variable with 4 levels (AC,BC,AD,BD)?

or

2) make 3 anova:
a) Anova (A,B) inside C
b) Anova (A,B) inside D
c) Full factorial Anova (like this in the e-mail)

or

3) exist any other way to make this in only one analysis, to find all
differences e interactions? In other words, to find differences in "A"
and "B" inside "C", "A" and "B" inside "D", "C" and "D" inside "A" and "C"
and "D" inside "B"

Thanks
Ronaldo
--
> Prof. Ronaldo Reis Júnior
|  .''`. UNIMONTES/Depto. Biologia Geral/Lab. de Ecologia
| : :'  : Campus Universitário Prof. Darcy Ribeiro, Vila Mauricéia
| `. `'` CP: 126, CEP: 39401-089, Montes Claros - MG - Brasil
|   `- Fone: (38) 3229-8187 | ronaldo.reis em unimontes.br | chrysopa em gmail.com
| http://www.ppgcb.unimontes.br/ | ICQ#: 5692561 | LinuxUser#: 205366

```