【问题标题】:Getting standard errors for lme4 object with texreg使用 texreg 获取 lme4 对象的标准错误
【发布时间】:2014-07-18 19:27:49
【问题描述】:

我一直在使用神奇的 texreg 包从 lme4 模型生成高质量的 HTML 表格。不幸的是,默认情况下,texreg 在 lme4 模型的系数下创建置信区间,而不是标准误差(参见 JSS paper 的第 17 页)。

举个例子:

library(lme4)
library(texreg)
screenreg(lmer(Reaction ~ Days + (Days|Subject), sleepstudy))

生产

Computing profile confidence intervals ...
Computing confidence intervals at a confidence level of 0.95. Use argument "method = 'boot'" for bootstrapped CIs.

===============================================
                               Model 1         
-----------------------------------------------
(Intercept)                     251.41 *       
                               [237.68; 265.13]
Days                             10.47 *       
                               [  7.36;  13.58]
-----------------------------------------------
AIC                            1755.63         
BIC                            1774.79         
Log Likelihood                 -871.81         
Deviance                       1743.63         
Num. obs.                       180            
Num. groups: Subject             18            
Variance: Subject.(Intercept)   612.09         
Variance: Subject.Days           35.07         
Variance: Residual              654.94         
===============================================
* 0 outside the confidence interval

我更希望看到这样的东西:

Computing profile confidence intervals ...
Computing confidence intervals at a confidence level of 0.95. Use argument "method = 'boot'" for bootstrapped CIs.

===============================================
                               Model 1         
-----------------------------------------------
(Intercept)                     251.41 *       
                                (24.74)
Days                             10.47 *       
                                 (5.92)
-----------------------------------------------
[output truncated for clarity]

有没有办法覆盖这种行为?据我所知,使用 ci.force = FALSE 选项不起作用。

我坚持使用 texreg,而不是像 stargazer 那样使用 one of the other packages,因为 texreg 允许我将系数分组到有意义的组中。

提前感谢您的帮助!

(更新:已编辑以包含示例)

【问题讨论】:

  • 请考虑添加一个small reproducible example,以便我们更好地理解并更轻松地回答您的问题。
  • 谢谢!我放了一个。希望这有助于澄清。如果没有,请告诉我。再次感谢您的帮助!

标签: r lme4 texreg


【解决方案1】:

使用naive=TRUE 可以接近你想要的......

library(lme4); library(texreg)
fm1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy)
screenreg(fm1,naive=TRUE)

## ==========================================
##                                Model 1    
## ------------------------------------------
## (Intercept)                     251.41 ***
##                                  (6.82)   
## Days                             10.47 ***
##                                  (1.55)   
## ------------------------------------------
## [etc.]

我不知道你的 24.94、5.92 值是从...哪里得到的?

sqrt(diag(vcov(fm1)))
## [1] 6.824556 1.545789

cc <- confint(fm1,which="beta_")
apply(cc,1,diff)/3.84
## (Intercept)        Days 
##    7.14813     1.61908

基于缩放配置文件置信区间的隐含标准误差稍宽,但差别不大。

我不知道如何轻松地根据配置文件置信区间获得显着性检验/星级,同时仍然在表格中获得标准误差。根据?texreg中的ci.test条目,

  • 打印 CI 时,如果置信区间不包括零,texreg 会打印一个单个
  • 打印 SE 时,它会根据 p 值的大小打印标准星数

【讨论】:

  • 成功了,谢谢!我从summary(fm1) 获得了 SE,但显然这给了我一些我想不到的东西。使用 naive = T 选项的明星行为是我想要的;我想要基于 p 值大小的星星,而不是基于 CI 是否包含 0。
  • FWIW 您从摘要中复制了随机效应的标准差,而不是固定效应参数的标准差 ...
【解决方案2】:

您也可以尝试将 'include.ci' 参数设置为 FALSE

model <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy)
texreg(model, include.ci = FALSE)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-07-16
    • 2012-06-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-05
    • 1970-01-01
    • 2012-02-10
    相关资源
    最近更新 更多