gpt4 book ai didi

r - 如何让 emmeans 打印 glmer 类的自由度

转载 作者:行者123 更新时间:2023-12-05 05:35:21 26 4
gpt4 key购买 nike

出于报告原因,我试图从 glmer 模型的 emmeans 获取自由度,但它们只显示 Inf

这是一些示例数据。在真实数据中,没有嵌套结构,这只是我构建数据框的结果:

set.seed(1234)
dat <- data.frame(
dv=c(rnorm(mean=1, sd=0.2, n=12000)),
id=c(rep(c("1", "2", "3"), times=c(4000, 4000, 4000))),
region=c(rep(rep(c("1", "2"), times=c(2000, 2000)), 3)),
intervention=c(rep(c("1", "2", "1"), times=c(4000, 4000, 4000))),
timepoint=c(rep(rep(c("1", "2"), times=c(2000, 2000)), times=3)),
direction=c(rep(rep(c("1", "2"), times=c(2000, 2000)), 3))
)

glmm_1 <- glmer(dv ~ intervention*timepoint*region + direction + (1|id), data=dat, family=gaussian(link="log"))

glmm_1_emm <- emmeans::emmeans(glmm_1, pairwise ~ intervention*region*timepoint, type = "response")

glmm_1_emm$emmeans

NOTE: A nesting structure was detected in the fitted model:
timepoint %in% (direction*region), region %in% direction
region timepoint direction intervention response SE df asymp.LCL asymp.UCL
1 1 1 1 1 0.00313 Inf 0.994 1.01
2 2 2 1 1 0.00313 Inf 0.998 1.01
1 1 1 2 1 0.00442 Inf 0.992 1.01
2 2 2 2 1 0.00442 Inf 0.995 1.01

Confidence level used: 0.95
Intervals are back-transformed from the log scale

最佳答案

这实际上更像是一个统计问题(即 CrossValidated )而不是一个计算问题。 tl;dr 有限尺寸校正很少被考虑用于 GLM 或 GLMM,特别是对于 GLMM,据我所知,很少有理论工作甚至会指定如何计算它们。这就是为什么 emmeans 等将 df 报告为 Inf

emmeans 输出中的

df 表示“分母自由度”(即,如果针对 F 分布进行测试,您将使用的 nu2F_{nu1,nu2}),对于简单(非混合)模型(如线性回归或简单方差分析)来说,这类似于(观察数 - 估计参数数),但要难得多为多级模型(即线性混合模型)定义。对于广义线性(和线性混合)模型,情况变得更糟。引用自 "degrees of freedom" section of the GLMM FAQ (查看完整引用资料):

  • When the responses are not normally distributed (as in GLMs and GLMMs), and when the scale parameter is not estimated (as in standard Poisson- and binomial-response models), then the deviance differences are only asymptotically F- or chi-square-distributed (i.e. not for our real, finite-size samples). In standard GLM practice, we usually ignore this problem; there is some literature on finite-size corrections for GLMs under the rubrics of “Bartlett corrections” and “higher order asymptotics” (see McCullagh and Nelder (1989), Cordeiro, Paula, and Botter (1994), Cordeiro and Ferrari (1998) and the cond package (on CRAN) [which works with GLMs, not GLMMs]), but it’s rarely used. (The bias correction/Firth approach implemented in the brglm package attempts to address the problem of finite-size bias, not finite-size non-chi-squaredness of the deviance differences.)
  • When the scale parameter in a GLM is estimated rather than fixed (as in Gamma or quasi-likelihood models), it is sometimes recommended to use an Ftest to account for the uncertainty of the scale parameter (e.g. Venables and Ripley (2002) recommend anova(...,test="F") for quasi-likelihood models)Combining these issues, one has to look pretty hard for information on small-sample or finite-size corrections for GLMMs: Feng, Braun, and McCulloch (2004) and Bell and Grunwald (2010) look like good starting points, but it’s not at all trivial.

关于r - 如何让 emmeans 打印 glmer 类的自由度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73536308/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com