[R] type III ANOVA for a nested linear model
Mendiburu, Felipe (CIP)
F.MENDIBURU at CGIAR.ORG
Thu Jul 12 16:08:08 CEST 2007
Dear Carsten
In this test, factor B would be representing to a factor of block or repetition according to as the levels of A, B, and C are in the data. Factor C this nested in A, then the model should include: B, A and C nested in A, the difference it is the error.
Model:
B 1
A 2
C(A) 6
Error (2+6)*1 = 8
Total
mydata<-read.table("mydata.txt",header=T)
mydata[,1]<- as.factor(mydata[,1])
mydata[,2]<- as.factor(mydata[,2])
mydata[,3]<- as.factor(mydata[,3])
model <- aov(resp ~ B + A + C/A, mydata)
summary(model)
Df Sum Sq Mean Sq F value Pr(>F)
B 1 915.21 915.21 89.6476 1.274e-05 ***
A 2 33.12 16.56 1.6223 0.25621
C 6 199.50 33.25 3.2570 0.06316 .
Residuals 8 81.67 10.21
Best regards,
Felipe de Mendiburu
Statistician
-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch]On Behalf Of Carsten Jaeger
Sent: Tuesday, July 10, 2007 6:15 AM
To: R help list
Subject: [R] type III ANOVA for a nested linear model
Hello,
is it possible to obtain type III sums of squares for a nested model as
in the following:
lmod <- lm(resp ~ A * B + (C %in% A), mydata))
I have tried
library(car)
Anova(lmod, type="III")
but this gives me an error (and I also understand from the documentation
of Anova as well as from a previous request
(http://finzi.psych.upenn.edu/R/Rhelp02a/archive/64477.html) that it is
not possible to specify nested models with car's Anova).
anova(lmod) works, of course.
My data (given below) is balanced so I expect the results to be similar
for both type I and type III sums of squares. But are they *exactly* the
same? The editor of the journal which I'm sending my manuscript to
requests what he calls "conventional" type III tests and I'm not sure if
can convince him to accept my type I analysis.
R> mydata
A B C resp
1 1 1 1 34.12
2 1 1 2 32.45
3 1 1 3 44.55
4 1 2 1 20.88
5 1 2 2 22.32
6 1 2 3 27.71
7 2 1 6 38.20
8 2 1 7 31.62
9 2 1 8 38.71
10 2 2 6 18.93
11 2 2 7 20.57
12 2 2 8 31.55
13 3 1 9 40.81
14 3 1 10 42.23
15 3 1 11 41.26
16 3 2 9 28.41
17 3 2 10 24.07
18 3 2 11 21.16
Thanks a lot,
Carsten
______________________________________________
R-help at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list