Learn R Programming

JM (version 0.1-0)

residuals: Residuals for Joint Models

Description

Calculates residuals for joint models.

Usage

## S3 method for class 'jointModel':
residuals(object, process = c("Longitudinal", "Event"), 
  type = c("Marginal", "Subject", "stand-Marginal", 
    "stand-Subject"), ...)

Arguments

object
an object inheriting from class jointModel.
process
for which model (i.e., linear mixed model or survival model) to calculate residuals.
type
what type of residuals to calculate. See Details.
...
additional arguments; currently none is used.

Value

  • a numeric vector of residual values.

Details

Currently residuals are calculated for the longitudinal outcome. If type = "Marginal" these are $e_{ij} = y_{ij} - x_{ij}^T \hat{\beta}$, whereas for type = "Subject", $e_{ij} = y_{ij} - x_{ij}^T \hat{\beta} - z_{ij}^T b_i$, where $i$ denotes the subject and $j$ the measurement, $y_{ij}$ the longitudinal responses, $x_{ij}^T$ and $z_{ij}^T$ the corresponding rows of the fixed and random effects design matrices, respectively, and $\beta$ and $b_i$ denote the fixed effects and random effects components. If type = "stand-Marginal" or type = "stand-Subject", the above defined residuals are divided by the estimated standard deviation of the error term.

See Also

fitted.jointModel

Examples

Run this code
# linear mixed model fit
fitLME <- lme(sqrt(CD4) ~ obstime * drug - drug, 
    random = ~ 1 | patient, data = aids)
# cox model fit
fitCOX <- coxph(Surv(Time, death) ~ drug, data = aids.id, x = TRUE)

# joint model fit, under the additive log cumulative hazard model
fitJOINT <- jointModel(fitLME, fitCOX, 
    timeVar = "obstime", method = "ch-GH")

head(cbind(
    "Marginal" = residuals(fitJOINT),
    "std-Marginal" = residuals(fitJOINT, type = "stand-Marginal"),
    "Subject" = residuals(fitJOINT, type = "Subject"),
    "std-Subject" = residuals(fitJOINT, type = "stand-Subject")
))

Run the code above in your browser using DataLab