This function generates predictions for
merMod models, but
with the ability to get standard errors as well.
predict_merMod( object, newdata = NULL, se.fit = FALSE, use.re.var = FALSE, allow.new.levels = FALSE, type = c("link", "response", "terms"), na.action = na.pass, re.form = NULL, boot = FALSE, sims = 100, prog.arg = "none", ... )
a fitted model object
data frame for which to evaluate predictions.
Include standard errors with the predictions? Note that these standard errors by default include only fixed effects variance. See details for more info. Default is FALSE.
logical if new levels (or NA values) in
character string - either
Use bootstrapping (via
The developers of lme4 omit an
se.fit argument for a
reason, which is that it's not perfectly clear how best to estimate
the variance for these models. This solution is a logical one, but perhaps
not perfect. Bayesian models are one way to do better.
The method used here is based on the one described here: http://bbolker.github.io/mixedmodels-misc/glmmFAQ.html#predictions-andor-confidence-or-prediction-intervals-on-predictions