如何比较r中混合效应模型中交互变量的斜率

How to compare the slope of interaction variables in mixed effect model in r

我想测试岛屿面积和土地利用的影响,以及岛屿面积和土地利用之间的相互作用对物种丰富度的影响。对于土地利用,我分为三组,即森林、农田和混合。数据是基于不同岛屿的横断面,所以岛屿ID设置为随机效应。

我的模型是这样的:

#model = glmer(SR ~ Area + land_use + Area:land_use + (1|islandID))

#summary(model)

Linear mixed model fit by REML. t-tests use Satterthwaite's method ['lmerModLmerTest']
Formula: SR ~ Area + land_use + Area:land_use + (1 | islandID)
Data: transect_ZS

REML criterion at convergence: 184.4

Scaled residuals: 
 Min       1Q   Median       3Q      Max 
-2.66105 -0.56159 -0.00294  0.57259  1.72096 

Random effects:
Groups   Name        Variance Std.Dev.
islandID (Intercept) 0.1524   0.3903  
Residual             0.6805   0.8249  
Number of obs: 70, groups:  islandID, 34

Fixed effects:
                 Estimate Std. Error      df t value Pr(>|t|)   
(Intercept)         -0.9996   0.5187 57.0061  -1.927  0.05893 . 
Area                0.9064    0.2834 40.9977   3.198  0.00267 **
land_useforest      0.6563    0.5569 62.0889   1.179  0.24309   
land_usemix         0.9611    0.6373 55.3032   1.508  0.13723   
Area:land_useforest -0.8318   0.3034 63.4045  -2.742  0.00793 **
Area:land_usemix    -0.7756   0.4748 56.3692  -1.633  0.10795   
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

结果告诉我岛面积和交互项对SR有显着影响:

#    > anova(model)
#Type III Analysis of Variance Table with Satterthwaite's method
#                Sum Sq Mean Sq NumDF  DenDF F value  Pr(>F)  
#Area                 3.0359 3.03590     1 27.448  4.4615 0.04390 *
#land_use             1.5520 0.77601     2 57.617  1.1404 0.32679  
#Area:land_use        5.1658 2.58288     2 60.935  3.7958 0.02795 *
#---
#Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#

然后我用lsmeans函数进行了Tukeys的两两比较:

#lsmeans(model, pairwise ~ Area:land_use, adjust="tukey")
 

结果表明农田和森林的物种丰富度有显着差异,对吧?我想知道这种差异是否应该被视为该模型中耕地和森林之间物种丰富度-面积关系的截距的显着差异?即农田样带的物种丰富度高于森林样带?

#$contrasts
  contrast                                            estimate    SE   df t.ratio p.value
 1.19968425045037 farmland - 1.19968425045037 forest   3.4153 0.288 62.6   1.185  0.0466
 1.19968425045037 farmland - 1.19968425045037 mix     -0.0306 0.426 64.0  -0.072  0.9972
 1.19968425045037 forest - 1.19968425045037 mix       -0.3722 0.377 63.9  -0.987  0.5087

Degrees-of-freedom method: kenward-roger 
P value adjustment: tukey method for comparing a family of 3 estimates 

但是如何检验这个模型中耕地和森林物种丰富度-面积关系的斜率是否有显着差异呢?那就是证明农田样带的物种丰富度-面积关系是否比森林样带更陡峭?

我想你想要

lstrends(model, pairwise ~ land_use, var = "Area", adjust="tukey")

函数lsmeanslstrendsemmeans包中,相当于emmeansemtrends 分别。因此,请查看这些功能的文档。 lsmeans 包只是一个前端。