简体   繁体   中英

R: Analyse trends in mixed-effects model

I have a variable yi that represents a treatment effect over time nyears for a bunch of different studies ( Site ). There are also two grouping factors with two levels each: N (Nhigh/Nlow) and Myc (AM/ECM). I need to know if yi shows a significant positive or negative trend over time nyears , and if the trends changes among subgroups N x Myc .

The mixed-effects models shows a significant triple interaction nyears * N * Myc

library(lme4)
library(car)    
> mod <- lmer(yi ~ N*Myc*nyears + (1|Site), data = df)
> Anova(mod)
    Analysis of Deviance Table (Type II Wald chisquare tests)

    Response: yi
                   Chisq Df Pr(>Chisq)   
    N             0.7468  1   0.387489   
    Myc           0.0875  1   0.767403   
    nyears        1.1217  1   0.289559   
    N:Myc         0.5428  1   0.461272   
    N:nyears      2.2371  1   0.134733   
    Myc:nyears    0.6318  1   0.426691   
    N:Myc:nyears 10.8108  1   0.001009 **

How can I now find out the sign of the slope and significance for each of the 4 subgroups?

Thanks

The value of the slope (on nyears , right?) is given by

nyears
nyears + N:nyears
nyears + Myc:nyears
nyears + Myc:nyears + N:Myc:nyears

for the four respective groups. (Are N and Myc numeric 0/1? They don't look like factors, judging by the output. If they aren't 0/1 the recode.)

For significance testing of the slopes, either use linearHypothesis in the CAR package; or you could use eg waldtest in package lmtest ; or rewrite your model so that nyears is the coefficient of interest for each of the four groups. (For example, set Myc equal to 1 minus its old value, if it was a 0/1 dummie.)

I would use the nlme package to code the mixed effects model and then check the output using summary . This will report slopes, signs and p values.

require(nlme)
m1<- lme(yi ~ N*Myc*nyears, random= ~1|Site, data=df)
summary(m1)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM