knitr::opts_chunk$set( echo = TRUE, message = TRUE, warning = FALSE, error = FALSE, collapse = TRUE, comment = NA, R.options = list(width = 220), dev.args = list(bg = 'transparent'), dev = 'png', fig.align = 'center', out.width = '75%', fig.asp = .75, cache.rebuild = FALSE, cache = FALSE )
brms_model <- mixedup:::brms_model
This is pretty printing of results of a mixed model. Correlations of random and fixed effects are turned off by default, as the focus of interest is usually the variance components and fixed effects themselves. 95% confidence intervals are provided by default.
library(lme4) library(glmmTMB) library(nlme) library(brms) library(mgcv) lmer_model <- lmer(Reaction ~ Days + (1 + Days | Subject), data = sleepstudy) lme_model <- lme(Reaction ~ Days, random = ~ 1 + Days | Subject, data = sleepstudy) tmb_model <- glmmTMB(Reaction ~ Days + (1 + Days | Subject), data = sleepstudy) # brms_model <- # brm(Reaction ~ Days + (1 + Days | Subject), # data = sleepstudy, # cores = 4, # refresh = -1, # verbose = FALSE # ) # this is akin to (1 | Subject) + (0 + Days | Subject) in lme4 mgcv_model <- gam( Reaction ~ Days + s(Subject, bs = 're') + s(Days, Subject, bs = 're'), data = lme4::sleepstudy, method = 'REML' )
library(mixedup) summarize_model(lmer_model) summarize_model(lme_model) summarize_model(tmb_model) summarize_model(brms_model) summarize_model(mgcv_model)
summarize_model( lmer_model, ci = FALSE, cor_re = TRUE, cor_fe = TRUE, digits = 3 ) summarise_model(lmer_model, ci = FALSE)
Often a model estimated by lme4 needs a bit of help for convergence. At present this function only works for lme4, but then, that's mostly where you're going to have the problem. This function will start with your current model and run it long enough to the point that if you still have problems, you probably really have data or model issues, and not just an estimation problem. See this for details.
# for some reason this example apparently only works interactively, not when knit ss2 = sleepstudy ss2$Days = ss2$Days * 10 lmer_not_converged <- lmer( Reaction ~ Days + (Days|Subject), data = ss2 ) # lmer_not_converged lmer_converged <- converge_it(lmer_not_converged) # final result is a converged model lmer_converged
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.