add_ci.lmerMod {ciTools}  R Documentation 
This function is one of the methods for add_ci
, and is
called automatically when add_ci
is used on a fit
of
class lmerMod
. It is recommended that one use parametric
confidence intervals when modeling with a random intercept linear
mixed model (i.e. a fit with a formula such as lmer(y ~ x +
(1group))
). Otherwise, confidence intervals may be bootstrapped
via lme4::bootMer
.
## S3 method for class 'lmerMod'
add_ci(
df,
fit,
alpha = 0.05,
names = NULL,
yhatName = "pred",
type = "boot",
includeRanef = TRUE,
nSims = 500,
...
)
df 
A data frame of new data. 
fit 
An object of class 
alpha 
A real number between 0 and 1. Controls the confidence level of the interval estimates. 
names 

yhatName 
A string. Name of the predictions vector. 
type 
A string. Must be 
includeRanef 
A logical. Default is 
nSims 
A positive integer. Controls the number of bootstrap
replicates if 
... 
Additional arguments. 
Bootstrapped intervals are slower to compute, but they are the recommended method when working with any linear mixed models more complicated than the random intercept model.
A dataframe, df
, with predicted values, upper and lower
confidence bounds attached.
add_pi.lmerMod
for prediction intervals
of lmerMod
objects, add_probs.lmerMod
for
conditional probabilities of lmerMod
objects, and
add_quantile.lmerMod
for response quantiles of
lmerMod
objects.
## Not run:
dat < lme4::sleepstudy
# Fit a linear mixed model (random intercept model)
fit < lme4::lmer(Reaction ~ Days + (1Subject), data = lme4::sleepstudy)
# Get the fitted values for each observation in dat, and
# append CIs for those fitted values to dat
add_ci(dat, fit, alpha = 0.5)
# Try the parametric bootstrap method, and make prediction at the population level
add_ci(dat, fit, alpha = 0.5, type = "boot", includeRanef = FALSE, nSims = 100)
## End(Not run)