如何在 R 包 lmerTest 中的 lmer() 函数的估计值中显示更多小数?

问题描述 投票:0回答:3

我想使用 lmerTest R 包测试固定和随机效应。使用 lmer() 定义模型后,我使用summary() 来获取结果。对于我的结果报告,我想显示更多小数点的 AIC 和 BIC、随机效应中的方差和标准差、估计值和标准误差(参见图片: my output summary(lmer) with missing/few decimals)。

我已经尝试过但没有帮助的事情:

  1. 更改常规 R 选项
options(digits=3)
  1. 更改summary()或coef(summary())中的选项
summary(lmer, digits=3)
coef(summary(lmer), digits=3)
  1. 使用 round() 作为 summary() 或 coef(summary())
round(summary(lmer), digits=3)
round(coef(summary(lmer)), digits=3)
  1. 在 lmerTest R 包手册中搜索术语“数字”和“小数”
r decimal digits lmertest
3个回答
1
投票

实现此目的的一种方法是加载

jtools
包并使用
options( "jtools-digits" = 3 )
。调用模型结果时,请使用
summ
函数查看它们。


1
投票

目前无法调整 AIC 等打印的数字设置。您可以使用内部功能对此进行破解:

lme4:::.prt.aictab(summary(model)$AICtab, digits = 10)
         AIC          BIC       logLik     deviance     df.resid 
1763.9393445 1783.0970856 -875.9696722 1751.9393445          174 

全局

digits
选项应该会影响
coef(summary(.))
的打印:

options(digits = 10)
coef(summary(model))
                Estimate  Std. Error          df      t value        Pr(>|t|)
(Intercept) 251.40510485 6.632122742 18.00113477 37.907185169 1.263751938e-18

以及随机效应方差:

VarCorr(model)
Groups   Name        Std.Dev.   Corr    
 Subject  (Intercept) 23.7797596         
          Days         5.7167985 0.081321
 Residual             25.5919070   

要提取混合模型的组件,另请参阅 this Question 以及

glance()
包中的
tidy()
broom.mixed
函数。


0
投票
emm_options(opt.digits = FALSE)
© www.soinside.com 2019 - 2024. All rights reserved.