IndvPred_lme {JMbayes} | R Documentation |
Individualized Predictions from Linear Mixed Models
Description
Calculates subject-specific predictions for new subjects from a linear mixed model.
Usage
IndvPred_lme(lmeObject, newdata, timeVar, times = NULL, M = 200L,
interval = c("confidence", "prediction"), all_times = FALSE,
level = 0.95, return_data = FALSE, seed = 1L)
extract_lmeComponents(lmeObject, timeVar)
Arguments
lmeObject |
an object inheriting from class |
newdata |
a data frame in which to look for variables with which to predict. |
timeVar |
a character string specifying the time variable in the linear mixed model. |
interval |
a character string indicating what type of intervals should be computed. |
all_times |
logical; should predictions be calculated at all |
level |
a numeric scalar denoting the tolerance/confidence level. |
times |
a numeric vector denoting the time points for which we wish to compute the
subject-specific predictions after the last available measurement provided in
|
M |
numeric scalar denoting the number of Monte Carlo samples. See Details. |
return_data |
logical; if |
seed |
numeric scalar, the random seed used to produce the results. |
Value
If return_data = TRUE
, a the data frame newdata
with extra rows for the
time points at which predictions were calculated, and extra columns with the predictions
and the limits of the pointwise confidence intervals.
If return_data = FALSE
, a list with components
times_to_pred |
time points at which predictions were calculated. |
predicted_y |
the predictions. |
low |
the lower limits of the pointwise confidence intervals. |
upp |
the upper limits of the pointwise confidence intervals. |
Author(s)
Dimitris Rizopoulos d.rizopoulos@erasmusmc.nl
See Also
Examples
## Not run:
# linear mixed model fit
fitLME <- lme(log(serBilir) ~ drug * ns(year, 2), data = subset(pbc2, id != 2),
random = ~ ns(year, 2) | id)
DF <- IndvPred_lme(fitLME, newdata = subset(pbc2, id == 2), timeVar = "year",
M = 500, return_data = TRUE)
require(lattice)
xyplot(pred + low + upp ~ year | id, data = DF,
type = "l", col = c(2,1,1), lty = c(1,2,2), lwd = 2,
ylab = "Average log serum Bilirubin")
# extract_lmeComponents() extract the required components from the lme object
# that are required to calculate the predictions; this is a light weight version of
# the object, e.g.,
fitLME_light <- extract_lmeComponents(fitLME, timeVar = "year")
DF <- IndvPred_lme(fitLME_light, newdata = subset(pbc2, id == 2), timeVar = "year",
M = 500, return_data = TRUE)
## End(Not run)