lmer_predict | R Documentation |
By default, lmer_predict will compute estimates of the outcome variable for every combination of predictors
that are in the model. For continuous predictors, it finds the range of observed values and computes at
20 equally spaced points along the range. This number is controlled by n.cont
. For categorical predictors,
it computes estimates at each level.
lmer_predict(
lmerObj,
divide = NULL,
n.divide = 3,
divide.prefix = TRUE,
n.cont = 20,
cont.pts = NULL,
fixat0 = NULL,
fixatmean = NULL,
yoked = NULL
)
lmerObj |
the fitted (g)lmer object used to make predictions |
divide |
a character vector specifying continuous predictors that should be cut into categorical levels |
n.divide |
how many categories to use when cutting variables in |
divide.prefix |
Whether to include the variable name in naming the cut points |
n.cont |
The number of points along the continuous predictor range at which to compute an estimate |
cont.pts |
A list named by predictor where each element is a vector of values at which to compute an estimate |
fixat0 |
Predictors that should be fixed at 0 in the estimates |
fixatmean |
Predictors that should be fixed at sample mean in the estimates |
yoked |
Useful when predictors are transformations of each other (need to document this better). |
This function was adapted from code initially developed by Doug Bates. This is currently part of the predict method of lmer: https://github.com/bbolker/mixedmodels-misc/blob/master/glmmFAQ.rmd
A data.frame containing model-predicted values for each predictor, along with standard errors (se), 95% CIs (ci_lo and ci_hi), and 95% prediction intervals (pred_lo and pred_hi).
Michael Hallquist
data(rat.brain)
library(lme4); library(ggplot2)
m <- lmer(activate ~ region * treatment + (1 | animal), data=rat.brain)
pred_vals <- lmer_predict(m)
ggplot(pred_vals, aes(x=region, y=activate,
ymin=activate-se, ymax=activate+se, color=treatment)) +
geom_pointrange()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.