Title: | Joint Modeling of Longitudinal and Survival Data |
---|---|
Description: | Shared parameter models for the joint modeling of longitudinal and time-to-event data. |
Authors: | Dimitris Rizopoulos <[email protected]> |
Maintainer: | Dimitris Rizopoulos <[email protected]> |
License: | GPL (>= 2) |
Version: | 1.5-2 |
Built: | 2024-11-12 06:37:47 UTC |
Source: | CRAN |
A randomized clinical trial in which both longitudinal and survival data were collected to compare the efficacy and safety of two antiretroviral drugs in treating patients who had failed or were intolerant of zidovudine (AZT) therapy.
A data frame with 1408 observations on the following 9 variables.
patient
patients identifier; in total there are 467 patients.
Time
the time to death or censoring.
death
a numeric vector with 0 denoting censoring and 1 death.
CD4
the CD4 cells count.
obstime
the time points at which the CD4 cells count was recorded.
drug
a factor with levels ddC
denoting zalcitabine and ddI
denoting didanosine.
gender
a factor with levels female
and male
.
prevOI
a factor with levels AIDS
denoting previous opportunistic infection (AIDS
diagnosis) at study entry, and noAIDS
denoting no previous infection.
AZT
a factor with levels intolerance
and failure
denoting AZT intolerance and
AZT failure, respectively.
The data frame aids.id
contains the first CD4 cell count measurement for each patient. This data frame is used to
fit the survival model.
Goldman, A., Carlin, B., Crane, L., Launer, C., Korvick, J., Deyton, L. and Abrams, D. (1996) Response of CD4+ and clinical consequences to treatment using ddI or ddC in patients with advanced HIV infection. Journal of Acquired Immune Deficiency Syndromes and Human Retrovirology 11, 161–169.
Guo, X. and Carlin, B. (2004) Separate and joint modeling of longitudinal and event time data using standard computer packages. The American Statistician 58, 16–24.
summary(aids.id)
summary(aids.id)
Produces marginal Wald tests or Performs a likelihood ratio test between two nested joint models.
## S3 method for class 'jointModel' anova(object, object2, test = TRUE, process = c("both", "Longitudinal", "Event"), L = NULL, ...)
## S3 method for class 'jointModel' anova(object, object2, test = TRUE, process = c("both", "Longitudinal", "Event"), L = NULL, ...)
object |
an object inheriting from class |
object2 |
an object inheriting from class |
test |
logical; if |
process |
for which of the two submodels to produce the marginal Wald tests table. |
L |
a numeric matrix of appropriate dimensions defining the contrasts of interest. |
... |
additional arguments; currently none is used. |
An object of class aov.jointModel
with components,
nam0 |
the name of |
L0 |
the log-likelihood under the null hypothesis ( |
aic0 |
the AIC value for the model given by |
bic0 |
the BIC value for the model given by |
nam1 |
the name of |
L1 |
the log-likelihood under the alternative hypothesis ( |
aic1 |
the AIC value for the model given by |
bic1 |
the BIC value for the model given by |
df |
the degrees of freedom for the test (i.e., the difference in the number of parameters). |
LRT |
the value of the Likelihood Ratio Test statistic (returned if |
p.value |
the |
aovTab.Y |
a data.frame with the marginal Wald tests for the longitudinal process;
produced only when |
aovTab.T |
a data.frame with the marginal Wald tests for the event process;
produced only when |
aovTab.L |
a data.frame with the marginal Wald tests for the user-defined contrasts matrix;
produced only when |
The code minimally checks whether the models are nested! The user is responsible to supply nested models in order the LRT to be valid.
Dimitris Rizopoulos [email protected]
Rizopoulos, D. (2012) Joint Models for Longitudinal and Time-to-Event Data: with Applications in R. Boca Raton: Chapman and Hall/CRC.
Rizopoulos, D. (2010) JM: An R Package for the Joint Modelling of Longitudinal and Time-to-Event Data. Journal of Statistical Software 35 (9), 1–33. doi:10.18637/jss.v035.i09
## Not run: # linear mixed model fit without treatment effect fitLME.null <- lme(sqrt(CD4) ~ obstime, random = ~ 1 | patient, data = aids) # cox model fit without treatment effect fitCOX.null <- coxph(Surv(Time, death) ~ 1, data = aids.id, x = TRUE) # joint model fit without treatment effect fitJOINT.null <- jointModel(fitLME.null, fitCOX.null, timeVar = "obstime", method = "weibull-PH-aGH") # linear mixed model fit with treatment effect fitLME.alt <- lme(sqrt(CD4) ~ obstime * drug - drug, random = ~ 1 | patient, data = aids) # cox model fit with treatment effect fitCOX.alt <- coxph(Surv(Time, death) ~ drug, data = aids.id, x = TRUE) # joint model fit with treatment effect fitJOINT.alt <- jointModel(fitLME.alt, fitCOX.alt, timeVar = "obstime", method = "weibull-PH-aGH") # likelihood ratio test for treatment effect anova(fitJOINT.null, fitJOINT.alt) ## End(Not run)
## Not run: # linear mixed model fit without treatment effect fitLME.null <- lme(sqrt(CD4) ~ obstime, random = ~ 1 | patient, data = aids) # cox model fit without treatment effect fitCOX.null <- coxph(Surv(Time, death) ~ 1, data = aids.id, x = TRUE) # joint model fit without treatment effect fitJOINT.null <- jointModel(fitLME.null, fitCOX.null, timeVar = "obstime", method = "weibull-PH-aGH") # linear mixed model fit with treatment effect fitLME.alt <- lme(sqrt(CD4) ~ obstime * drug - drug, random = ~ 1 | patient, data = aids) # cox model fit with treatment effect fitCOX.alt <- coxph(Surv(Time, death) ~ drug, data = aids.id, x = TRUE) # joint model fit with treatment effect fitJOINT.alt <- jointModel(fitLME.alt, fitCOX.alt, timeVar = "obstime", method = "weibull-PH-aGH") # likelihood ratio test for treatment effect anova(fitJOINT.null, fitJOINT.alt) ## End(Not run)
Using the available longitudinal information up to a starting time point, this function computes an estimate of the prediction error of survival at a horizon time point based on joint models.
aucJM(object, newdata, Tstart, ...) ## S3 method for class 'jointModel' aucJM(object, newdata, Tstart, Thoriz = NULL, Dt = NULL, idVar = "id", simulate = FALSE, M = 100, ...)
aucJM(object, newdata, Tstart, ...) ## S3 method for class 'jointModel' aucJM(object, newdata, Tstart, Thoriz = NULL, Dt = NULL, idVar = "id", simulate = FALSE, M = 100, ...)
object |
an object inheriting from class |
newdata |
a data frame that contains the longitudinal and covariate information for the subjects for which prediction
of survival probabilities is required. The names of the variables in this data frame must be the same as in the data frames that
were used to fit the linear mixed effects model (using |
Tstart |
numeric scalar denoting the time point up to which longitudinal information is to be used to derive predictions. |
Thoriz |
numeric scalar denoting the time point for which a prediction of the survival status is of interest;
|
Dt |
numeric scalar denoting the length of the time interval of prediction; either |
idVar |
the name of the variable in |
simulate |
logical; if |
M |
a numeric scalar denoting the number of Monte Carlo samples; see |
... |
additional arguments; currently none is used. |
Based on a fitted joint model (represented by object
) and using the data supplied in argument newdata
, this function
computes the following estimate of the AUC:
with and
denote a randomly selected pair of subjects, and
and
denote the conditional survival probabilities calculated by
survfitJM
for these two subjects, for different time windows specified by argument
Dt
using
the longitudinal information recorded up to time t =
Tstart
.
The estimate of provided by
aucJM()
is in the spirit of Harrell's
-index, that is for the comparable subjects (i.e., the ones whose observed event times can be ordered), we
compare their dynamic survival probabilities calculated by
survfitJM
. As with Harrell's -index,
does not fully take into account censoring, and therefore is expected to mask the
true discriminative capability of the joint model under heavy censoring.
A list of class aucJM
with components:
auc |
a numeric scalar denoting the estimated prediction error. |
Tstart |
a copy of the |
Thoriz |
a copy of the |
nr |
a numeric scalar denoting the number of subjects at risk at time |
classObject |
the class of |
nameObject |
the name of |
Dimitris Rizopoulos [email protected]
Antolini, L., Boracchi, P., and Biganzoli, E. (2005). A time-dependent discrimination index for survival data. Statistics in Medicine 24, 3927–3944.
Harrell, F., Kerry, L. and Mark, D. (1996). Multivariable prognostic models: issues in developing models, evaluating assumptions and adequacy, and measuring and reducing errors. Statistics in Medicine 15, 361–387.
Heagerty, P. and Zheng, Y. (2005). Survival model predictive accuracy and ROC curves. Biometrics 61, 92–105.
Rizopoulos, D. (2012) Joint Models for Longitudinal and Time-to-Event Data: with Applications in R. Boca Raton: Chapman and Hall/CRC.
Rizopoulos, D. (2011). Dynamic predictions and prospective accuracy in joint models for longitudinal and time-to-event data. Biometrics 67, 819–829.
Rizopoulos, D., Murawska, M., Andrinopoulou, E.-R., Lesaffre, E. and Takkenberg, J. (2013). Dynamic predictions with time-dependent covariates in survival analysis: A comparison between joint modeling and landmarking. under preparation.
## Not run: # we construct the composite event indicator (transplantation or death) pbc2$status2 <- as.numeric(pbc2$status != "alive") pbc2.id$status2 <- as.numeric(pbc2.id$status != "alive") # we fit the joint model using splines for the subject-specific # longitudinal trajectories and a spline-approximated baseline # risk function lmeFit <- lme(log(serBilir) ~ ns(year, 3), random = list(id = pdDiag(form = ~ ns(year, 3))), data = pbc2) survFit <- coxph(Surv(years, status2) ~ drug, data = pbc2.id, x = TRUE) jointFit <- jointModel(lmeFit, survFit, timeVar = "year", method = "piecewise-PH-aGH") # AUC using data up to year 5 with horizon at year 8 aucJM(jointFit, pbc2, Tstart = 5, Thoriz = 8) ## End(Not run)
## Not run: # we construct the composite event indicator (transplantation or death) pbc2$status2 <- as.numeric(pbc2$status != "alive") pbc2.id$status2 <- as.numeric(pbc2.id$status != "alive") # we fit the joint model using splines for the subject-specific # longitudinal trajectories and a spline-approximated baseline # risk function lmeFit <- lme(log(serBilir) ~ ns(year, 3), random = list(id = pdDiag(form = ~ ns(year, 3))), data = pbc2) survFit <- coxph(Surv(years, status2) ~ drug, data = pbc2.id, x = TRUE) jointFit <- jointModel(lmeFit, survFit, timeVar = "year", method = "piecewise-PH-aGH") # AUC using data up to year 5 with horizon at year 8 aucJM(jointFit, pbc2, Tstart = 5, Thoriz = 8) ## End(Not run)
Extracts estimated coefficients from fitted joint models.
## S3 method for class 'jointModel' coef(object, process = c("Longitudinal", "Event"), include.splineCoefs = FALSE, ...) ## S3 method for class 'jointModel' fixef(object, process = c("Longitudinal", "Event"), include.splineCoefs = FALSE, ...)
## S3 method for class 'jointModel' coef(object, process = c("Longitudinal", "Event"), include.splineCoefs = FALSE, ...) ## S3 method for class 'jointModel' fixef(object, process = c("Longitudinal", "Event"), include.splineCoefs = FALSE, ...)
object |
an object inheriting from class |
process |
for which model (i.e., linear mixed model or survival model) to extract the estimated coefficients. |
include.splineCoefs |
logical; if |
... |
additional arguments; currently none is used. |
When process = "Event"
both methods return the same output. However, for process = "Longitudinal"
,
the coef()
method returns the subject-specific coefficients, whereas fixef()
only the fixed effects.
A numeric vector or a matrix of the estimated parameters for the fitted model.
Dimitris Rizopoulos [email protected]
## Not run: # 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 fitJOINT <- jointModel(fitLME, fitCOX, timeVar = "obstime") # fixed effects for the longitudinal process fixef(fitJOINT) # fixed effects + random effects estimates for the longitudinal # process coef(fitJOINT) # fixed effects for the event process fixef(fitJOINT, process = "Event") coef(fitJOINT, process = "Event") ## End(Not run)
## Not run: # 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 fitJOINT <- jointModel(fitLME, fitCOX, timeVar = "obstime") # fixed effects for the longitudinal process fixef(fitJOINT) # fixed effects + random effects estimates for the longitudinal # process coef(fitJOINT) # fixed effects for the event process fixef(fitJOINT, process = "Event") coef(fitJOINT, process = "Event") ## End(Not run)
In a competing risks setting this function expands the data frame with a single row per subject to the a data frame in long format in which each subject has as many rows as the number of competing events.
crLong(data, statusVar, censLevel, nameStrata = "strata", nameStatus = "status2")
crLong(data, statusVar, censLevel, nameStrata = "strata", nameStatus = "status2")
data |
the data frame containing the competing risk data with a single row per subject. |
statusVar |
a character string denoting the name of the variable in
|
censLevel |
a character string or a scalar denoting the censoring level
in the |
nameStrata |
a character string denoting the variable that will be added
in the long version of |
nameStatus |
a character string denoting the variable that will be added
in the long version of |
A data frame in the long format with multiple rows per subject.
Dimitris Rizopoulos [email protected]
Rizopoulos, D. (2012) Joint Models for Longitudinal and Time-to-Event Data: with Applications in R. Boca Raton: Chapman and Hall/CRC.
Putter, H., Fiocco, M., and Geskus, R. (2007). Tutorial in biostatistics: Competing risks and multi-state models. Statistics in Medicine 26, 2389–2430.
head(crLong(pbc2.id, "status", "alive"))
head(crLong(pbc2.id, "status", "alive"))
Numerical derivatives and integrals of functions bs()
and ns()
at their first argument.
dns(x, df = NULL, knots = NULL, intercept = FALSE, Boundary.knots = range(x), eps = 1e-03) dbs(x, df = NULL, knots = NULL, intercept = FALSE, Boundary.knots = range(x), eps = 1e-03) ins(x, df = NULL, knots = NULL, intercept = FALSE, Boundary.knots = range(x), from = 0, weight.fun = NULL, ...) ibs(x, df = NULL, knots = NULL, intercept = FALSE, Boundary.knots = range(x), from = 0, weight.fun = NULL, ...)
dns(x, df = NULL, knots = NULL, intercept = FALSE, Boundary.knots = range(x), eps = 1e-03) dbs(x, df = NULL, knots = NULL, intercept = FALSE, Boundary.knots = range(x), eps = 1e-03) ins(x, df = NULL, knots = NULL, intercept = FALSE, Boundary.knots = range(x), from = 0, weight.fun = NULL, ...) ibs(x, df = NULL, knots = NULL, intercept = FALSE, Boundary.knots = range(x), from = 0, weight.fun = NULL, ...)
x , df , knots , intercept , Boundary.knots
|
see the help pages of functions |
eps |
a numeric scalar denoting the step length for the central difference approximation, which calculates the derivative. |
from |
a numeric scalar denoting the lower limit of the integral. |
weight.fun |
a function to applied as weights. |
... |
extra arguments passed to |
an object of class dns
, dbs
, ins
or ibs
.
Dimitris Rizopoulos [email protected]
x <- rnorm(10) dns(x, df = 4) ins(x, df = 4)
x <- rnorm(10) dns(x, df = 4) ins(x, df = 4)
This function computes a dynamic discrimination index for joint models based on a weighted average of time-dependent AUCs.
dynCJM(object, newdata, Dt, ...) ## S3 method for class 'jointModel' dynCJM(object, newdata, Dt, idVar = "id", t.max = NULL, simulate = FALSE, M = 100, weightFun = NULL, ...)
dynCJM(object, newdata, Dt, ...) ## S3 method for class 'jointModel' dynCJM(object, newdata, Dt, idVar = "id", t.max = NULL, simulate = FALSE, M = 100, weightFun = NULL, ...)
object |
an object inheriting from class |
newdata |
a data frame that contains the longitudinal and covariate information for the subjects for which prediction
of survival probabilities is required. The names of the variables in this data frame must be the same as in the data frames that
were used to fit the linear mixed effects model (using |
Dt |
a numeric scalar denoting the time frame within which the occurrence of events is of interest. |
idVar |
the name of the variable in |
t.max |
a numeric scalar denoting the time maximum follow-up time up to which the dynamic discrimination index is to be calculated.
If |
simulate |
logical; if |
M |
a numeric scalar denoting the number of Monte Carlo samples; see |
weightFun |
a function of two arguments the first denoting time and the second the length of the time frame of interest, i.e., |
... |
additional arguments; currently none is used. |
(Note: The following contain some math formulas, which are better viewed in the pdf version of the manual accessible at https://cran.r-project.org/package=JM.)
Function dynC
computes the following discrimination index
where
and
with and
denote a randomly selected pair subjects, and
and
denote the conditional survival probabilities calculated by
survfitJM
for these two subjects, for different time windows specified by argument
Dt
.
The upper limit of integral in specified by argument t.max
. The integrals in the numerator and denominator
are approximated using a 15-point Gauss-Kronrod quadrature rule.
Index is in the spirit of Harrell's
-index, that is for the comparable
subjects (i.e., the ones whose observed event times can be ordered), we compare their dynamic survival
probabilities calculated by
survfitJM
. As with Harrell's -index,
does not take into account censoring, and therefore is expected to mask the
true discriminative capability of the joint model under heavy censoring.
A list of class dynCJM
with components:
dynC |
a numeric scalar denoting the dynamic discrimination index. |
times |
a numeric vector of time points at which the AUC was calculated. |
AUCs |
a numeric vector of the estimated AUCs at the aforementioned time points. |
weights |
a numeric vector of the estimated weights at the aforementioned time points. |
t.max |
a copy of the |
Dt |
a copy of the |
classObject |
the class of |
nameObject |
the name of |
Dimitris Rizopoulos [email protected]
Antolini, L., Boracchi, P., and Biganzoli, E. (2005). A time-dependent discrimination index for survival data. Statistics in Medicine 24, 3927–3944.
Harrell, F., Kerry, L. and Mark, D. (1996). Multivariable prognostic models: issues in developing models, evaluating assumptions and adequacy, and measuring and reducing errors. Statistics in Medicine 15, 361–387.
Heagerty, P. and Zheng, Y. (2005). Survival model predictive accuracy and ROC curves. Biometrics 61, 92–105.
Rizopoulos, D. (2012) Joint Models for Longitudinal and Time-to-Event Data: with Applications in R. Boca Raton: Chapman and Hall/CRC.
Rizopoulos, D. (2011). Dynamic predictions and prospective accuracy in joint models for longitudinal and time-to-event data. Biometrics 67, 819–829.
Rizopoulos, D., Murawska, M., Andrinopoulou, E.-R., Lesaffre, E. and Takkenberg, J. (2013). Dynamic predictions with time-dependent covariates in survival analysis: A comparison between joint modeling and landmarking. under preparation.
## Not run: # we construct the composite event indicator (transplantation or death) pbc2$status2 <- as.numeric(pbc2$status != "alive") pbc2.id$status2 <- as.numeric(pbc2.id$status != "alive") # we fit the joint model using splines for the subject-specific # longitudinal trajectories and a spline-approximated baseline # risk function lmeFit <- lme(log(serBilir) ~ ns(year, 3), random = list(id = pdDiag(form = ~ ns(year, 3))), data = pbc2) survFit <- coxph(Surv(years, status2) ~ drug, data = pbc2.id, x = TRUE) jointFit <- jointModel(lmeFit, survFit, timeVar = "year", method = "piecewise-PH-aGH") # dynamic discrimination index up to year 10 using a two-year interval dynCJM(jointFit, pbc2, Dt = 2, t.max = 10) ## End(Not run)
## Not run: # we construct the composite event indicator (transplantation or death) pbc2$status2 <- as.numeric(pbc2$status != "alive") pbc2.id$status2 <- as.numeric(pbc2.id$status != "alive") # we fit the joint model using splines for the subject-specific # longitudinal trajectories and a spline-approximated baseline # risk function lmeFit <- lme(log(serBilir) ~ ns(year, 3), random = list(id = pdDiag(form = ~ ns(year, 3))), data = pbc2) survFit <- coxph(Surv(years, status2) ~ drug, data = pbc2.id, x = TRUE) jointFit <- jointModel(lmeFit, survFit, timeVar = "year", method = "piecewise-PH-aGH") # dynamic discrimination index up to year 10 using a two-year interval dynCJM(jointFit, pbc2, Dt = 2, t.max = 10) ## End(Not run)
Calculates fitted values for joint models.
## S3 method for class 'jointModel' fitted(object, process = c("Longitudinal", "Event"), type = c("Marginal", "Subject", "EventTime", "Slope"), scale = c("survival", "cumulative-Hazard", "log-cumulative-Hazard"), M = 200, ...)
## S3 method for class 'jointModel' fitted(object, process = c("Longitudinal", "Event"), type = c("Marginal", "Subject", "EventTime", "Slope"), scale = c("survival", "cumulative-Hazard", "log-cumulative-Hazard"), M = 200, ...)
object |
an object inheriting from class |
process |
for which model (i.e., linear mixed model or survival model) to calculate the fitted values. |
type |
what type of fitted values to calculate for the survival outcome. See Details. |
scale |
in which scale to calculate; relevant only when |
M |
how many times to simulate random effects; see Details for more info. |
... |
additional arguments; currently none is used. |
For process = "Longitudinal"
, let denote the design matrix for the fixed effects
, and
the design matrix for the random effects
. Then for
type = "Marginal"
the fitted values are
whereas for
type = "Subject"
they are . For
type = "EventTime"
is the same as type = "Subject"
but evaluated at the observed event times. Finally, type == "Slope"
returns where
and
denote the fixed- and random-effects design
matrices corresponding to the slope term which is specified in the
derivForm
argument of jointModel
.
For process = "Event"
and type = "Subject"
the linear predictor conditional on the random effects
estimates is calculated for each sample unit. Depending on the value of the scale
argument the fitted survival
function, cumulative hazard function or log cumulative hazard function is returned. For type = "Marginal"
,
random effects values for each sample unit are simulated M
times from a normal distribution with zero mean and
covariance matrix the estimated covariance matrix for the random effects. The marginal survival function for the
th sample unit is approximated by
where denotes the normal probability density function, and
the
th
simulated value for the random effect of the
th sample unit. The cumulative hazard and log cumulative hazard
functions are calculated as
and
respectively.
a numeric vector of fitted values.
Dimitris Rizopoulos [email protected]
Rizopoulos, D. (2012) Joint Models for Longitudinal and Time-to-Event Data: with Applications in R. Boca Raton: Chapman and Hall/CRC.
Rizopoulos, D. (2010) JM: An R Package for the Joint Modelling of Longitudinal and Time-to-Event Data. Journal of Statistical Software 35 (9), 1–33. doi:10.18637/jss.v035.i09
## Not run: # linear mixed model fit fitLME <- lme(log(serBilir) ~ drug * year, random = ~ 1 | id, data = pbc2) # survival regression fit fitSURV <- survreg(Surv(years, status2) ~ drug, data = pbc2.id, x = TRUE) # joint model fit, under the (default) Weibull model fitJOINT <- jointModel(fitLME, fitSURV, timeVar = "year") # fitted for the longitudinal process head(cbind( "Marg" = fitted(fitJOINT), "Subj" = fitted(fitJOINT, type = "Subject") )) # fitted for the event process - survival function head(cbind( "Marg" = fitted(fitJOINT, process = "Ev"), "Subj" = fitted(fitJOINT, process = "Ev", type = "Subject") )) # fitted for the event process - cumulative hazard function head(cbind( "Marg" = fitted(fitJOINT, process = "Ev", scale = "cumulative-Hazard"), "Subj" = fitted(fitJOINT, process = "Ev", type = "Subject", scale = "cumulative-Hazard") )) ## End(Not run)
## Not run: # linear mixed model fit fitLME <- lme(log(serBilir) ~ drug * year, random = ~ 1 | id, data = pbc2) # survival regression fit fitSURV <- survreg(Surv(years, status2) ~ drug, data = pbc2.id, x = TRUE) # joint model fit, under the (default) Weibull model fitJOINT <- jointModel(fitLME, fitSURV, timeVar = "year") # fitted for the longitudinal process head(cbind( "Marg" = fitted(fitJOINT), "Subj" = fitted(fitJOINT, type = "Subject") )) # fitted for the event process - survival function head(cbind( "Marg" = fitted(fitJOINT, process = "Ev"), "Subj" = fitted(fitJOINT, process = "Ev", type = "Subject") )) # fitted for the event process - cumulative hazard function head(cbind( "Marg" = fitted(fitJOINT, process = "Ev", scale = "cumulative-Hazard"), "Subj" = fitted(fitJOINT, process = "Ev", type = "Subject", scale = "cumulative-Hazard") )) ## End(Not run)
This package fits shared parameter models for the joint modeling of normal longitudinal responses and event times under a maximum likelihood approach. Various options for the survival model and optimization/integration algorithms are provided.
Package: | JM |
Type: | Package |
Version: | 1.5-2 |
Date: | 2022-08-08 |
License: | GPL |
The package has a single model-fitting function called jointModel
, which accepts as main arguments a linear
mixed effects object fit returned by function lme()
of package nlme, and a survival object fit returned
by either function coxph()
or function survreg()
of package survival. In addition, the method
argument of jointModel()
specifies the type of the survival submodel to be fitted and the type of the numerical
integration technique; available options are:
"Cox-PH-GH"
the time-dependent version of a proportional hazards model with unspecified baseline hazard function. The Gauss-Hermite integration rule is used to approximate the required integrals. (This option corresponds to the joint model proposed by Wulfsohn and Tsiatis, 1997)
"weibull-PH-GH"
the Weibull model under the proportional hazards formulation. The Gauss-Hermite integration rule is used to approximate the required integrals.
"weibull-AFT-GH"
the Weibull model under the accelerated failure time formulation. The Gauss-Hermite integration rule is used to approximate the required integrals.
"piecewise-PH-GH"
a proportional hazards model with a piecewise constant baseline risk function. The Gauss-Hermite integration rule is used to approximate the required integrals.
"spline-PH-GH"
a proportional hazards model, in which the log baseline hazard is approximated using B-splines. The Gauss-Hermite integration rule is used to approximate the required integrals.
"ch-Laplace"
an additive log cumulative hazard model, in which the log cumulative baseline hazard is approximated using B-splines. A fully exponential Laplace approximation method is used to approximate the required integrals (Rizopoulos et al., 2009).
For all the above mentioned options (except the last one), a pseudo-adaptive Gauss-Hermite integration rule is also available (Rizopoulos, 2012b). This is much faster than the classical Gauss-Hermite rule, and in several simulations it has been shown to perform equally well (though its performance is still under investigation).
The package also offers several utility functions that can extract useful information from fitted joint models. The most important of those are included in the See also section below.
Dimitris Rizopoulos
Maintainer: Dimitris Rizopoulos <[email protected]>
Henderson, R., Diggle, P. and Dobson, A. (2000) Joint modelling of longitudinal measurements and event time data. Biostatistics 1, 465–480.
Rizopoulos, D. (2012a) Joint Models for Longitudinal and Time-to-Event Data: with Applications in R. Boca Raton: Chapman and Hall/CRC.
Rizopoulos, D. (2012b) Fast fitting of joint models for longitudinal and event time data using a pseudo-adaptive Gaussian quadrature rule. Computational Statistics and Data Analysis 56, 491–501.
Rizopoulos, D. (2011) Dynamic predictions and prospective accuracy in joint models for longitudinal and time-to-event data. Biometrics 67, 819–829.
Rizopoulos, D. (2010) JM: An R package for the joint modelling of longitudinal and time-to-event data. Journal of Statistical Software 35 (9), 1–33. doi:10.18637/jss.v035.i09
Rizopoulos, D., Verbeke, G. and Lesaffre, E. (2009) Fully exponential Laplace approximation for the joint modelling of survival and longitudinal data. Journal of the Royal Statistical Society, Series B 71, 637–654.
Rizopoulos, D., Verbeke, G. and Molenberghs, G. (2010) Multiple-imputation-based residuals and diagnostic plots for joint models of longitudinal and survival outcomes. Biometrics 66, 20–29.
Tsiatis, A. and Davidian, M. (2004) Joint modeling of longitudinal and time-to-event data: an overview. Statistica Sinica 14, 809–834.
Wulfsohn, M. and Tsiatis, A. (1997) A joint model for survival and longitudinal data measured with error. Biometrics 53, 330–339.
jointModel
,
survfitJM
,
rocJM
,
aucJM
,
dynCJM
,
prederrJM
,
predict
This function fits shared parameter models for the joint modelling of normal longitudinal responses and time-to-event data under a maximum likelihood approach. Various options for the survival model are available.
jointModel(lmeObject, survObject, timeVar, parameterization = c("value", "slope", "both"), method = c("weibull-PH-aGH", "weibull-PH-GH", "weibull-AFT-aGH", "weibull-AFT-GH", "piecewise-PH-aGH", "piecewise-PH-GH", "Cox-PH-aGH", "Cox-PH-GH", "spline-PH-aGH", "spline-PH-GH", "ch-Laplace"), interFact = NULL, derivForm = NULL, lag = 0, scaleWB = NULL, CompRisk = FALSE, init = NULL, control = list(), ...)
jointModel(lmeObject, survObject, timeVar, parameterization = c("value", "slope", "both"), method = c("weibull-PH-aGH", "weibull-PH-GH", "weibull-AFT-aGH", "weibull-AFT-GH", "piecewise-PH-aGH", "piecewise-PH-GH", "Cox-PH-aGH", "Cox-PH-GH", "spline-PH-aGH", "spline-PH-GH", "ch-Laplace"), interFact = NULL, derivForm = NULL, lag = 0, scaleWB = NULL, CompRisk = FALSE, init = NULL, control = list(), ...)
lmeObject |
an object inheriting from class |
survObject |
an object inheriting from class |
timeVar |
a character string indicating the time variable in the linear mixed effects model. |
parameterization |
a character string indicating the type of parameterization. See Details |
method |
a character string specifying the type of joint model to fit. See Details. |
interFact |
a list with components |
derivForm |
a list with components |
lag |
a numeric scalar denoting a lag effect in the time-dependent covariate represented by the mixed model; default is 0. |
scaleWB |
a numeric scalar denoting a fixed value for the scale parameter of the Weibull hazard; used only when
|
CompRisk |
logical; should a competing risks joint model be fitted. |
init |
a named list of user-specified initial values:
When this list of initial values does not contain some of these components or contains components not of the appropriate length, then the default initial values are used instead. |
control |
a list of control values with components:
|
... |
options passed to the |
Function jointModel
fits joint models for longitudinal and survival data (more detailed information about the formulation of these
models can be found in Rizopoulos (2010)). For the longitudinal responses the linear mixed effects model represented by the lmeObject
is
assumed. For the survival times let denote the vector of baseline covariates in
survObject
, with associated parameter vector
,
the value of the longitudinal outcome at time point
as approximated by the linear mixed model
(i.e.,
equals the fixed-effects part
+
random-effects part of the linear mixed effects model for sample unit ),
the association parameter for
,
the derivative of
with respect to
, and
the association parameter for
. Then, for
method = "weibull-AFT-GH"
a time-dependent Weibull model under
the accelerated failure time formulation is assumed. For method = "weibull-PH-GH"
a time-dependent relative risk model is postulated
with a Weibull baseline risk function. For method = "piecewise-PH-GH"
a time-dependent relative risk model is postulated with a
piecewise constant baseline risk function. For method = "spline-PH-GH"
a time-dependent relative risk model is assumed in which the
log baseline risk function is approximated using B-splines. For method = "ch-Laplace"
an additive model on the log cumulative hazard
scale is assumed (see Rizopoulos et al., 2009 for more info). Finally, for method = "Cox-PH-GH"
a time-dependent relative risk model
is assumed where the baseline risk function is left unspecified (Wulfsohn and Tsiatis, 1997). For all these options the linear predictor for the
survival submodel is written as
when
parameterization = "value"
,
when parameterization = "slope"
, and
when parameterization = "both"
, where in all the above the value
of is specified by the
lag
argument and . If
interFact
is specified, then
and/or
are multiplied with the design matrices derived from the formulas
supplied as the first two arguments of
interFact
, respectively. In this case and/or
become vectors of
association parameters.
For method = "spline-PH-GH"
it is also allowed to include stratification factors. These should be included in the specification of
the survObject
using function strata()
. Note that in this case survObject
must only be a 'coxph' object.
For all survival models except for the time-dependent proportional hazards model, the optimization algorithm starts
with EM iterations, and if convergence is not achieved, it switches to quasi-Newton iterations (i.e., BFGS in
optim()
or nlminb()
, depending on the value of the optimizer
control argument). For method = "Cox-PH-GH"
only the
EM algorithm is used. During the EM iterations, convergence is declared if either of the following two conditions is satisfied: (i)
, or (ii)
, where
and
is the vector of parameter values at the current and previous iterations, respectively, and
is the
log-likelihood function. The values for
,
and
are specified via the
control
argument. During the
quasi-Newton iterations, the default convergence criteria of either optim()
or nlminb()
are used.
The required integrals are approximated using the standard Gauss-Hermite quadrature rule when the chosen option for the method
argument contains the string "GH", and the (pseudo) adaptive Gauss-Hermite rule when the chosen option for the method
argument contains the string "aGH". For method = "ch-Laplace"
the fully exponential Laplace approximation described in
Rizopoulos et al. (2009) is used. The (pseudo) adaptive Gauss-Hermite and the Laplace approximation are particularly useful when
high-dimensional random effects vectors are considered (e.g., when modelling nonlinear subject-specific trajectories with splines
or high-order polynomials).
See jointModelObject
for the components of the fit.
1. The lmeObject
argument should represent a linear mixed model object with a simple random-effects
structure, i.e., only the pdDiag()
class is currently allowed.
2. The lmeObject
object should not contain any within-group correlation structure (i.e., correlation
argument of lme()
) or within-group heteroscedasticity structure (i.e., weights
argument of lme()
).
3. It is assumed that the linear mixed effects model lmeObject
and the survival model survObject
have been
fitted to the same subjects. Moreover, it is assumed that the ordering of the subjects is the same for both
lmeObject
and survObject
, i.e., that the first line in the data frame containing the event times
corresponds to the first set of lines identified by the grouping variable in the data frame containing the repeated
measurements, and so on.
4. In the print
and summary
generic functions for class jointModel
, the estimated coefficients (and
standard errors for the summary
generic) for the event process are augmented with the element "Assoct" that
corresponds to the association parameter and the element "Assoct.s" that corresponds to the parameter
when
parameterization
is "slope"
or "both"
(see Details).
5. The standard errors returned by the summary
generic function for class jointModel
when
method = "Cox-PH-GH"
are based on the profile score vector (i.e., given the NPMLE for the unspecified baseline
hazard). Hsieh et al. (2006) have noted that these standard errors are underestimated.
6. As it is the case for all types of mixed models that require numerical integration, it is advisable (especially in difficult datasets) to check the stability of the maximum likelihood estimates with an increasing number of Gauss-Hermite quadrature points.
7. It is assumed that the scale of the time variable (e.g., days, months years) is the same in both lmeObject
and survObject
.
Dimitris Rizopoulos [email protected]
Henderson, R., Diggle, P. and Dobson, A. (2000) Joint modelling of longitudinal measurements and event time data. Biostatistics 1, 465–480.
Hsieh, F., Tseng, Y.-K. and Wang, J.-L. (2006) Joint modeling of survival and longitudinal data: Likelihood approach revisited. Biometrics 62, 1037–1043.
Rizopoulos, D. (2012a) Joint Models for Longitudinal and Time-to-Event Data: with Applications in R. Boca Raton: Chapman and Hall/CRC.
Rizopoulos, D. (2012b) Fast fitting of joint models for longitudinal and event time data using a pseudo-adaptive Gaussian quadrature rule. Computational Statistics and Data Analysis 56, 491–501.
Rizopoulos, D. (2011) Dynamic predictions and prospective accuracy in joint models for longitudinal and time-to-event data. Biometrics 67, 819–829.
Rizopoulos, D. (2010) JM: An R package for the joint modelling of longitudinal and time-to-event data. Journal of Statistical Software 35 (9), 1–33. doi:10.18637/jss.v035.i09
Rizopoulos, D., Verbeke, G. and Lesaffre, E. (2009) Fully exponential Laplace approximations for the joint modelling of survival and longitudinal data. Journal of the Royal Statistical Society, Series B 71, 637–654.
Rizopoulos, D., Verbeke, G. and Molenberghs, G. (2010) Multiple-imputation-based residuals and diagnostic plots for joint models of longitudinal and survival outcomes. Biometrics 66, 20–29.
Tsiatis, A. and Davidian, M. (2004) Joint modeling of longitudinal and time-to-event data: an overview. Statistica Sinica 14, 809–834.
Wulfsohn, M. and Tsiatis, A. (1997) A joint model for survival and longitudinal data measured with error. Biometrics 53, 330–339.
jointModelObject
,
anova.jointModel
,
coef.jointModel
,
fixef.jointModel
,
ranef.jointModel
,
fitted.jointModel
,
residuals.jointModel
,
plot.jointModel
,
survfitJM
,
rocJM
,
dynCJM
,
aucJM
,
prederrJM
## Not run: # linear mixed model fit (random intercepts) fitLME <- lme(log(serBilir) ~ drug * year, random = ~ 1 | id, data = pbc2) # survival regression fit fitSURV <- survreg(Surv(years, status2) ~ drug, data = pbc2.id, x = TRUE) # joint model fit, under the (default) Weibull model fitJOINT <- jointModel(fitLME, fitSURV, timeVar = "year") fitJOINT summary(fitJOINT) # linear mixed model fit (random intercepts + random slopes) fitLME <- lme(log(serBilir) ~ drug * year, random = ~ year | id, data = pbc2) # survival regression fit fitSURV <- survreg(Surv(years, status2) ~ drug, data = pbc2.id, x = TRUE) # joint model fit, under the (default) Weibull model fitJOINT <- jointModel(fitLME, fitSURV, timeVar = "year") fitJOINT summary(fitJOINT) # we also include an interaction term of log(serBilir) with drug fitJOINT <- jointModel(fitLME, fitSURV, timeVar = "year", interFact = list(value = ~ drug, data = pbc2.id)) fitJOINT summary(fitJOINT) # a joint model in which the risk for and event depends both on the true value of # marker and the true value of the slope of the longitudinal trajectory lmeFit <- lme(sqrt(CD4) ~ obstime * drug, random = ~ obstime | patient, data = aids) coxFit <- coxph(Surv(Time, death) ~ drug, data = aids.id, x = TRUE) # to fit this model we need to specify the 'derivForm' argument, which is a list # with first component the derivative of the fixed-effects formula of 'lmeFit' with # respect to 'obstime', second component the indicator of which fixed-effects # coefficients correspond to the previous defined formula, third component the # derivative of the random-effects formula of 'lmeFit' with respect to 'obstime', # and fourth component the indicator of which random-effects correspond to the # previous defined formula dForm <- list(fixed = ~ 1 + drug, indFixed = c(2, 4), random = ~ 1, indRandom = 2) jointModel(lmeFit, coxFit, timeVar = "obstime", method = "spline-PH-aGH", parameterization = "both", derivForm = dForm) # Competing Risks joint model # we first expand the PBC dataset in the competing risks long format # with two competing risks being death and transplantation pbc2.idCR <- crLong(pbc2.id, "status", "alive") # we fit the linear mixed model as before lmeFit.pbc <- lme(log(serBilir) ~ drug * ns(year, 3), random = list(id = pdDiag(form = ~ ns(year, 3))), data = pbc2) # however, for the survival model we need to use the data in the long # format, and include the competing risks indicator as a stratification # factor. We also take interactions of the baseline covariates with the # stratification factor in order to allow the effect of these covariates # to be different for each competing risk coxCRFit.pbc <- coxph(Surv(years, status2) ~ (drug + sex)*strata + strata(strata), data = pbc2.idCR, x = TRUE) # the corresponding joint model is fitted simply by including the above # two submodels as main arguments, setting argument CompRisk to TRUE, # and choosing as method = "spline-PH-aGH". Similarly as above, we also # include strata as an interaction factor to allow serum bilirubin to # have a different effect for each of the two competing risks jmCRFit.pbc <- jointModel(lmeFit.pbc, coxCRFit.pbc, timeVar = "year", method = "spline-PH-aGH", interFact = list(value = ~ strata, data = pbc2.idCR), CompRisk = TRUE) summary(jmCRFit.pbc) # 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 with a spline-approximated baseline hazard function fitJOINT <- jointModel(fitLME, fitCOX, timeVar = "obstime", method = "spline-PH-aGH") fitJOINT summary(fitJOINT) ## End(Not run)
## Not run: # linear mixed model fit (random intercepts) fitLME <- lme(log(serBilir) ~ drug * year, random = ~ 1 | id, data = pbc2) # survival regression fit fitSURV <- survreg(Surv(years, status2) ~ drug, data = pbc2.id, x = TRUE) # joint model fit, under the (default) Weibull model fitJOINT <- jointModel(fitLME, fitSURV, timeVar = "year") fitJOINT summary(fitJOINT) # linear mixed model fit (random intercepts + random slopes) fitLME <- lme(log(serBilir) ~ drug * year, random = ~ year | id, data = pbc2) # survival regression fit fitSURV <- survreg(Surv(years, status2) ~ drug, data = pbc2.id, x = TRUE) # joint model fit, under the (default) Weibull model fitJOINT <- jointModel(fitLME, fitSURV, timeVar = "year") fitJOINT summary(fitJOINT) # we also include an interaction term of log(serBilir) with drug fitJOINT <- jointModel(fitLME, fitSURV, timeVar = "year", interFact = list(value = ~ drug, data = pbc2.id)) fitJOINT summary(fitJOINT) # a joint model in which the risk for and event depends both on the true value of # marker and the true value of the slope of the longitudinal trajectory lmeFit <- lme(sqrt(CD4) ~ obstime * drug, random = ~ obstime | patient, data = aids) coxFit <- coxph(Surv(Time, death) ~ drug, data = aids.id, x = TRUE) # to fit this model we need to specify the 'derivForm' argument, which is a list # with first component the derivative of the fixed-effects formula of 'lmeFit' with # respect to 'obstime', second component the indicator of which fixed-effects # coefficients correspond to the previous defined formula, third component the # derivative of the random-effects formula of 'lmeFit' with respect to 'obstime', # and fourth component the indicator of which random-effects correspond to the # previous defined formula dForm <- list(fixed = ~ 1 + drug, indFixed = c(2, 4), random = ~ 1, indRandom = 2) jointModel(lmeFit, coxFit, timeVar = "obstime", method = "spline-PH-aGH", parameterization = "both", derivForm = dForm) # Competing Risks joint model # we first expand the PBC dataset in the competing risks long format # with two competing risks being death and transplantation pbc2.idCR <- crLong(pbc2.id, "status", "alive") # we fit the linear mixed model as before lmeFit.pbc <- lme(log(serBilir) ~ drug * ns(year, 3), random = list(id = pdDiag(form = ~ ns(year, 3))), data = pbc2) # however, for the survival model we need to use the data in the long # format, and include the competing risks indicator as a stratification # factor. We also take interactions of the baseline covariates with the # stratification factor in order to allow the effect of these covariates # to be different for each competing risk coxCRFit.pbc <- coxph(Surv(years, status2) ~ (drug + sex)*strata + strata(strata), data = pbc2.idCR, x = TRUE) # the corresponding joint model is fitted simply by including the above # two submodels as main arguments, setting argument CompRisk to TRUE, # and choosing as method = "spline-PH-aGH". Similarly as above, we also # include strata as an interaction factor to allow serum bilirubin to # have a different effect for each of the two competing risks jmCRFit.pbc <- jointModel(lmeFit.pbc, coxCRFit.pbc, timeVar = "year", method = "spline-PH-aGH", interFact = list(value = ~ strata, data = pbc2.idCR), CompRisk = TRUE) summary(jmCRFit.pbc) # 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 with a spline-approximated baseline hazard function fitJOINT <- jointModel(fitLME, fitCOX, timeVar = "obstime", method = "spline-PH-aGH") fitJOINT summary(fitJOINT) ## End(Not run)
An object returned by the jointModel
function, inheriting from class jointModel
and representing a fitted
joint model for longitudinal and time-to-event data. Objects of this class have methods for the generic functions
anova
, coef
, fitted
, fixed.effects
, logLik
, plot
, print
,
random.effects
, residuals
, summary
, and vcov
.
The following components must be included in a legitimate jointModel
object.
coefficients |
a list with the estimated coefficients. The components of this list are:
|
Hessian |
the Hessian matrix evaluated at the estimated parameter values. |
logLik |
the log-likelihood value. |
EB |
a list with components:
|
knots |
the numeric vector of the knots positions; returned only when |
iters |
the number of iterations in the optimization algorithm. |
convergence |
convergence identifier: 0 corresponds to successful convergence, whereas 1 to a problem (i.e., when 1, usually more iterations are required). |
n |
the number of sample units. |
N |
the total number of repeated measurements for the longitudinal outcome. |
ni |
a vector with the number of repeated measurements for each sample unit. |
d |
a numeric vector with 0 denoting censored observation and 1 events. |
id |
the grouping vector for the longitudinal responses. |
x |
a list with the design matrices for the longitudinal and event processes. |
y |
a list with the response vectors for the longitudinal and event processes. |
data.id |
a |
method |
the value of the |
termsY |
the |
termsT |
the |
formYx |
the formula for the fixed effects part of the longitudinal model. |
formYz |
the formula for the random effects part of the longitudinal model. |
formT |
the formula for the survival model. |
timeVar |
the value of the |
control |
the value of the |
parameterization |
the value of the |
interFact |
the value of the |
derivForm |
the value of the |
lag |
the value of the |
call |
the matched call. |
Dimitris Rizopoulos [email protected]
Followup of 312 randomised patients with primary biliary cirrhosis, a rare autoimmune liver disease, at Mayo Clinic.
A data frame with 1945 observations on the following 20 variables.
id
patients identifier; in total there are 312 patients.
years
number of years between registration and the earlier of death, transplantion, or study analysis time.
status
a factor with levels alive
, transplanted
and dead
.
drug
a factor with levels placebo
and D-penicil
.
age
at registration in years.
sex
a factor with levels male
and female
.
year
number of years between enrollment and this visit date, remaining values on the line of data refer to this visit.
ascites
a factor with levels No
and Yes
.
hepatomegaly
a factor with levels No
and Yes
.
spiders
a factor with levels No
and Yes
.
edema
a factor with levels No edema
(i.e., no edema and no diuretic therapy for edema),
edema no diuretics
(i.e., edema present without diuretics, or edema resolved by diuretics), and
edema despite diuretics
(i.e., edema despite diuretic therapy).
serBilir
serum bilirubin in mg/dl.
serChol
serum cholesterol in mg/dl.
albumin
albumin in gm/dl.
alkaline
alkaline phosphatase in U/liter.
SGOT
SGOT in U/ml.
platelets
platelets per cubic ml / 1000.
prothrombin
prothrombin time in seconds.
histologic
histologic stage of disease.
status2
a numeric vector with the value 1 denoting if the patient was dead, and 0 if the patient was alive or transplanted.
The data frame pbc2.id
contains the first measurement for each patient. This data frame is used to
fit the survival model.
Fleming, T. and Harrington, D. (1991) Counting Processes and Survival Analysis. Wiley, New York.
Therneau, T. and Grambsch, P. (2000) Modeling Survival Data: Extending the Cox Model. Springer-Verlag, New York.
summary(pbc2.id)
summary(pbc2.id)
Based on a fitted Cox model this function fits the corresponding relative risk model with a piecewise constant baseline hazard using the Poisson regression equivalence
piecewiseExp.ph(coxObject, knots = NULL, length.knots = 6)
piecewiseExp.ph(coxObject, knots = NULL, length.knots = 6)
coxObject |
an object of class |
knots |
A numeric vector denoting the internal knots (cut points) defining the intervals in which the baseline hazard is assumed constant. |
length.knots |
a numeric value denoting the number of internal knots to use in the fit.
Used when |
an object of class glm
.
Dimitris Rizopoulos [email protected]
Rizopoulos, D. (2012) Joint Models for Longitudinal and Time-to-Event Data: with Applications in R. Boca Raton: Chapman and Hall/CRC.
coxFit <- coxph(Surv(Time, death) ~ drug, data = aids.id, x = TRUE) piecewiseExp.ph(coxFit)
coxFit <- coxph(Surv(Time, death) ~ drug, data = aids.id, x = TRUE) piecewiseExp.ph(coxFit)
Produces a variety of plots for fitted joint models.
## S3 method for class 'jointModel' plot(x, which = 1:4, caption = c("Residuals vs Fitted", "Normal Q-Q", "Marginal Survival", "Marginal Cumulative Hazard", "Marginal log Cumulative Hazard", "Baseline Hazard", "Cumulative Baseline Hazard", "Subject-specific Survival", "Subject-specific Cumulative Hazard", "Subject-specific log Cumulative Hazard"), survTimes = NULL, main = "", ask = prod(par("mfcol")) < length(which) && dev.interactive(), ..., ids = NULL, add.smooth = getOption("add.smooth"), add.qqline = TRUE, add.KM = FALSE, cex.caption = 1, return = FALSE)
## S3 method for class 'jointModel' plot(x, which = 1:4, caption = c("Residuals vs Fitted", "Normal Q-Q", "Marginal Survival", "Marginal Cumulative Hazard", "Marginal log Cumulative Hazard", "Baseline Hazard", "Cumulative Baseline Hazard", "Subject-specific Survival", "Subject-specific Cumulative Hazard", "Subject-specific log Cumulative Hazard"), survTimes = NULL, main = "", ask = prod(par("mfcol")) < length(which) && dev.interactive(), ..., ids = NULL, add.smooth = getOption("add.smooth"), add.qqline = TRUE, add.KM = FALSE, cex.caption = 1, return = FALSE)
x |
an object inheriting from class |
which |
which types of plots to produce, specify a subset of the numbers 1:10. |
caption |
captions to appear above the plots defined by argument |
survTimes |
a vector of survival times for which the survival, cumulative hazard or
log cumulative hazard will be computed. Default is |
main |
a character string specifying the title in the plot. |
ask |
logical; if |
... |
other parameters to be passed through to plotting functions. |
ids |
a numeric vector specifying which subjects, the subject-specific plots will include; default is all subjects. |
add.smooth |
logical; if |
add.qqline |
logical; if |
add.KM |
logical; if |
cex.caption |
magnification of captions. |
return |
logical; if |
The plots of the baseline hazard and the cumulative baseline hazard are only produced when the joint model has
been fitted using method = "Cox-PH-GH"
.
Dimitris Rizopoulos [email protected]
Rizopoulos, D. (2012) Joint Models for Longitudinal and Time-to-Event Data: with Applications in R. Boca Raton: Chapman and Hall/CRC.
Rizopoulos, D. (2010) JM: An R package for the joint modelling of longitudinal and time-to-event data. Journal of Statistical Software 35 (9), 1–33. doi:10.18637/jss.v035.i09
## Not run: # linear mixed model fit fitLME <- lme(log(serBilir) ~ drug * year, random = ~ 1 | id, data = pbc2) # survival regression fit fitSURV <- survreg(Surv(years, status2) ~ drug, data = pbc2.id, x = TRUE) # joint model fit, under the (default) Weibull model fitJOINT <- jointModel(fitLME, fitSURV, timeVar = "year") plot(fitJOINT, 3, add.KM = TRUE, col = "red", lwd = 2) par(mfrow = c(2, 2)) plot(fitJOINT) ## End(Not run)
## Not run: # linear mixed model fit fitLME <- lme(log(serBilir) ~ drug * year, random = ~ 1 | id, data = pbc2) # survival regression fit fitSURV <- survreg(Surv(years, status2) ~ drug, data = pbc2.id, x = TRUE) # joint model fit, under the (default) Weibull model fitJOINT <- jointModel(fitLME, fitSURV, timeVar = "year") plot(fitJOINT, 3, add.KM = TRUE, col = "red", lwd = 2) par(mfrow = c(2, 2)) plot(fitJOINT) ## End(Not run)
Produces plots of ROC curves and the corresponding areas under the curve.
## S3 method for class 'rocJM' plot(x, which = NULL, type = c("ROC", "AUC"), ndt = "all", main = NULL, caption = NULL, xlab = NULL, ylab = NULL, ask = NULL, legend = FALSE, lx = NULL, ly = NULL, lty = NULL, col = NULL, cex.caption = 0.8, cex.axis = NULL, cex.lab = NULL, cex.main = NULL, ...)
## S3 method for class 'rocJM' plot(x, which = NULL, type = c("ROC", "AUC"), ndt = "all", main = NULL, caption = NULL, xlab = NULL, ylab = NULL, ask = NULL, legend = FALSE, lx = NULL, ly = NULL, lty = NULL, col = NULL, cex.caption = 0.8, cex.axis = NULL, cex.lab = NULL, cex.main = NULL, ...)
x |
an object inheriting from class |
which |
a numeric vector specifying for which generic subjects to produce the plots.
This refers to the different cases identified by the |
type |
a character string specifying which plot to produce the ROC curves or the areas under the ROC curves. |
ndt |
the character string |
main |
a character string specifying the title in the plot. |
caption |
a character string specifying a caption in the plot. |
xlab |
a character string specifying the x-axis label in the plot. |
ylab |
a character string specifying the y-axis label in the plot. |
ask |
logical; if |
legend |
logical; if |
lx , ly
|
the |
lty |
what types of lines to use. |
col |
which colors to use. |
cex.caption |
font size for the caption. |
cex.axis , cex.lab , cex.main
|
graphical parameters; see |
... |
extra graphical parameters passed to |
Dimitris Rizopoulos [email protected]
Rizopoulos, D. (2012) Joint Models for Longitudinal and Time-to-Event Data: with Applications in R. Boca Raton: Chapman and Hall/CRC.
Rizopoulos, D. (2011). Dynamic predictions and prospective accuracy in joint models for longitudinal and time-to-event data. Biometrics 67, 819–829.
## Not run: fitLME <- lme(sqrt(CD4) ~ obstime + obstime:(drug + AZT + prevOI + gender), random = ~ obstime | patient, data = aids) fitSURV <- coxph(Surv(Time, death) ~ drug + AZT + prevOI + gender, data = aids.id, x = TRUE) fit.aids <- jointModel(fitLME, fitSURV, timeVar = "obstime", method = "piecewise-PH-aGH") ND <- aids[aids$patient == "7", ] roc <- rocJM(fit.aids, dt = c(2, 4, 8), ND, idVar = "patient") plot(roc, lwd = 2, legend = TRUE) plot(roc, type = "AUC") ## End(Not run)
## Not run: fitLME <- lme(sqrt(CD4) ~ obstime + obstime:(drug + AZT + prevOI + gender), random = ~ obstime | patient, data = aids) fitSURV <- coxph(Surv(Time, death) ~ drug + AZT + prevOI + gender, data = aids.id, x = TRUE) fit.aids <- jointModel(fitLME, fitSURV, timeVar = "obstime", method = "piecewise-PH-aGH") ND <- aids[aids$patient == "7", ] roc <- rocJM(fit.aids, dt = c(2, 4, 8), ND, idVar = "patient") plot(roc, lwd = 2, legend = TRUE) plot(roc, type = "AUC") ## End(Not run)
Produces plots of conditional probabilities of survival.
## S3 method for class 'survfitJM' plot(x, estimator = c("both", "mean", "median"), which = NULL, fun = NULL, conf.int = FALSE, fill.area = FALSE, col.area = "grey", col.abline = "black", col.points = "black", add.last.time.axis.tick = FALSE, include.y = FALSE, main = NULL, xlab = NULL, ylab = NULL, ylab2 = NULL, lty = NULL, col = NULL, lwd = NULL, pch = NULL, ask = NULL, legend = FALSE, ..., cex.axis.z = 1, cex.lab.z = 1)
## S3 method for class 'survfitJM' plot(x, estimator = c("both", "mean", "median"), which = NULL, fun = NULL, conf.int = FALSE, fill.area = FALSE, col.area = "grey", col.abline = "black", col.points = "black", add.last.time.axis.tick = FALSE, include.y = FALSE, main = NULL, xlab = NULL, ylab = NULL, ylab2 = NULL, lty = NULL, col = NULL, lwd = NULL, pch = NULL, ask = NULL, legend = FALSE, ..., cex.axis.z = 1, cex.lab.z = 1)
x |
an object inheriting from class |
estimator |
character string specifying, whether to include in the plot the mean of the conditional probabilities of survival,
the median or both. The mean and median are taken as estimates of these conditional probabilities over the M replications of the
Monte Carlo scheme described in |
which |
a numeric or character vector specifying for which subjects to produce the plot. If a character vector, then is
should contain a subset of the values of the |
fun |
a vectorized function defining a transformation of the survival curve. For example with |
conf.int |
logical; if |
fill.area |
logical; if |
col.area |
the color of the area defined by the confidence interval of the survival function. |
col.abline , col.points
|
the color for the vertical line and the points when |
add.last.time.axis.tick |
logical; if |
include.y |
logical; if |
main |
a character string specifying the title in the plot. |
xlab |
a character string specifying the x-axis label in the plot. |
ylab |
a character string specifying the y-axis label in the plot. |
ylab2 |
a character string specifying the y-axis label in the plotm when |
lty |
what types of lines to use. |
col |
which colors to use. |
lwd |
the thickness of the lines. |
pch |
the type of points to use. |
ask |
logical; if |
legend |
logical; if |
cex.axis.z , cex.lab.z
|
the par |
... |
extra graphical parameters passed to |
Dimitris Rizopoulos [email protected]
Rizopoulos, D. (2012) Joint Models for Longitudinal and Time-to-Event Data: with Applications in R. Boca Raton: Chapman and Hall/CRC.
Rizopoulos, D. (2011). Dynamic predictions and prospective accuracy in joint models for longitudinal and time-to-event data. Biometrics 67, 819–829.
Rizopoulos, D. (2010) JM: An R Package for the Joint Modelling of Longitudinal and Time-to-Event Data. Journal of Statistical Software 35 (9), 1–33. doi:10.18637/jss.v035.i09
# linear mixed model fit fitLME <- lme(sqrt(CD4) ~ obstime + obstime:drug, random = ~ 1 | patient, data = aids) # cox model fit fitCOX <- coxph(Surv(Time, death) ~ drug, data = aids.id, x = TRUE) # joint model fit fitJOINT <- jointModel(fitLME, fitCOX, timeVar = "obstime", method = "weibull-PH-aGH") # sample of the patients who are still alive ND <- aids[aids$patient == "141", ] ss <- survfitJM(fitJOINT, newdata = ND, idVar = "patient", M = 50) plot(ss) plot(ss, include.y = TRUE, add.last.time.axis.tick = TRUE, legend = TRUE)
# linear mixed model fit fitLME <- lme(sqrt(CD4) ~ obstime + obstime:drug, random = ~ 1 | patient, data = aids) # cox model fit fitCOX <- coxph(Surv(Time, death) ~ drug, data = aids.id, x = TRUE) # joint model fit fitJOINT <- jointModel(fitLME, fitCOX, timeVar = "obstime", method = "weibull-PH-aGH") # sample of the patients who are still alive ND <- aids[aids$patient == "141", ] ss <- survfitJM(fitJOINT, newdata = ND, idVar = "patient", M = 50) plot(ss) plot(ss, include.y = TRUE, add.last.time.axis.tick = TRUE, legend = TRUE)
Using the available longitudinal information up to a starting time point, this function computes an estimate of the prediction error of survival at a horizon time point based on joint models.
prederrJM(object, newdata, Tstart, Thoriz, ...) ## S3 method for class 'jointModel' prederrJM(object, newdata, Tstart, Thoriz, lossFun = c("absolute", "square"), interval = FALSE, idVar = "id", simulate = FALSE, M = 100, ...)
prederrJM(object, newdata, Tstart, Thoriz, ...) ## S3 method for class 'jointModel' prederrJM(object, newdata, Tstart, Thoriz, lossFun = c("absolute", "square"), interval = FALSE, idVar = "id", simulate = FALSE, M = 100, ...)
object |
an object inheriting from class |
newdata |
a data frame that contains the longitudinal and covariate information for the subjects for which prediction
of survival probabilities is required. The names of the variables in this data frame must be the same as in the data frames that
were used to fit the linear mixed effects model (using |
Tstart |
numeric scalar denoting the time point up to which longitudinal information is to be used to derive predictions. |
Thoriz |
numeric scalar denoting the time point for which a prediction of the survival status is of interest; |
lossFun |
either the options |
interval |
logical; if |
idVar |
the name of the variable in |
simulate |
logical; if |
M |
a numeric scalar denoting the number of Monte Carlo samples; see |
... |
additional arguments; currently none is used. |
Based on a fitted joint model (represented by object
) and using the data supplied in argument newdata
, this function
computes the following estimate of the prediction:
where denotes the number of subjects at risk at time
Tstart
, denotes the available
longitudinal measurements up to time
,
denotes the observed event time for subject
,
is the event indicator,
is the starting time point
Tstart
up to which the longitudinal information is used, and is the horizon time point
Thoriz
.
Function is the loss function that can be the absolute value (i.e.,
), the squared value (i.e.,
),
or a user-specified function. The probabilities
are calculated by
survfitJM
.
When interval
is set to TRUE
, then function prederrJM
computes the integrated prediction error in the interval
(Tstart, Thoriz)
defined as
where
with denoting
the Kaplan-Meier estimator of the censoring time distribution.
A list of class prederrJM
with components:
prederr |
a numeric scalar denoting the estimated prediction error. |
nr |
a numeric scalar denoting the number of subjects at risk at time |
Tstart |
a copy of the |
Thoriz |
a copy of the |
interval |
a copy of the |
classObject |
the class of |
nameObject |
the name of |
lossFun |
a copy of the |
Dimitris Rizopoulos [email protected]
Henderson, R., Diggle, P. and Dobson, A. (2002). Identification and efficacy of longitudinal markers for survival. Biostatistics 3, 33–50.
Rizopoulos, D. (2012) Joint Models for Longitudinal and Time-to-Event Data: with Applications in R. Boca Raton: Chapman and Hall/CRC.
Rizopoulos, D. (2011). Dynamic predictions and prospective accuracy in joint models for longitudinal and time-to-event data. Biometrics 67, 819–829.
Rizopoulos, D., Murawska, M., Andrinopoulou, E.-R., Lesaffre, E. and Takkenberg, J. (2013). Dynamic predictions with time-dependent covariates in survival analysis: A comparison between joint modeling and landmarking. under preparation.
survfitJM
, aucJM
, dynCJM
, jointModel
## Not run: # we construct the composite event indicator (transplantation or death) pbc2$status2 <- as.numeric(pbc2$status != "alive") pbc2.id$status2 <- as.numeric(pbc2.id$status != "alive") # we fit the joint model using splines for the subject-specific # longitudinal trajectories and a spline-approximated baseline # risk function lmeFit <- lme(log(serBilir) ~ ns(year, 3), random = list(id = pdDiag(form = ~ ns(year, 3))), data = pbc2) survFit <- coxph(Surv(years, status2) ~ drug, data = pbc2.id, x = TRUE) jointFit <- jointModel(lmeFit, survFit, timeVar = "year", method = "piecewise-PH-aGH") # prediction error at year 10 using longitudinal data up to year 5 prederrJM(jointFit, pbc2, Tstart = 5, Thoriz = 10) prederrJM(jointFit, pbc2, Tstart = 5, Thoriz = 6.5, interval = TRUE) ## End(Not run)
## Not run: # we construct the composite event indicator (transplantation or death) pbc2$status2 <- as.numeric(pbc2$status != "alive") pbc2.id$status2 <- as.numeric(pbc2.id$status != "alive") # we fit the joint model using splines for the subject-specific # longitudinal trajectories and a spline-approximated baseline # risk function lmeFit <- lme(log(serBilir) ~ ns(year, 3), random = list(id = pdDiag(form = ~ ns(year, 3))), data = pbc2) survFit <- coxph(Surv(years, status2) ~ drug, data = pbc2.id, x = TRUE) jointFit <- jointModel(lmeFit, survFit, timeVar = "year", method = "piecewise-PH-aGH") # prediction error at year 10 using longitudinal data up to year 5 prederrJM(jointFit, pbc2, Tstart = 5, Thoriz = 10) prederrJM(jointFit, pbc2, Tstart = 5, Thoriz = 6.5, interval = TRUE) ## End(Not run)
Calculates predicted values for the longitudinal part of a joint model.
## S3 method for class 'jointModel' predict(object, newdata, type = c("Marginal", "Subject"), interval = c("none", "confidence", "prediction"), level = 0.95, idVar = "id", FtTimes = NULL, M = 300, returnData = FALSE, scale = 1.6, ...)
## S3 method for class 'jointModel' predict(object, newdata, type = c("Marginal", "Subject"), interval = c("none", "confidence", "prediction"), level = 0.95, idVar = "id", FtTimes = NULL, M = 300, returnData = FALSE, scale = 1.6, ...)
object |
an object inheriting from class |
newdata |
a data frame in which to look for variables with which to predict. |
type |
a character string indicating the type of predictions to compute, marginal or subject-specific. See Details. |
interval |
a character string indicating what type of intervals should be computed. |
level |
a numeric scalar denoting the tolerance/confidence level. |
idVar |
a character string indicating the name of the variable in
|
FtTimes |
a list with components numeric vectors denoting the time points
for which we wish to compute subject-specific predictions after the last
available measurement provided in |
M |
numeric scalar denoting the number of Monte Carlo samples. See Details. |
returnData |
logical; if |
scale |
a numeric value setting the scaling of the covariance matrix of the empirical Bayes estimates in the Metropolis step during the Monte Carlo sampling. |
... |
additional arguments; currently none is used. |
When type = "Marginal"
, this function computes predicted values for the
fixed-effects part of the longitudinal submodel. In particular,
let denote the fixed-effects design matrix calculated using
newdata
. The predict()
calculates ,
and if
interval = "confidence"
, , with
denoting the covariance matrix of
. Confidence intervals are constructed under
the normal approximation.
When type = "Subject"
, this functions computes subject-specific
predictions for the longitudinal outcome based on the joint model.
This accomplished with a Monte Carlo simulation scheme, similar to the one
described in survfitJM
. The only difference is in Step 3, where
for interval = "confidence"
, whereas
for
interval = "prediction"
is a random vector from a normal
distribution with mean
and standard deviation
. Based on this Monte Carlo simulation scheme we take as
estimate of
the average of the
M
estimates
from each Monte Carlo sample. Confidence intervals are constructed using the
percentiles of
from the Monte Carlo samples.
If se.fit = FALSE
a numeric vector of predicted values, otherwise a
list with components pred
the predicted values, se.fit
the
standard error for the fitted values, and low
and upp
the lower
and upper limits of the confidence interval. If returnData = TRUE
, it
returns the data frame newdata
with the previously mentioned components
added.
Dimitris Rizopoulos [email protected]
Rizopoulos, D. (2012) Joint Models for Longitudinal and Time-to-Event Data: with Applications in R. Boca Raton: Chapman and Hall/CRC.
## Not run: # linear mixed model fit fitLME <- lme(log(serBilir) ~ drug * year, random = ~ year | id, data = pbc2) # survival regression fit fitSURV <- survreg(Surv(years, status2) ~ drug, data = pbc2.id, x = TRUE) # joint model fit, under the (default) Weibull model fitJOINT <- jointModel(fitLME, fitSURV, timeVar = "year") DF <- with(pbc2, expand.grid(drug = levels(drug), year = seq(min(year), max(year), len = 100))) Ps <- predict(fitJOINT, DF, interval = "confidence", return = TRUE) require(lattice) xyplot(pred + low + upp ~ year | drug, data = Ps, type = "l", col = c(2,1,1), lty = c(1,2,2), lwd = 2, ylab = "Average log serum Bilirubin") # Subject-specific predictions ND <- pbc2[pbc2$id == 2, ] Ps.ss <- predict(fitJOINT, ND, type = "Subject", interval = "confidence", return = TRUE) require(lattice) xyplot(pred + low + upp ~ year | id, data = Ps.ss, type = "l", col = c(2,1,1), lty = c(1,2,2), lwd = 2, ylab = "Average log serum Bilirubin") ## End(Not run)
## Not run: # linear mixed model fit fitLME <- lme(log(serBilir) ~ drug * year, random = ~ year | id, data = pbc2) # survival regression fit fitSURV <- survreg(Surv(years, status2) ~ drug, data = pbc2.id, x = TRUE) # joint model fit, under the (default) Weibull model fitJOINT <- jointModel(fitLME, fitSURV, timeVar = "year") DF <- with(pbc2, expand.grid(drug = levels(drug), year = seq(min(year), max(year), len = 100))) Ps <- predict(fitJOINT, DF, interval = "confidence", return = TRUE) require(lattice) xyplot(pred + low + upp ~ year | drug, data = Ps, type = "l", col = c(2,1,1), lty = c(1,2,2), lwd = 2, ylab = "Average log serum Bilirubin") # Subject-specific predictions ND <- pbc2[pbc2$id == 2, ] Ps.ss <- predict(fitJOINT, ND, type = "Subject", interval = "confidence", return = TRUE) require(lattice) xyplot(pred + low + upp ~ year | id, data = Ps.ss, type = "l", col = c(2,1,1), lty = c(1,2,2), lwd = 2, ylab = "Average log serum Bilirubin") ## End(Not run)
A randomized trial on 488 liver cirrhosis patients
Two data frames with the following variable.
id
patients identifier; in total there are 467 patients.
pro
prothrobin measurements.
time
for data frame prothro
the time points at which the prothrobin measurements were taken;
for data frame prothros
the time to death or censoring.
death
a numeric vector with 0 denoting censoring and 1 death.
treat
randomized treatment; a factor with levels "placebo" and "prednisone".
http://www.gllamm.org/books/readme.html#14.6,
Andersen, P. K., Borgan, O., Gill, R. D. and Keiding, N. (1993). Statistical Models Based on Counting Processes. New York: Springer.
summary(prothros)
summary(prothros)
Extracts the random effects estimates from a fitted joint model.
## S3 method for class 'jointModel' ranef(object, type = c("mean", "mode"), postVar = FALSE, ...)
## S3 method for class 'jointModel' ranef(object, type = c("mean", "mode"), postVar = FALSE, ...)
object |
an object inheriting from class |
type |
what type of empirical Bayes estimates to compute, the mean of the posterior distribution or the mode of the posterior distribution. |
postVar |
logical; if |
... |
additional arguments; currently none is used. |
a numeric matrix with rows denoting the individuals and columns the random effects (e.g., intercepts, slopes, etc.).
If postVar = TRUE
, the numeric matrix has an extra attribute “postVar".
Dimitris Rizopoulos [email protected]
Rizopoulos, D. (2012) Joint Models for Longitudinal and Time-to-Event Data: with Applications in R. Boca Raton: Chapman and Hall/CRC.
coef.jointModel
, fixef.jointModel
## Not run: # linear mixed model fit fitLME <- lme(log(serBilir) ~ drug * year, random = ~ 1 | id, data = pbc2) # survival regression fit fitSURV <- survreg(Surv(years, status2) ~ drug, data = pbc2.id, x = TRUE) # joint model fit, under the (default) Weibull model fitJOINT <- jointModel(fitLME, fitSURV, timeVar = "year") ranef(fitJOINT) ## End(Not run)
## Not run: # linear mixed model fit fitLME <- lme(log(serBilir) ~ drug * year, random = ~ 1 | id, data = pbc2) # survival regression fit fitSURV <- survreg(Surv(years, status2) ~ drug, data = pbc2.id, x = TRUE) # joint model fit, under the (default) Weibull model fitJOINT <- jointModel(fitLME, fitSURV, timeVar = "year") ranef(fitJOINT) ## End(Not run)
Calculates residuals for joint models.
## S3 method for class 'jointModel' residuals(object, process = c("Longitudinal", "Event"), type = c("Marginal", "Subject", "stand-Marginal", "stand-Subject", "Martingale", "nullMartingale", "CoxSnell", "AFT"), MI = FALSE, M = 50, time.points = NULL, return.data = FALSE, ...)
## S3 method for class 'jointModel' residuals(object, process = c("Longitudinal", "Event"), type = c("Marginal", "Subject", "stand-Marginal", "stand-Subject", "Martingale", "nullMartingale", "CoxSnell", "AFT"), MI = FALSE, M = 50, time.points = NULL, return.data = FALSE, ...)
object |
an object inheriting from class |
process |
for which model (i.e., linear mixed model or survival model) to calculate residuals. |
type |
what type of residuals to calculate. See Details. |
MI |
logical; if |
M |
integer denoting how many imputations to use for the MI residuals. |
time.points |
for fixed visit times, this should be a numeric vector with the unique times points at which
longitudinal measurements are supposed to be taken; if |
return.data |
logical; if |
... |
additional arguments; currently none is used. |
When process = "Longitudinal"
, residuals are calculated for the longitudinal outcomes. In particular, if
type = "Marginal"
these are , whereas for
type = "Subject"
,
, where
denotes the subject and
the
measurement,
the longitudinal responses,
and
the corresponding rows of the
fixed and random effects design matrices, respectively, and
and
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 corresponding error term. If MI = TRUE
, multiple-imputation-based
residuals are calculated for the longitudinal process; for more information regarding these residuals, check Rizopoulos et al. (2009).
When process = "Event"
, residuals are calculated for the survival outcome. Martingale residuals are available
for all options for the survival submodel (for the different options of survival submodel, check the method
argument of jointModel
). when option type = "nullMartingale"
is invoked, the martingale residuals
are calculated with the coefficient(s) that correspond to the marker set to zero. Cox-Snell residuals (Cox and Snell,
1968) are available for the Weibull model and the additive log cumulative hazard model. AFT residuals are only
available for the Weibull model.
If MI = FALSE
, a numeric vector of residual values. Otherwise a list with components:
fitted.values |
the fitted values for the observed data. |
residuals |
the residuals for the observed data. |
fitted.valsM |
the fitted values for the missing data. |
resid.valsM |
the multiply imputed residuals for the missing longitudinal responses. |
mean.resid.valsM |
the average of the multiply imputed residuals for the missing longitudinal responses; returned only if fixed visit times are considered. |
dataM |
if |
The multiple-imputation-based residuals are not available for joint models with method = "Cox-PH-GH"
.
Dimitris Rizopoulos [email protected]
Cox, D. and Snell, E. (1968) A general definition of residuals. Journal of the Royal Statistical Society, Series B 30, 248–275.
Rizopoulos, D. (2012) Joint Models for Longitudinal and Time-to-Event Data: with Applications in R. Boca Raton: Chapman and Hall/CRC.
Rizopoulos, D., Verbeke, G. and Molenberghs, G. (2010) Multiple-imputation-based residuals and diagnostic plots for joint models of longitudinal and survival outcomes. Biometrics 66, 20–29.
Rizopoulos, D. (2010) JM: An R Package for the Joint Modelling of Longitudinal and Time-to-Event Data. Journal of Statistical Software 35 (9), 1–33. doi:10.18637/jss.v035.i09
## Not run: # 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") # residuals for the longitudinal outcome head(cbind( "Marginal" = residuals(fitJOINT), "std-Marginal" = residuals(fitJOINT, type = "stand-Marginal"), "Subject" = residuals(fitJOINT, type = "Subject"), "std-Subject" = residuals(fitJOINT, type = "stand-Subject") )) # residuals for the survival outcome head(cbind( "Martingale" = residuals(fitJOINT, process = "Event", type = "Martingale"), "CoxSnell" = residuals(fitJOINT, process = "Event", type = "CoxSnell") )) ## End(Not run)
## Not run: # 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") # residuals for the longitudinal outcome head(cbind( "Marginal" = residuals(fitJOINT), "std-Marginal" = residuals(fitJOINT, type = "stand-Marginal"), "Subject" = residuals(fitJOINT, type = "Subject"), "std-Subject" = residuals(fitJOINT, type = "stand-Subject") )) # residuals for the survival outcome head(cbind( "Martingale" = residuals(fitJOINT, process = "Event", type = "Martingale"), "CoxSnell" = residuals(fitJOINT, process = "Event", type = "CoxSnell") )) ## End(Not run)
It computes sensitivity, specificity, ROC and AUC measures for joint models.
rocJM(object, dt, data, idVar = "id", directionSmaller = NULL, cc = NULL, min.cc = NULL, max.cc = NULL, optThr = c("sens*spec", "youden"), diffType = c("absolute", "relative"), abs.diff = 0, rel.diff = 1, M = 300, burn.in = 100, scale = 1.6)
rocJM(object, dt, data, idVar = "id", directionSmaller = NULL, cc = NULL, min.cc = NULL, max.cc = NULL, optThr = c("sens*spec", "youden"), diffType = c("absolute", "relative"), abs.diff = 0, rel.diff = 1, M = 300, burn.in = 100, scale = 1.6)
object |
an object inheriting from class |
dt |
a numeric vector indicating the lengths of the time intervals of primary interest within which we want to distinguish between subjects who died within the intervals from subjects who survived longer than that. |
data |
a data frame that contains the baseline covariates for the longitudinal and survival submodels,
including a case identifier (i.e., the variable denoted by the argument |
idVar |
the name of the variable in |
directionSmaller |
logical; if |
cc |
a numeric vector of threshold values for the longitudinal marker; if |
min.cc |
the start of the regular sequence for the threshold values for the longitudinal marker;
see argument |
max.cc |
the end of the regular sequence for the threshold values for the longitudinal marker;
see argument |
optThr |
character string defining how the optimal threshold is to be computed. The default chooses the
cut-point for the marker that maximizes the product of sensitivity and specificity. Option |
diffType |
character string defining the type of prediction rule. See Details. |
abs.diff |
a numeric vector of absolute differences in the definition of composite prediction rules. |
rel.diff |
a numeric vector of relative differences in the definition of composite prediction rules. |
M |
a numeric scalar denoting the number of Monte Carlo samples. |
burn.in |
a numeric scalar denoting the iterations to discard. |
scale |
a numeric scalar that controls the acceptance rate of the Metropolis-Hastings algorithm. See Details. |
(Note: the following contain some math formulas, which are better viewed in the pdf version of the manual accessible at https://cran.r-project.org/package=JM.)
Assume that we have collected longitudinal measurements up to time point
for
subject
. We are interested in events occurring in the medically relevant time frame
within which the
physician can take an action to improve the survival chance of the patient. Using an appropriate function of the marker history
, we can define a prediction rule to discriminate between patients of high and low risk for an event. For instance,
for in HIV infected patients, we could consider values of CD4 cell count smaller than a specific threshold as predictive for death.
Since we are in a longitudinal context, we have the flexibility of determining which values of the longitudinal history of the
patient will contribute to the specification of the prediction rule. That is, we could define a composite prediction rule that is not
based only on the last available measurement but rather on the last two or last three measurements of a patient. Furthermore, it
could be of relevance to consider different threshold values for each of these measurements, for instance, we could define as success
the event that the pre-last CD4 cell count is
and the last one
, indicating that a 50% decrease is strongly
indicative for death. Under this setting we define sensitivity and specificity as,
and
respectively, where we term as success
(i.e., occurrence of the event of interest), and
as a failure,
denotes the time-to-event, and
the length of the medically relevant time window (specified by argument
dt
). The cut values for the marker are specified by the
cc
, min.cc
and max.cc
arguments. Two types of
composite prediction rules can be defined depending on the value of the diffType
argument. Absolute prediction rules in which, between
successive measurements there is an absolute difference of between the cut values, and relative prediction rules in which there is a
relative difference between successive measurements of the marker. The lag values for these differences are defined by the abs.diff
and rel.diff
arguments. Some illustrative examples:
keeping the defaults we define a simple rule that is only based on the last available marker measurement.
to define a prediction rule that is based on the last two available measurements using the same cut values (e.g.,
if a patient had two successive measurements below a medically relevant threshold), we need to set abs.diff = c(0, 0)
.
to define a prediction rule that is based on the last two available measurements using a drop of 5 units between the cut
values (e.g., the pre-last measurement is and the last
), we need to set
abs.diff = c(0, -5)
.
to define a prediction rule that is based on the last two available measurements using a drop of 20% units between the cut
values (e.g., the pre-last measurement is and the last
), we need to set
diffType = "relative"
and
rel.diff = c(0, 0.8)
.
The estimation of the above defined probabilities is achieved with a Monte Carlo scheme similar to the one described in
survfitJM
. The number of Monte Carlo samples is defined by the M
argument, and the burn-in iterations for
the Metropolis-Hastings algorithm using the burn.in
argument.
More details can be found in Rizopoulos (2011).
An object of class rocJM
is a list with components,
MCresults |
a list of length the number of distinct cases in |
AUCs |
a numeric vector of estimated areas under the ROC curves for the different values of |
optThr |
a numeric vector with the optimal threshold values for the markers for the different
|
times |
a list of length the number of distinct cases in |
dt |
a copy of the |
M |
a copy of the |
diffType |
a copy of the |
abs.diff |
a copy of the |
rel.diff |
a copy of the |
cc |
a copy of the |
min.cc |
a copy of the |
max.cc |
a copy of the |
success.rate |
a numeric matrix with the success rates of the Metropolis-Hastings algorithm described above. |
Dimitris Rizopoulos [email protected]
Heagerty, P. and Zheng, Y. (2005). Survival model predictive accuracy and ROC curves. Biometrics 61, 92–105.
Rizopoulos, D. (2012) Joint Models for Longitudinal and Time-to-Event Data: with Applications in R. Boca Raton: Chapman and Hall/CRC.
Rizopoulos, D. (2011). Dynamic predictions and prospective accuracy in joint models for longitudinal and time-to-event data. Biometrics 67, 819–829.
Rizopoulos, D. (2010) JM: An R package for the joint modelling of longitudinal and time-to-event data. Journal of Statistical Software 35 (9), 1–33. doi:10.18637/jss.v035.i09
Zheng, Y. and Heagerty, P. (2007). Prospective accuracy for longitudinal markers. Biometrics 63, 332–341.
plot.rocJM
,
survfitJM
,
dynCJM
,
aucJM
,
prederrJM
,
jointModel
## Not run: fitLME <- lme(sqrt(CD4) ~ obstime * (drug + AZT + prevOI + gender), random = ~ obstime | patient, data = aids) fitSURV <- coxph(Surv(Time, death) ~ drug + AZT + prevOI + gender, data = aids.id, x = TRUE) fit.aids <- jointModel(fitLME, fitSURV, timeVar = "obstime", method = "piecewise-PH-aGH") # the following will take some time to execute... ND <- aids[aids$patient == "7", ] roc <- rocJM(fit.aids, dt = c(2, 4, 8), ND, idVar = "patient") roc ## End(Not run)
## Not run: fitLME <- lme(sqrt(CD4) ~ obstime * (drug + AZT + prevOI + gender), random = ~ obstime | patient, data = aids) fitSURV <- coxph(Surv(Time, death) ~ drug + AZT + prevOI + gender, data = aids.id, x = TRUE) fit.aids <- jointModel(fitLME, fitSURV, timeVar = "obstime", method = "piecewise-PH-aGH") # the following will take some time to execute... ND <- aids[aids$patient == "7", ] roc <- rocJM(fit.aids, dt = c(2, 4, 8), ND, idVar = "patient") roc ## End(Not run)
simulate longitudinal responses and event times from joint models
simulateJM(nsim, nsub, thetas, times, formulas, Data = NULL, method = c("weibull-PH", "weibull-AFT", "piecewise-PH", "spline-PH"), lag = 0, censoring = "uniform", max.FUtime = NULL, seed = NULL, return.ranef = FALSE) ## S3 method for class 'jointModel' simulate(object, nsim, seed = NULL, times = NULL, Data = NULL, ...)
simulateJM(nsim, nsub, thetas, times, formulas, Data = NULL, method = c("weibull-PH", "weibull-AFT", "piecewise-PH", "spline-PH"), lag = 0, censoring = "uniform", max.FUtime = NULL, seed = NULL, return.ranef = FALSE) ## S3 method for class 'jointModel' simulate(object, nsim, seed = NULL, times = NULL, Data = NULL, ...)
nsim |
number of data sets to be simulated. |
nsub |
the number of subjects in each data set. |
thetas |
a list with the parameter values. This should be of the same structure as
the |
times |
a numeric vector denoting the time points at which longitudinal measurements are planned to be taken. |
formulas |
a list with components: |
Data |
a data frame containing any covariates used in the formulas defined in the
|
method |
a character string indicating from what type of survival submodel to simulate.
There are the same options as the ones provided by |
lag |
a numeric value denoting a lagged effect; the same as the |
censoring |
a character string or a numeric vector. |
max.FUtime |
a numeric value denoting the maximum follow-up time for the study. The default
is |
seed |
an object specifying if and how the random number generator should
be initialized ('seeded'). It could be either |
return.ranef |
logical; if |
object |
an object inheriting from class |
... |
additional arguments; currently none is used. |
A list of length nsim
of data frames that contains the simulated responses
for the longitudinal process "y", the simulated event times "Time", the event indicator
"Event", and the subject identification number "id". If extra covariates were assumed,
these are also included.
Dimitris Rizopoulos [email protected]
## Not run: prothro$t0 <- as.numeric(prothro$time == 0) lmeFit <- lme(pro ~ treat * (time + t0), random = ~ time | id, data = prothro) survFit <- coxph(Surv(Time, death) ~ treat, data = prothros, x = TRUE) jointFit <- jointModel(lmeFit, survFit, timeVar = "time", method = "weibull-PH-aGH") newData <- simulate(jointFit, nsim = 1, times = seq(0, 11, len = 15)) newData ## End(Not run)
## Not run: prothro$t0 <- as.numeric(prothro$time == 0) lmeFit <- lme(pro ~ treat * (time + t0), random = ~ time | id, data = prothro) survFit <- coxph(Surv(Time, death) ~ treat, data = prothros, x = TRUE) jointFit <- jointModel(lmeFit, survFit, timeVar = "time", method = "weibull-PH-aGH") newData <- simulate(jointFit, nsim = 1, times = seq(0, 11, len = 15)) newData ## End(Not run)
Summarizes the fit of a Weibull model with Gamma frailties
## S3 method for class 'weibull.frailty' summary(object, sand.se = FALSE, ...)
## S3 method for class 'weibull.frailty' summary(object, sand.se = FALSE, ...)
object |
an object inheriting from class |
sand.se |
logical; if |
... |
additional arguments; currently none is used. |
Dimitris Rizopoulos [email protected]
fit <- weibull.frailty(Surv(time, status) ~ age + sex, kidney) summary(fit) summary(fit, TRUE)
fit <- weibull.frailty(Surv(time, status) ~ age + sex, kidney) summary(fit) summary(fit, TRUE)
This function computes the conditional probability of surviving later times than the last observed time for which a longitudinal measurement was available.
survfitJM(object, newdata, ...) ## S3 method for class 'jointModel' survfitJM(object, newdata, idVar = "id", simulate = TRUE, survTimes = NULL, last.time = NULL, M = 200, CI.levels = c(0.025, 0.975), scale = 1.6, ...)
survfitJM(object, newdata, ...) ## S3 method for class 'jointModel' survfitJM(object, newdata, idVar = "id", simulate = TRUE, survTimes = NULL, last.time = NULL, M = 200, CI.levels = c(0.025, 0.975), scale = 1.6, ...)
object |
an object inheriting from class |
newdata |
a data frame that contains the longitudinal and covariate information for the subjects for which prediction
of survival probabilities is required. The names of the variables in this data frame must be the same as in the data frames that
were used to fit the linear mixed effects model (using |
idVar |
the name of the variable in |
simulate |
logical; if |
survTimes |
a numeric vector of times for which prediction survival probabilities are to be computed. |
last.time |
a numeric vector or character string. This specifies the known time at which each of the subjects in |
M |
integer denoting how many Monte Carlo samples to use – see Details. |
CI.levels |
a numeric vector of length two that specifies which quantiles to use for the calculation of confidence interval for the predicted probabilities – see Details. |
scale |
a numeric scalar that controls the acceptance rate of the Metropolis-Hastings algorithm – see Details. |
... |
additional arguments; currently none is used. |
Based on a fitted joint model (represented by object
), and a history of longitudinal responses
and a covariates vector
(stored in
newdata
), this function provides estimates of , i.e., the conditional probability of surviving time
given that subject
, with covariate information
, has survived up to time
and has provided longitudinal the measurements
.
To estimate and if
simulate = TRUE
, a
Monte Carlo procedure is followed with the following steps:
Simulate new parameter values, say , from
,
where
are the MLEs and
their large sample covariance matrix, which are extracted from
object
.
Simulate random effects values, say , from their posterior distribution given survival up to time
,
the vector of longitudinal responses
and
. This is achieved using a Metropolis-Hastings algorithm with
independent proposals from a properly centered and scaled multivariate
distribution. The
scale
argument controls the
acceptance rate for this algorithm.
Using and
, compute
.
Repeat Steps 1-3 M
times.
Based on the M
estimates of the conditional probabilities, we compute useful summary statistics, such as their mean, median, and
quantiles (to produce a confidence interval).
If simulate = FALSE
, then survival probabilities are estimated using the formula
where denotes the MLEs as above, and
denotes the empirical Bayes estimates.
A list of class survfitJM
with components:
summaries |
a list with elements numeric matrices with numeric summaries of the predicted probabilities for each subject. |
survTimes |
a copy of the |
last.time |
a numeric vector with the time of the last available longitudinal measurement of each subject. |
obs.times |
a list with elements numeric vectors denoting the timings of the longitudinal measurements for each subject. |
y |
a list with elements numeric vectors denoting the longitudinal responses for each subject. |
full.results |
a list with elements numeric matrices with predicted probabilities for each subject in each replication of the Monte Carlo scheme described above. |
success.rate |
a numeric vector with the success rates of the Metropolis-Hastings algorithm described above for each subject. |
scale |
a copy of the |
Predicted probabilities are not computed for joint models with method = "ch-Laplace"
and method = "Cox-PH-GH"
.
Dimitris Rizopoulos [email protected]
Rizopoulos, D. (2012) Joint Models for Longitudinal and Time-to-Event Data: with Applications in R. Boca Raton: Chapman and Hall/CRC.
Rizopoulos, D. (2011). Dynamic predictions and prospective accuracy in joint models for longitudinal and time-to-event data. Biometrics 67, 819–829.
Rizopoulos, D. (2010) JM: An R Package for the Joint Modelling of Longitudinal and Time-to-Event Data. Journal of Statistical Software 35 (9), 1–33. doi:10.18637/jss.v035.i09
# linear mixed model fit fitLME <- lme(sqrt(CD4) ~ obstime + obstime:drug, random = ~ 1 | patient, data = aids) # cox model fit fitCOX <- coxph(Surv(Time, death) ~ drug, data = aids.id, x = TRUE) # joint model fit fitJOINT <- jointModel(fitLME, fitCOX, timeVar = "obstime", method = "weibull-PH-aGH") # sample of the patients who are still alive ND <- aids[aids$patient == "141", ] ss <- survfitJM(fitJOINT, newdata = ND, idVar = "patient", M = 50) ss
# linear mixed model fit fitLME <- lme(sqrt(CD4) ~ obstime + obstime:drug, random = ~ 1 | patient, data = aids) # cox model fit fitCOX <- coxph(Surv(Time, death) ~ drug, data = aids.id, x = TRUE) # joint model fit fitJOINT <- jointModel(fitLME, fitCOX, timeVar = "obstime", method = "weibull-PH-aGH") # sample of the patients who are still alive ND <- aids[aids$patient == "141", ] ss <- survfitJM(fitJOINT, newdata = ND, idVar = "patient", M = 50) ss
It performs a Wald test to test the hypothesis of equal spline coefficients among strata in the approximation of baseline risk function.
wald.strata(fit)
wald.strata(fit)
fit |
an object of class |
an object of class wald.strata
with components:
alternative |
a character string naming the alternative. |
Result |
a numeric matrix with the results of the Wald test. |
This test is valid when the same knots have been used across strata.
Dimitris Rizopoulos [email protected]
Rizopoulos, D. (2012) Joint Models for Longitudinal and Time-to-Event Data: with Applications in R. Boca Raton: Chapman and Hall/CRC.
## Not run: fitLME <- lme(log(serBilir) ~ drug * year - drug, random = ~ year | id, data = pbc2) fitSURV <- coxph(Surv(years, status2) ~ drug + strata(hepatomegaly), data = pbc2.id, x = TRUE) fit.pbc <- jointModel(fitLME, fitSURV, timeVar = "year", method = "spline-PH-aGH") wald.strata(fit.pbc) ## End(Not run)
## Not run: fitLME <- lme(log(serBilir) ~ drug * year - drug, random = ~ year | id, data = pbc2) fitSURV <- coxph(Surv(years, status2) ~ drug + strata(hepatomegaly), data = pbc2.id, x = TRUE) fit.pbc <- jointModel(fitLME, fitSURV, timeVar = "year", method = "spline-PH-aGH") wald.strata(fit.pbc) ## End(Not run)
Fits a Weibull model with Gamma frailties for multivariate survival data under maximum likelihood
weibull.frailty(formula = formula(data), data = parent.frame(), id = "id", subset, na.action, init, control = list())
weibull.frailty(formula = formula(data), data = parent.frame(), id = "id", subset, na.action, init, control = list())
formula |
an object of class |
data |
an optional data frame containing the variables specified in the model. |
id |
either a character string denoting a variable name in |
subset |
an optional vector specifying a subset of observations to be used in the fitting process. |
na.action |
what to do with missing values. |
init |
a numeric vector of length |
control |
a list of control values with components:
|
The fitted model is defined as follows:
where denotes the subject,
denotes the hazard function, conditionally on the frailty
,
is a vector of covariates with corresponding regression
coefficients
, and
is the Weibull baseline hazard defined as
. Finally, for the frailties we assume
, with
denoting the unknown variance of
's.
an object of class weibull.frailty
with components:
coefficients |
a list with the estimated coefficients values. The components of this list are: |
hessian |
the hessian matrix at convergence. For the shape, scale, and var-frailty parameters the Hessian is computed on the log scale. |
logLik |
the log-likelihood value. |
control |
a copy of the |
y |
an object of class |
x |
the design matrix of the model. |
id |
a numeric vector specifying which event times belong to the same cluster. |
nam.id |
the value of argument |
terms |
the term component of the fitted model. |
data |
a copy of |
call |
the matched call. |
weibull.frailty()
currently supports only right-censored data.
Dimitris Rizopoulos [email protected]
weibull.frailty(Surv(time, status) ~ age + sex, kidney)
weibull.frailty(Surv(time, status) ~ age + sex, kidney)
produces a LaTeX table with the results of a joint model using package xtable.
## S3 method for class 'jointModel' xtable(x, caption = NULL, label = NULL, align = NULL, digits = NULL, display = NULL, which = c("all", "Longitudinal", "Event"), varNames.Long = NULL, varNames.Event = NULL, p.values = TRUE, digits.pval = 4, ...)
## S3 method for class 'jointModel' xtable(x, caption = NULL, label = NULL, align = NULL, digits = NULL, display = NULL, which = c("all", "Longitudinal", "Event"), varNames.Long = NULL, varNames.Event = NULL, p.values = TRUE, digits.pval = 4, ...)
x |
an object inheriting from class |
caption |
the |
label |
the |
align |
the |
digits |
the |
display |
the |
which |
a character string indicating which results to include in the LaTeX table. Options are all results, the results of longitudinal submodel or the results of the survival submodel. |
varNames.Long |
a character vector of the variable names for the longitudinal submodel. |
varNames.Event |
a character vector of the variable names for the survival submodel. |
p.values |
logical; should p-values be included in the table. |
digits.pval |
a numeric scalare denoting the number of significance
digits in the |
... |
additional arguments; currently none is used. |
A LaTeX code chunk with the results of the joint modeling analysis.
Dimitris Rizopoulos [email protected]
## Not run: require(xtable) prothro$t0 <- as.numeric(prothro$time == 0) lmeFit <- lme(pro ~ treat * (time + t0), random = ~ time | id, data = prothro) survFit <- coxph(Surv(Time, death) ~ treat, data = prothros, x = TRUE) jointFit <- jointModel(lmeFit, survFit, timeVar = "time", method = "weibull-PH-aGH") xtable(jointFit, math.style.negative = TRUE) ## End(Not run)
## Not run: require(xtable) prothro$t0 <- as.numeric(prothro$time == 0) lmeFit <- lme(pro ~ treat * (time + t0), random = ~ time | id, data = prothro) survFit <- coxph(Surv(Time, death) ~ treat, data = prothros, x = TRUE) jointFit <- jointModel(lmeFit, survFit, timeVar = "time", method = "weibull-PH-aGH") xtable(jointFit, math.style.negative = TRUE) ## End(Not run)