[R-sig-ME] Problems using Anova functions 'type = 2' or 'type = 3' from car package with lme
Mario Garrido
g@@d|o @end|ng |rom po@t@bgu@@c@||
Mon Oct 28 10:33:02 CET 2019
Hello,
I use lme to create a linear mixed effects model with three fixed factors
(Treatment, species and Period) and one random factor (individual identity,
ExpID).
After creating the model, I tried to apply Anova from car package to
compute results with both Type II and III Sum of Squares, but I get the
error stated below:
I have UNBALANCED data, more data from sp1 than for the others
These are the data types.
> str(Data)
'data.frame': 496 obs. of 27 variables:
$ Trtmnt2 : Factor w/ 2 levels "Control","Treated": 2 2 2 2 2 2 2 2 1
1 ...
$ ExpID : Factor w/ 62 levels "EA1","EA10","EA11",..: 1 1 1 1 1 1 1
1 10 10 ...
$ sp : Factor w/ 3 levels "sp1","sp2","sp3": 2 2 2 2 2 2 2 2 2 2
...
$ Period : Factor w/ 5 levels "Before","earlypeak",..: 1 5 2 4 3 5 4
3 1 2 ...
$ StdzDiff : num -51.1 -53.2 -49 22.9 ...
Here is the code to generate the model
> library(car)
> options(contrasts = c("contr.sum", "contr.poly"))
> model<- lme(StdzDiff ~ Trtmnt2*sp*Period, data = Data, random = ~
1|factor(ExpID))
> Anova(model, type=2) #with type = 3, I have the same problems
Error in I.p[subs.relatives, , drop = FALSE] :
subscript out of bounds
I have no problems with 'default' anova. But, I get the same error working
with the following code
model<- lme(StdzDiff ~ Trtmnt2*sp*Period, data =
DataFreqDark_StdzDiff_peakAll, random = ~
1|factor(ExpID),contrasts=list(Trtmnt2=contr.sum, sp=contr.sum,
Period=contr.sum))
My questions:
1) What is my error?
2) If Anova from car cannot deal with lme, how can I apply Type III to my
model?
3) To confirm, if I define nothing, anova with lme, is type I by default?
Thanks!
[[alternative HTML version deleted]]
More information about the R-sig-mixed-models
mailing list