0

这是我的数据:

subject     arm treat   bline   change
'subject1'  'L' N   6.3597  4.9281
'subject1'  'R' T   10.3499 1.8915
'subject3'  'L' N   12.4108 -0.9008
'subject3'  'R' T   13.2422 -0.7357
'subject4'  'L' T   8.7383  2.756
'subject4'  'R' N   10.8257 -0.531
'subject5'  'L' N   7.1766  2.0536
'subject5'  'R' T   8.1369  1.9841
'subject6'  'L' T   10.3978  9.0743
'subject6'  'R' N   11.3184  3.381
'subject8'  'L' T   10.7251  2.9658
'subject8'  'R' N   10.9818  2.9908
'subject9'  'L' T   7.3745   2.9143
'subject9'  'R' N   9.4863  -3.0847
'subject10' 'L' T   11.8132  -2.1629
'subject10' 'R' N   9.5287   0.1401
'subject11' 'L' T   8.2977   6.2219
'subject11' 'R' N   9.3691   0.7408
'subject12' 'L' T   12.6003  -0.7645
'subject12' 'R' N   11.7329  0.0342
'subject13' 'L' N   9.4918  2.0716
'subject13' 'R' T   9.6205  1.5705
'subject14' 'L' T   9.3945  4.6176
'subject14' 'R' N   11.0176 1.445
'subject16' 'L' T   8.0221  1.4751
'subject16' 'R' N   9.8307  -2.3697

当我将混合模型与treatarm作为因素拟合时:

m <- lmer(change ~ bline + treat + arm + (1|subject), data=change1)
ls_means(m, which = NULL, level=0.95, ddf="Kenward-Roger")

ls_means语句不返回任何结果。任何人都可以帮助解决问题吗?

4

2 回答 2

0

我也看到空结果:

> ls_means(m, which = NULL, level=0.95, ddf="Kenward-Roger")
Least Squares Means table:

     Estimate Std. Error df t value lower upper Pr(>|t|)

  Confidence level: 95%
  Degrees of freedom method: Kenward-Roger 

但是,emmeans包工作正常。您可以使用emmeans()or lsmeans()-- 后者只是重新标记emmeans()结果。“估计边际均值”是一个更普遍适用的术语。

> library(emmeans)
> lsmeans(m, "treat")
 treat lsmean   SE df lower.CL upper.CL
 N      0.996 0.72 15   -0.539     2.53
 T      2.290 0.72 15    0.755     3.82

Results are averaged over the levels of: arm 
Degrees-of-freedom method: kenward-roger 
Confidence level used: 0.95 

> lsmeans(m, "arm")
 arm lsmean    SE   df lower.CL upper.CL
 L     1.97 0.737 15.6    0.403     3.53
 R     1.32 0.737 15.6   -0.248     2.88

Results are averaged over the levels of: treat 
Degrees-of-freedom method: kenward-roger 
Confidence level used: 0.95 

我怀疑它lmerTest::ls_means()不支持“字符”类的预测器。如果你改变treatarm因素,它可能会起作用。

于 2021-04-27T01:24:56.580 回答
0

我们需要更多信息。这是一个看起来很好的可重现示例:

set.seed(101)
library(lme4)
library(lmerTest)
dd <- expand.grid(subject=factor(1:40), arm=c("L","R"))
## replicate N/T in random order for each subject
dd$treat <- c(replicate(40,sample(c("N","T"))))
dd$bline <- rnorm(nrow(dd))
dd$change <- simulate(~bline+treat+arm+(1|subject),
                      newdata=dd,
                      newparams=list(beta=rep(1,4),
                                     theta=1,
                                     sigma=1))[[1]]

m <- lmer(change ~ bline + treat + arm + (1|subject), data=dd)
ls_means(m, which = NULL, level=0.95, ddf="Kenward-Roger")
##  Least Squares Means table:
##  
##      Estimate Std. Error   df t value   lower   upper  Pr(>|t|)    
## armL  1.37494    0.22716 55.6  6.0527 0.91981 1.83007 1.275e-07 ***
## armR  2.54956    0.22716 55.6 11.2235 2.09443 3.00469 6.490e-16 ***

在这一点上我最好的猜测是你在模型拟合方面遇到了一些问题。lmerTest有时可能是不透明/吞咽警告或错误消息。你有没有收到任何你忽略告诉我们的警告?如果您重新运行模型lme4::lmer(...)(即使用 中的基本版本lme4,而不是 中的增强版本lmerTest),您会看到任何警告吗?

于 2021-04-24T00:07:30.423 回答