lmer_table: Function producing a tidy table for many multilevel...

View source: R/multilevel_helpers.R

lmer_tableR Documentation

Function producing a tidy table for many multilevel regressions (lmer fitted objects)

Description

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.

Note

Issues to implement:

  • Might be veeery slow (something to work on)

Examples

data("sleepstudy", package="lme4")
m1=lmer(Reaction ~ Days + (1|Subject), sleepstudy)
m2=lmer(Reaction ~ Days + (1+Days|Subject), sleepstudy)
good_table(list(m1, m2))



MaksimRudnev/LittleHelpers documentation built on Nov. 5, 2024, 10:16 p.m.