# [R] question about linear models.

ivan.borozan@utoronto.ca ivan.borozan at utoronto.ca
Mon Apr 19 19:30:55 CEST 2004

```hi there,

i have the following table with two factors A, B each respectively with 3 and 4
levels (unbalanced design)

>S1
samples A B
1  1.3398553 0 0
2  0.8455924 0 0
3  1.0290893 0 0
4  1.2720512 0 0
5  1.2071754 0 0
6  1.1859539 0 0
7  2.7399659 2 3
8  1.2476911 2 3
9  2.6389479 2 2
10 1.6914068 1 2
11 2.2260561 2 1
12 1.2955187 1 1
13 1.6526140 1 3
14 2.3159151 2 3
15 2.3905009 1 2
16 2.9520105 2 2
17 1.9478868 1 1
18 1.9936118 1 1
19 1.3775338 1 3
20 1.9638190 2 2
21 1.4697860 1 2
22 2.2028858 2 3
23 2.4024771 2 1
24 1.9935864 1 1

i fit two different models

fit1<-aov(samples~A + B,data=S1,contrasts = list(A = contr.treatment, B =
contr.treatment))
fit2<-aov(samples~A,data=S1,contrasts = list(A = contr.treatment))
fit3<-aov(samples~B,data=S1,contrasts = list(B = contr.treatment))

and using

>anova(fit1,fit2)
Analysis of Variance Table

Model 1: samples ~ A + B
Model 2: samples ~ A
Res.Df      RSS Df Sum of Sq      F Pr(>F)
1     19  2.74820
2     21  3.14667 -2  -0.39847 1.3774 0.2763

i get B as not significant and

>anova(fit1,fit3)

Analysis of Variance Table

Model 1: samples ~ A + B
Model 2: samples ~ B
Res.Df     RSS Df Sum of Sq      F   Pr(>F)
1     19  2.7482
2     20  4.2391 -1   -1.4909 10.308 0.004604 **

A as significant.

however if i do

>anova(fit3)

Analysis of Variance Table

Response: samples
Df Sum Sq Mean Sq F value   Pr(>F)
B          3 3.7241  1.2414  5.8567 0.004854 **
Residuals 20 4.2391  0.2120

i get B as significant and

>anova(fit2)

Analysis of Variance Table

Response: samples
Df Sum Sq Mean Sq F value    Pr(>F)
A          2 4.8165  2.4083  16.072 5.835e-05 ***
Residuals 21 3.1467  0.1498

A as significant.

Should i conclude that A is significant and B is not or rather that both factors
are significant ?

all the best

```