knitr::opts_chunk$set( echo = TRUE, message = FALSE, 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 )
Miscellaneous functions are included to fill a need.
In many cases, predictions are made by holding the random effects to zero, which can be seen as the typical case. When the clusters carry substantive meaning, for example, school, country, or hospital, it might be of interest to note which are most 'typical', or at any other value relative to their peers. This will work for any model to which extract_random_effects applies.
library(lme4) lmer_model <- lmer(Reaction ~ Days + (1 + Days | Subject), data = sleepstudy) library(mixedup) find_typical(lmer_model) # closest RE to zero find_typical(lmer_model, probs = c(.1, .9))
For nlme, only models with varIdent have been tested. For glmmTMB, this applies to models that use the diag function in the formula.
library(nlme) lme_1 <- lme( distance ~ scale(age) + Sex, data = Orthodont, random = ~ 1 | Subject, weights = varIdent(form = ~ 1 | Sex) ) extract_het_var(lme_1)
May include brms at some point, but for
these, you can extract any parameters associated with sigma model for
distributional models using the component argument of the other standard
functions.
With some packages one can estimate the residual correlation structure. Right now this works for nlme, glmmTMB, and brms objects.
base_model <- lme(Reaction ~ Days, random = ~ 1 + Days | Subject, data = sleepstudy) lme_corSymm <- update( base_model, corr = corSymm(form = ~ 1 | Subject), data = dplyr::filter(sleepstudy, Days < 5) ) lme_corAR <- update( base_model, corr = corAR1(form = ~ Days), data = dplyr::filter(sleepstudy, Days < 5) ) extract_cor_structure(lme_corSymm) extract_cor_structure(lme_corAR)
Just a wrapper for model.frame.
head(extract_model_data(lmer_model))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.