简体   繁体   English

R:分析混合效应模型的趋势

[英]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 ). 我有一个变量yi ,代表了一系列不同研究( Site )随时间推移nyears的治疗效果。 There are also two grouping factors with two levels each: N (Nhigh/Nlow) and Myc (AM/ECM). 还有两个分组因子,每个分组因子具有两个级别: N (Nhigh / Nlow)和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 . 我需要知道yi在过去nyears是否显示出显着的正或负趋势,以及该趋势是否在子组N x Myc之间变化。

The mixed-effects models shows a significant triple interaction nyears * N * Myc 混合效应模型显示显著三重互动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? 我现在如何找出4个子组中每个子组的斜率和重要性的符号?

Thanks 谢谢

The value of the slope (on nyears , right?) is given by 斜率的值(以nyears ,对吗?)由

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.) NMyc数字是否为0/1?根据输出判断,它们看起来不是因子。如果不是0/1,则重新编码。)

For significance testing of the slopes, either use linearHypothesis in the CAR package; 对于斜率的显着性检验,可以在CAR包装中使用linearHypothesis or you could use eg waldtest in package lmtest ; 或者您可以在lmtest软件包中使用waldtest or rewrite your model so that nyears is the coefficient of interest for each of the four groups. 或重写您的模型,使nyears是四个组中每个组的兴趣系数。 (For example, set Myc equal to 1 minus its old value, if it was a 0/1 dummie.) (例如,将Myc设置为1减去它的旧值(如果它是0/1的假人)。)

I would use the nlme package to code the mixed effects model and then check the output using summary . 我将使用nlme包对混合效果模型进行编码,然后使用summary检查输出。 This will report slopes, signs and p values. 这将报告斜率,符号和p值。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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