add_pi.lmerMod {ciTools}  R Documentation 
This function is one of the methods in add_pi
, and is
called automatically when add_pi
is used on a fit
of
class lmerMod
.
## S3 method for class 'lmerMod'
add_pi(
df,
fit,
alpha = 0.05,
names = NULL,
yhatName = "pred",
type = "parametric",
includeRanef = TRUE,
log_response = FALSE,
nSims = 10000,
...
)
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, either 
includeRanef 
A logical. Set whether the predictions and
intervals should be conditioned on the random effects. If

log_response 
A logical, indicating if the response is on log
scale in the model fit. If 
nSims 
A positive integer. If 
... 
Additional arguments. 
It is recommended that one use parametric prediction intervals when
modeling with a random intercept linear mixed model. Otherwise,
prediction intervals may be simulated via a parametric bootstrap
using the function lme4.simulate()
.
A dataframe, df
, with predicted values, upper and lower
prediction bounds attached.
add_ci.lmerMod
for confidence intervals
for lmerMod
objects, add_probs.lmerMod
for
conditional probabilities of lmerMod
objects, and
add_quantile.lmerMod
for response quantiles of
lmerMod
objects.
dat < lme4::sleepstudy
# Fit a (random intercept) linear mixed model
fit < lme4::lmer(Reaction ~ Days + (1Subject), data = lme4::sleepstudy)
# Add 50% prediction intervals to the original data using the default
# method.
add_pi(dat, fit, alpha = 0.5)
# Add 50% prediction intervals to the original data using the
# parametric bootstrap method. Form prediction intervals at the population
# level (unconditional on the random effects).
add_pi(dat, fit, alpha = 0.5, type = "boot", includeRanef = FALSE)