# NOT RUN {
dat <- lme4::sleepstudy
# Fit a (random intercept) linear mixed model
fit <- lme4::lmer(Reaction ~ Days + (1|Subject), data = lme4::sleepstudy)
# Add prediction intervals to the original data using the default
# method, parametric bootstrap. (You may want to use more than 100
# bootstrap replicates in practice).
add_pi(dat, fit, alpha = 0.5, nSims = 100)
# Add prediction intervals to the original data using the
# parametric method. Form prediction intervals at the population
# level (unconditional on the random effects)
add_pi(dat, fit, alpha = 0.5, type = "parametric", includeRanef = FALSE)
# Use a simulation method to form the parametric intervals. Add
# custom names to the prediction bounds. This method is faster
# than the parametric bootstrap, so we can set nSims higher.
add_pi(dat, fit, alpha = 0.5, type = "sim", names = c("lwr", "upr"), nSims = 1000)
# }
Run the code above in your browser using DataLab