简体   繁体   English

如何从lme4的lmer模型中快速提取t值?

[英]How to (quickly) extract t values from lmer model in lme4?

I am working with a script that calls lmer function of the lme4 package thousands of times (do not worry, relevant correction for multiple comparisons is performed later) and would like to save as much time during a single call as possible. 我与调用脚本工作lmer的功能lme4包上千次(不要担心,在后面进行多重比较相关的校正),并想在单个呼叫尽可能在尽可能多的时间来保存。

I want to extract t-values from the fitted model, what is the fastest (computation time) way to do this? 我想从拟合模型中提取t值,最快的方式(计算时间)是什么? I tried using summary(model) but it seems to take (much) longer than calling lmer itself. 我尝试使用summary(model)但似乎比调用lmer本身花费的时间更长。 Is it possible to get the t-values from the obtained model without using summary() ? 是否可以在不使用summary()情况下从获得的模型中获得t值?

The best way to answer this question is to look at the code of lme4:::summary.merMod to figure out how to get the pieces you need. 回答此问题的最佳方法是查看lme4:::summary.merMod的代码,以弄清楚如何获得所需的零件。 This ought to do it: 这应该做到:

library(lme4)
fm1 <- lmer(Reaction ~ Days + (Days | Subject), sleepstudy)
t.stat <- function(x) fixef(x)/sqrt(diag(vcov(x)))
t.stat(fm1)
##    (Intercept)        Days 
##     36.838311    6.771485 
coef(summary(fm1))[,"t value"]  ## identical

Depending on what characteristics are common across your thousands of calls to lmer there may be other opportunities for computational efficiency: see eg ?refit and ?modular . 取决于您成千上万次致电lmer共同特征是什么,可能还有其他提高计算效率的机会:请参阅例如?refit?modular

(Looking at the code of lme4:::summary.merMod doesn't reveal anything obviously time-consuming: I would be interested in profiling results that say what's slow in those computations.) (查看lme4:::summary.merMod的代码并没有发现任何明显耗时的内容:我对剖析表明哪些计算速度较慢的结果很感兴趣。)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从 ML 拟合的“lme4::lmer”模型中提取信息标准,并与 REML 拟合的 model 中的 model 摘要结合 - How to extract information criterions from `lme4::lmer`-model fitted by ML and combine with model summary from REML-fitted model 如何从 R 中的 package lme4 中提取参数的实际值及其标准误差而不是 lmer 中的边际效应估计值? - How to extract the actual values of parameters and their standard error instead of the marginal effect estimates in lmer from package lme4 in R? 从 lmer 对象中提取随机效应的原始模型矩阵 (lme4, R) - Extract raw model matrix of random effects from lmer objects (lme4, R) 关于lme4中来自lmer的u和u0值[R] - About the u and u0 values from lmer in lme4 [R] 修复 lme4/lmer 中特定值的差异 - Fix variances to specific values in lme4/lmer 如何使用broom :: tidy()从lme4 :: lmer()创建的线性混合效果模型中计算p值? - How to calculate p-value from a linear mixed effect model created by lme4::lmer() using broom::tidy()? 从混合模型(lme4)公式中提取组件 - Extract components from mixed model (lme4) formula 从 lme4 mer 模型对象中提取随机效应方差 - Extract random effect variances from lme4 mer model object lme4 :: lmer报告“固定效应模型矩阵秩不足”,我是否需要修复以及如何解决? - lme4::lmer reports “fixed-effect model matrix is rank deficient”, do I need a fix and how to? 在lme4(g)lmer()模型计算中添加进度条 - Adding a progress bar to lme4 (g)lmer() model computation
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM