I am using lmerTest::lmer()
to perform linear regression with repeated measures data.
My model contains a fixed effect (factor with 5 levels) and a random effect (subject):
library(lmerTest)
model_lm <- lmer(likertscore ~ task.f + (1 | subject), data = df_long)
I would like to include the total number of observations, the number of subjects, total R^2, and the R^2 of the fixed effects in the regression table which I generate with modelsummary()
.
I tried to extract these and build a gof_map
as described by the author of the package but did not succeed.
Below my model output from lmerTest::lmer()
the performance measures obtained:
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