如何在多项式lmer模型上使用lsmeans进行事后检验(成对比较)?

时间:2017-07-21 01:44:01

标签: r linear-regression lme4 mixed-models lsmeans

现在我有一个二次多项式线性混合效应模型,使用lme4包,有四个固定因子:时间(10个时间点:1-10,多边因子),Age_Group1(成人和儿童),类型(两种语义类型单词:重复和占有粒子)和Word(四个单词,四个音调:T1,T2,T3,T4)和随机因素:参与者。

我想要儿童和成人的音高曲线'跨类型和单词的制作,特别是它们的斜率(线性趋势)和锐度(二次趋势)。

该模型如下:

model <- lmer(Pitch ~ poly(Time,2)*Type*Word*Age_Group+(1|Participant),data = sub_t0_f0_4yrs, REML = F)

我得到的结果是&#34;摘要&#34;功能:

Fixed effects:
                                                          Estimate Std. Error        df t value Pr(>|t|)    
(Intercept)                                                24.7762     0.5283   96.0000  46.897  < 2e-16 ***
poly(Time, 2)1                                           -390.5239    13.4959 6141.0000 -28.937  < 2e-16 ***
poly(Time, 2)2                                           -104.0100    13.4959 6141.0000  -7.707 1.49e-14 ***
TypeReduplicative                                           0.8123     0.2409 6142.0000   3.371 0.000753 ***
WordT2                                                      4.9607     0.2469 6142.0000  20.088  < 2e-16 ***
WordT3                                                      3.2516     0.2425 6142.0000  13.411  < 2e-16 ***
WordT4                                                     -2.3748     0.2436 6141.0000  -9.750  < 2e-16 ***
Age_Group1Adults                                           -7.3116     0.8168   96.0000  -8.952 2.73e-14 ***
poly(Time, 2)1:TypeReduplicative                          115.9732    18.9821 6141.0000   6.110 1.06e-09 ***
poly(Time, 2)2:TypeReduplicative                           21.5677    18.9821 6141.0000   1.136 0.255912    
poly(Time, 2)1:WordT2                                     106.4190    19.4239 6141.0000   5.479 4.45e-08 ***
poly(Time, 2)2:WordT2                                     -13.1036    19.4239 6141.0000  -0.675 0.499949    
poly(Time, 2)1:WordT3                                     362.7334    19.0861 6141.0000  19.005  < 2e-16 ***
poly(Time, 2)2:WordT3                                      42.8257    19.0861 6141.0000   2.244 0.024880 *  
poly(Time, 2)1:WordT4                                      80.1560    19.1942 6141.0000   4.176 3.01e-05 ***
poly(Time, 2)2:WordT4                                      -1.0699    19.1942 6141.0000  -0.056 0.955552    
TypeReduplicative:WordT2                                   -0.7602     0.3439 6142.0000  -2.211 0.027102 *  
TypeReduplicative:WordT3                                   -0.3809     0.3407 6142.0000  -1.118 0.263664    
TypeReduplicative:WordT4                                   -1.2234     0.3437 6142.0000  -3.559 0.000375 ***
poly(Time, 2)1:Age_Group1Adults                            39.1559    20.7488 6141.0000   1.887 0.059188 .  
poly(Time, 2)2:Age_Group1Adults                            30.5261    20.7488 6141.0000   1.471 0.141281    
TypeReduplicative:Age_Group1Adults                         -0.7886     0.3714 6141.0000  -2.123 0.033758 *  
WordT2:Age_Group1Adults                                    -0.7191     0.3753 6142.0000  -1.916 0.055389 .  
WordT3:Age_Group1Adults                                    -1.5218     0.3724 6141.0000  -4.087 4.42e-05 ***
WordT4:Age_Group1Adults                                    -1.0807     0.3731 6141.0000  -2.897 0.003783 ** 
poly(Time, 2)1:TypeReduplicative:WordT2                     0.8514    27.0859 6141.0000   0.031 0.974924    
poly(Time, 2)2:TypeReduplicative:WordT2                   -25.8572    27.0859 6141.0000  -0.955 0.339800    
poly(Time, 2)1:TypeReduplicative:WordT3                  -107.0904    26.8447 6141.0000  -3.989 6.71e-05 ***
poly(Time, 2)2:TypeReduplicative:WordT3                     5.8849    26.8447 6141.0000   0.219 0.826487    
poly(Time, 2)1:TypeReduplicative:WordT4                  -111.4500    27.0717 6141.0000  -4.117 3.89e-05 ***
poly(Time, 2)2:TypeReduplicative:WordT4                   -14.2141    27.0717 6141.0000  -0.525 0.599565    
poly(Time, 2)1:TypeReduplicative:Age_Group1Adults        -116.7790    29.2756 6141.0000  -3.989 6.71e-05 ***
poly(Time, 2)2:TypeReduplicative:Age_Group1Adults         -26.3431    29.2756 6141.0000  -0.900 0.368246    
poly(Time, 2)1:WordT2:Age_Group1Adults                     32.8847    29.5640 6141.0000   1.112 0.266044    
poly(Time, 2)2:WordT2:Age_Group1Adults                     21.4939    29.5640 6141.0000   0.727 0.467237    
poly(Time, 2)1:WordT3:Age_Group1Adults                    -17.5598    29.3432 6141.0000  -0.598 0.549576    
poly(Time, 2)2:WordT3:Age_Group1Adults                     15.0965    29.3432 6141.0000   0.514 0.606934    
poly(Time, 2)1:WordT4:Age_Group1Adults                     -8.2570    29.4136 6141.0000  -0.281 0.778934    
poly(Time, 2)2:WordT4:Age_Group1Adults                     31.1921    29.4136 6141.0000   1.060 0.288975    
TypeReduplicative:WordT2:Age_Group1Adults                   1.2192     0.5273 6141.0000   2.312 0.020792 *  
TypeReduplicative:WordT3:Age_Group1Adults                   2.2395     0.5252 6141.0000   4.264 2.03e-05 ***
TypeReduplicative:WordT4:Age_Group1Adults                   3.7471     0.5271 6141.0000   7.108 1.31e-12 ***
poly(Time, 2)1:TypeReduplicative:WordT2:Age_Group1Adults   14.9473    41.5588 6141.0000   0.360 0.719109    
poly(Time, 2)2:TypeReduplicative:WordT2:Age_Group1Adults  -26.2315    41.5588 6141.0000  -0.631 0.527940    
poly(Time, 2)1:TypeReduplicative:WordT3:Age_Group1Adults  127.8737    41.4020 6141.0000   3.089 0.002020 ** 
poly(Time, 2)2:TypeReduplicative:WordT3:Age_Group1Adults   15.8382    41.4020 6141.0000   0.383 0.702069    
poly(Time, 2)1:TypeReduplicative:WordT4:Age_Group1Adults  137.2644    41.5495 6141.0000   3.304 0.000960 ***
poly(Time, 2)2:TypeReduplicative:WordT4:Age_Group1Adults  -23.2233    41.5495 6141.0000  -0.559 0.576229 

很明显,Word Type和Age_Group之间存在重要的三方互动。我通常会进行事后测试,以便在不同条件下比较成人和儿童,例如:

 lsmeans (model, pairwise ~ Age_Group1|Words*Type*Time)

我得到了:

 $contrasts
 Type = Possessive, Word = T1, Time = 5.5:
  contrast      estimate        SE     df t.ratio p.value
  4yrs - Adults 7.751045 0.8696730 122.81   8.913  <.0001

 Type = Reduplicative, Word = T1, Time = 5.5:
  contrast      estimate        SE     df t.ratio p.value
  4yrs - Adults 8.160387 0.8687632 122.30   9.393  <.0001

 Type = Possessive, Word = T2, Time = 5.5:
  contrast      estimate        SE     df t.ratio p.value
  4yrs - Adults 8.779598 0.8726068 124.46  10.061  <.0001

 Type = Reduplicative, Word = T2, Time = 5.5:
  contrast      estimate        SE     df t.ratio p.value
  4yrs - Adults 7.592119 0.8687632 122.30   8.739  <.0001

 Type = Possessive, Word = T3, Time = 5.5:
  contrast      estimate        SE     df t.ratio p.value
  4yrs - Adults 9.490212 0.8696530 122.80  10.913  <.0001

 Type = Reduplicative, Word = T3, Time = 5.5:
  contrast      estimate        SE     df t.ratio p.value
  4yrs - Adults 7.888047 0.8687632 122.30   9.080  <.0001

 Type = Possessive, Word = T4, Time = 5.5:
  contrast      estimate        SE     df t.ratio p.value
  4yrs - Adults 9.280836 0.8706023 123.33  10.660  <.0001

 Type = Reduplicative, Word = T4, Time = 5.5:
  contrast      estimate        SE     df t.ratio p.value
  4yrs - Adults 5.608742 0.8705994 123.33   6.442  <.0001

只比较成人和儿童的截距,而不是像汇总函数那样的线性和二次参数。 所以我想知道如何比较线性趋势:poly(时间,2)1和四元趋势:成人和孩子之间的poly(时间,2)2,是否有任何解决方案?

1 个答案:

答案 0 :(得分:0)

您可以使用 lsmeans 包中提供的多项式对比来完成此操作;然后产生交互对比(对比的对比)。在第一步中,您必须使用at来指定Time的不同级别,因为它是一个协变量,默认情况下它会降低到它的平均值(在您的情况下为5.5)。

model.lsm <- lsmeans(model, ~ Time * Age_Group1 | Words * Type, 
                            at = list(Time = .5 + 4:6))
model.lsm   # show the estimates)

contrast(model.lsm, interaction = c("poly", "pairwise"))

请注意,"poly"规范会在Time的指定级别之间创建正交多项式对比。它们的缩放比模型中的正交缩放poly()项不同。在创建model.lsm时,您可以使用at = list(Time = 1:10)(或等效cov.reduce = FALSE)来包含Time的所有级别。然而,它会产生对比度达到6度(由于你的模型,估计为零的第三个)。如果仅显示三个值,您将获得相同的P值,但不会出现混乱。

有关详细信息,请参阅contrast的帮助页面。