# [R] SSQ decomposition and contrasts with ANOVA

From: Jose Claudio Faria <joseclaudio.faria_at_terra.com.br>
Date: Thu 16 Feb 2006 - 14:33:16 EST

Dear R list,

Please, could someone help me with SSQ decomposition and contrasts. Below my data, graphic, ANOVAs and my doubt:

# Data

```a   = paste('a', gl(3, 8), sep='')
b   = paste('b', gl(2, 4, 24), sep='')
tra = sort(paste('t', rep(1:6, 4), sep=''))
y   = c(26.2, 26.0, 25.0, 25.4, 24.8, 24.6, 26.7, 25.2,
25.7, 26.3, 25.1, 26.4, 19.6, 21.1, 19.0, 18.6,
22.8, 19.4, 18.8, 19.2, 19.8, 21.4, 22.8, 21.3)
```
dF = data.frame(a, b, tra, y)

# Graphic
par(mfrow=c(2,1))
interaction.plot(dF\$a, dF\$b, dF\$y,

```                  ylab = 'y', xlab = 'a')

interaction.plot(dF\$b, dF\$a, dF\$y,
ylab = 'y', xlab = 'b')

```

# ANOVAs
av0 = aov(y ~ tra, data=dF)
summary(av0)

av1 = aov(y ~ a*b, data=dF)
summary(av1)

av2 = aov(y ~ a/b, data=dF)
b_a = summary(av2, split = list('a:b' = list(

'b1 vs b2/a1' = 1, 'b1 vs b2/a2' = 2, 'b1 vs b2/a3' = 3))) b_a

av3 = aov(y ~ b/a, data=dF)
a_b = summary(av3, split = list('b:a' = list(

'a/b1' = c(1,3), 'a/b2' = c(2,4)))) a_b

# My doubts
a) How to make the SSQ decomposition to complete the ANOVA below?

```                    Df   Sum Sq Mean Sq F value    Pr(>F)
b                   1   19.082  19.082  14.875  0.001155
b:a                 4  156.622  39.155  30.524 8.438e-08

--------------------------------------------------------
b:a: a/b1         (2) (87.122) 43.561  33.958 7.776e-07

--------------------------------------------------------
a1 vs (a2, a3)   1        ?       ?       ?         ?
a2 vs a3         1        ?       ?       ?         ?

--------------------------------------------------------
b:a: a/b2         (2) (69.500) 34.750  27.090 3.730e-06

--------------------------------------------------------
a1 vs (a2, a3)   1        ?       ?       ?         ?
a2 vs a3         1        ?       ?       ?         ?

--------------------------------------------------------
```
Residuals 18 23.090 1.283

b) How to make the SSQ decomposition to complete the ANOVA below?

```                    Df   Sum Sq Mean Sq F value    Pr(>F)
b                   1   19.082  19.082  14.875  0.001155
b:a                 4  156.622  39.155  30.524 8.438e-08

--------------------------------------------------------
b:a: a/b1         (2) (87.122) 43.561  33.958 7.776e-07

--------------------------------------------------------
a2 vs (a1, a3)   1        ?       ?       ?         ?
a1 vs a3         1        ?       ?       ?         ?

--------------------------------------------------------
b:a: a/b2         (2) (69.500) 34.750  27.090 3.730e-06

--------------------------------------------------------
a2 vs (a1, a3)   1        ?       ?       ?         ?
a1 vs a3         1        ?       ?       ?         ?

--------------------------------------------------------
```
Residuals 18 23.090 1.283

Or, In this case, how can I to test these constrasts?

Thanks for any help,

```--
Jose Claudio Faria
Brasil/Bahia/UESC/DCET
mails:
joseclaudio.faria@terra.com.br
joseclaudio.faria@oi.com.br
jc_faria@uesc.br
jc_faria@uol.com.br
tel: 73-3634.2779

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help