Learn R Programming

JSM (version 1.0.1)

residuals: Extract Residuals for Joint Models

Description

residuals is a generic function which extracts residuals from objects returned by jmodelTM() or jmodelMult().

Usage

# S3 method for jmodelTM
residuals(object, process = c("Longitudinal", "Survival"), 
            type = c("Marginal", "Conditional", "Standardized-Marginal", 
            "Standardized-Conditional"), …)
# S3 method for jmodelMult
residuals(object, process = c("Longitudinal", "Survival"), 
            type = c("Marginal", "Conditional", "Standardized-Marginal", 
            "Standardized-Conditional"), …)

Arguments

object

an object inheriting from class jmodelTM or jmodelMult.

process

for which process the residuals are calculated, i.e. the longitudinal or the survival process.

type

what type of residuals to calculate for each process. See Details.

additional arguments required. None is used in this method.

Value

A numerc vector of residual values.

Details

We have implemented the residual calculation for process = "Longitudinal" but not for process = "Survival" yet as they are not well defined under the joint modeling setting. There are four types of residuals depending on whether to compute the values conditional on the random effects and whether to standardize the residuals. Please refer to Nobre and Single (2007) for details.

With type = "Marginal", the residuals are \(\varepsilon_{ij} = Y_{ij} - \mathbf{X}_{ij}^\top\boldsymbol\beta\) for objects returned by jmodelTM() and \(\varepsilon_{ij} = Y_{ij} - \mathbf{B}^\top(t_{ij})\boldsymbol\gamma\) for objects returned by jmodelMult(). With type = "Conditional", the residuals are \(\varepsilon_{ij} = Y_{ij} - \mathbf{X}_{ij}^\top\boldsymbol\beta - \mathbf{Z}_{ij}^\top\mathbf{b}_i\) for objects returned by jmodelTM() and \(\varepsilon_{ij} = Y_{ij} - b_i\times\mathbf{B}^\top(t_{ij})\boldsymbol\gamma\) for objects returned by jmodelMult(). If type = "Standardized-Marginal" or type = "Standardized-Conditional", the above defined residuals are divided by the estimated standard deviation of the corresponding error term.

References

Nobre, J. S. and Singer, J. M. (2007) Residuals analysis for linear mixed models. Biometrical Jounral 49(6), 863--875.

See Also

fitted.jmodelTM, fitted.jmodelMult

Examples

Run this code
# NOT RUN {
fitLME <- lme(proth ~ Trt * obstime, random = ~ 1 | ID, data = liver)
fitCOX <- coxph(Surv(start, stop, event) ~ Trt, data = liver, x = TRUE)
fitJT.ph <- jmodelTM(fitLME, fitCOX, liver, timeVarY = 'obstime')

# residuals for the longitudinal process
residuals(fitJT.ph, type = "Standardized-Conditional")
# }

Run the code above in your browser using DataLab