Function producing a tidy table for many multilevel regressions (lmer fitted objects)
Source:R/multilevel_helpers.R
lmer_table.Rd
Stacks coefficients and SEs, extracts various lmer-specific model fit statistics and confidence intervals for random effects (refits models if necessary), outputs a nicely formatted table using stargazer and shows it directly in Rstudio Viewer.
Usage
lmer_table(
models,
fit.stats = c("fit", "random"),
mod.names = "",
show.viewer = TRUE,
silent = TRUE,
digits = 2,
...
)
Arguments
- models
List of the fitted lmer objects
- fit.stats
What fit statistics to compute/extract and show? Possible options are "ICC", "random", "R2s", "fit", "LRT", "REML", "VIF". See "Details".
- mod.names
Vector of the same length as models list, giving names to each model.
- show.viewer
Logical. Whether the resulting table should be shown in the RStudio viewer. If FALSE then the file "good_table_output.html" is saved to working directory.
- ...
Arguments passed to stargazer.
Details
The list of possible fit.stats options:
- fit
Shows deviance (-2*logLikelihood), AIC, BIC, number of parameters, number of groups, number of observations, if the model converged
- ICC
Computes intra-class correlation by fitting an empty model and computing a ratio of first-level and intercept variances.
- R2
Computes R-square by fitting an empoty model and computing a ratio of residuals in an empty model and in the current model.
- LRT
Computes Likelihood ratio test; all the models should be fitted to the same sample and be in order of nestedness, otherwise the test fails.
- random
Adds variances of all the random effects.
- random.p
Adds variances of all the random effects and implements bootstrapping (
lme4::confint.merMod
) in order to get confidence intervals and this p.values for variances of random effects.- REML
Shows if REML was used to fit the model.