如何从modelsummary包中提取MSSummary的lmer()模型的拟合优度统计信息

如何从modelsummary包中提取MSSummary的lmer()模型的拟合优度统计信息,r,regression,lme4,lmertest,modelsummary,R,Regression,Lme4,Lmertest,Modelsummary,我正在使用lmerTest::lmer()对重复测量数据执行线性回归 我的模型包含固定效应(5级因子)和随机效应(主题): 问题是,默认情况下,glance或performance中没有一个统计信息可用,这意味着您需要做一些腿部工作来定制输出 首先,我们加载库并估计模型: 库(模型摘要) 图书馆(lmerTest) mod aic bic r2.条件r2.边际icc rmse西格玛nobs #> 1 181.8949 187.7578 0.6744743 0.1432201 0.6

我正在使用
lmerTest::lmer()
对重复测量数据执行线性回归

我的模型包含固定效应(5级因子)和随机效应(主题):


问题是,默认情况下,
glance
performance
中没有一个统计信息可用,这意味着您需要做一些腿部工作来定制输出

首先,我们加载库并估计模型:

库(模型摘要)
图书馆(lmerTest)
mod aic bic r2.条件r2.边际icc rmse西格玛nobs
#> 1 181.8949 187.7578      0.6744743   0.1432201 0.6200592 2.957141 3.149127   32
您会注意到那里没有
N(主题)
统计信息,所以我们需要手动添加它。一种可复制的方法是利用中描述的
glance\u custom
机制。要做到这一点,我们需要知道模型的类别:

class(mod)[1]
#>[1]“lmerModLmerTest”
然后,我们需要为这个类名定义一个方法。此方法应称为
glance\u custom.CLASSNAME
。在
lmerModLmerTest
模型中,可以通过获取摘要中的
ngrps
对象来检索组数。所以我们这样做:


glance\u custom.lmerModLmerTest您能澄清一下您的预期输出是什么吗?太棒了!这个更详细的例子说明了如何从
get_god()
gof_map()=gm
非常有帮助和深刻的见解–非常非常感谢!仅针对边际和配置R^2调整“fmt=2”
library(lmerTest) 
model_lm  <- lmer(likertscore ~ task.f + (1 | subject), data = df_long)  
Linear mixed model fit by REML ['lmerModLmerTest']
Formula: likertscore ~ factor + (1 | subject)
   Data: df_long
REML criterion at convergence: 6674.915
Random effects:
 Groups   Name        Std.Dev.
 subject  (Intercept) 1.076   
 Residual             1.514   
Number of obs: 1715, groups:  subject, 245
Fixed Effects:
                      (Intercept)                         factor1                         factor2  
                           3.8262                             1.5988                             0.3388  
                      factor3                             factor4                         factor5  
                          -0.7224                            -0.1061                            -1.1102  

library("performance")
performance::model_performance(my_model)

# Indices of model performance

AIC     |     BIC | R2 (cond.) | R2 (marg.) |  ICC | RMSE | Sigma
-----------------------------------------------------------------
6692.91 | 6741.94 |       0.46 |       0.18 | 0.34 | 1.42 |  1.51