fitted & residuals {JMbayes} | R Documentation |
Fitted Values and Residuals for Joint Models
Description
Calculates fitted values for joint models.
Usage
## S3 method for class 'JMbayes'
fitted(object,
process = c("Longitudinal", "longitudinal", "Event", "event"),
type = c("Marginal", "marginal", "Subject", "subject"), nullY = FALSE, ...)
## S3 method for class 'JMbayes'
residuals(object,
process = c("Longitudinal", "longitudinal", "Event", "event"),
type = c("Marginal", "marginal", "Subject", "subject",
"Martingale", "martingale", "nullMartingale", "nullmartingale"),
standardized = FALSE, ...)
Arguments
object |
an object inheriting from class |
process |
for which model (i.e., linear mixed model or survival model) to calculate fitted values or residuals. |
type |
what type of fitted values or residuals to calculate. See Details. |
nullY |
logical; if |
standardized |
logical; if |
... |
additional arguments; currently none is used. |
Details
For process = "Longitudinal"
, let X
denote the design matrix for the fixed effects \beta
, and
Z
the design matrix for the random effects b
. Then for type = "Marginal"
the fitted values are
X \hat{\beta},
whereas for type = "Subject"
they are X \hat{\beta} + Z \hat{b}
, where \hat{\beta}
and \hat{b}
denote the corresponding posterior means for the fixed and random effects. The corresponding residuals
are calculated by subtracting the fitted values from the observed data y
. If type = "Subject"
and
standardized = TRUE
, the residuals are divided by the estimated residual standard error.
For process = "Event"
function fitted()
calculates the cumulative hazard function at each time point a longitudinal
measurement has been recorded. If nullY = TRUE
, then the cumulative hazard is calculated without the contribution of the
longitudinal process. Function residuals()
calculates the martingales residuals or the martingale residuals without the
contribution of the longitudinal process when type = "nullMartingale"
.
Value
a numeric vector of fitted values or residuals.
Author(s)
Dimitris Rizopoulos d.rizopoulos@erasmusmc.nl
References
Rizopoulos, D. (2012) Joint Models for Longitudinal and Time-to-Event Data: with Applications in R. Boca Raton: Chapman and Hall/CRC.
Examples
## Not run:
lmeFit <- lme(log(serBilir) ~ ns(year, 2), data = pbc2,
random = ~ ns(year, 2) | id)
survFit <- coxph(Surv(years, status2) ~ 1, data = pbc2.id, x = TRUE)
jointFit <- jointModelBayes(lmeFit, survFit, timeVar = "year")
fitted(jointFit, process = "Event")
residuals(jointFit, type = "Subject", standardized = TRUE)
## End(Not run)