[R-sig-ME] Problems using Anova functions 'type = 2' or 'type = 3' from car package with lme

Julian Gaviria Lopez Ju||@n@G@v|r|@Lopez @end|ng |rom un|ge@ch
Mon Oct 28 12:23:14 CET 2019


Hi Mario,


Glad to hear you found the solution.  Unfortunately I can not validate it, since I am not a stats expert. I was  thinking that maybe the emmeans package could help you for the post-hoc contrasts, and the interaction analysis:

https://cran.rstudio.com/web/packages/emmeans/vignettes/interactions.html


P.D. The statistician from my dept.  encourages us to work always with ANOVA type II.  Maybe further information about it might be found not here,  but in another list, such as stack overflow.


Best,

Julian Gaviria
Neurology and Imaging of cognition lab (Labnic)
University of Geneva. Campus Biotech.
9 Chemin des Mines, 1202 Geneva, CH
Tel: +41 22 379 0380
Email: Julian.GaviriaLopez using unige.ch
________________________________
From: R-sig-mixed-models <r-sig-mixed-models-bounces using r-project.org> on behalf of Mario Garrido <gaadio using post.bgu.ac.il>
Sent: Monday, October 28, 2019 11:18:44 AM
To: r-sig-mixed-models using r-project.org
Subject: Re: [R-sig-ME] Problems using Anova functions 'type = 2' or 'type = 3' from car package with lme

Hi,
I think I have found the solution using:
anova.lme(model,type = "sequential") # same results as anova(model); it
seems logical, since Type I is sequential
anova.lme(model,type = "marginal") # as far as I know, sorry of Im wrong,
Type III is also called marginal

Cheers!

El lun., 28 oct. 2019 a las 10:33, Mario Garrido (<gaadio using post.bgu.ac.il>)
escribi�:

> 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!
>


--
Mario Garrido Escudero, PhD
Dr. Hadas Hawlena Lab
Mitrani Department of Desert Ecology
Jacob Blaustein Institutes for Desert Research
Ben-Gurion University of the Negev
Midreshet Ben-Gurion 84990 ISRAEL

gaiarrido using gmail.com; gaadio using post.bgu.ac.il
phone: (+972) 08-659-6854

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-mixed-models using r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models

	[[alternative HTML version deleted]]



More information about the R-sig-mixed-models mailing list