| Title: | Semi-Parametric Joint Modeling of Longitudinal and Survival Data |
|---|---|
| Description: | Implements scalable joint models for large-scale competing risks time-to-event data with one or multiple longitudinal biomarkers using the efficient algorithms developed by Li et al. (2022) <doi:10.1155/2022/1362913> and <doi:10.48550/arXiv.2506.12741>. The time-to-event process is modeled using a cause-specific Cox proportional hazards model with time-fixed covariates, while longitudinal biomarkers are modeled using linear mixed-effects models. The association between the longitudinal and survival processes is captured through shared random effects. The package enables analysis of large-scale biomedical data to model biomarker trajectories, estimate their effects on event risks, and perform dynamic prediction of future events based on patients' longitudinal histories. Functions for simulating survival and longitudinal data for multiple biomarkers are included, along with built-in example datasets. The package also supports modeling a single biomarker with heterogeneous within-subject variability via functionality adapted from the 'JMH' package. |
| Authors: | Shanpeng Li [aut, cre], Ace Mejia-Sanchez [ctb], Emily Ouyang [ctb], Gang Li [ctb] |
| Maintainer: | Shanpeng Li <[email protected]> |
| License: | GPL (>= 3) |
| Version: | 1.7.0 |
| Built: | 2026-06-05 14:52:14 UTC |
| Source: | https://github.com/shanpengli/fastjm |
The cdata data frame has 1000 rows and 7 columns.
data(cdata)data(cdata)
This data frame contains the following columns:
IDpatient identifier.
survevent time.
failure_typeevent indicator. 0 denotes censoring, 1 risk 1,
and 2 risk 2.
x1continuous variable.
x2treatment indicator. 0 denotes the placebo group and 1 the treatment group.
gendergender indicator.
racerace indicator.
The cdatah data frame has 200 rows and 6 columns.
data(cdatah)data(cdatah)
This data frame contains the following columns:
IDpatient identifier.
survtimeevent time.
cmprskevent indicator. 0 denotes censoring, 1 risk 1,
and 2 risk 2.
var1treatment indicator. 0 denotes the placebo group and 1 the treatment group.
var2continuous variable.
var3continuous variable.
Combines specified biomarker measurements across a list of data frames and returns a unified long-format data set restricted to subjects with at least one recorded measurement for EVERY requested biomarker.
The function searches each provided data frame for the biomarker names listed
in biomarkers, extracts the matching measurement rows, and standardizes
the output into a common structure. Subjects are retained only if they have
at least one non-missing measurement for every requested biomarker across the
supplied data frames. It is intended for settings where biomarker measurements
may be distributed across multiple data frames, and where each data frame may
contain one or more of the requested biomarkers. The returned data are in long
format so that repeated measurements per subject and per biomarker are preserved.
No collapsing, averaging, or other within-subject summarization is performed.
combine_biomarkers( data_list, biomarkers, id_col, time_col = NULL, dataset_names = NULL )combine_biomarkers( data_list, biomarkers, id_col, time_col = NULL, dataset_names = NULL )
data_list |
A non-empty list of data frames containing subject-level biomarker measurements. |
biomarkers |
A character vector of biomarker column names to search for across the supplied data frames. |
id_col |
A character string giving the subject ID column name. This
column must be present in every data frame in |
time_col |
An optional character string giving the time variable column
name, such as days from baseline. If supplied, this column must be present
in every data frame in |
dataset_names |
An optional character vector of names for the supplied
data frames. If omitted, the function uses |
A list with the following components:
combined_longA long-format data frame containing only
included subjects. The output includes the subject ID column, a
dataset column identifying the source data frame, a
biomarker column identifying the biomarker name, a standardized
value column containing the measurement values, and a standardized
time column if time_col was supplied.
included_idsA vector of subject IDs retained in the final combined data. These are the subjects with at least one non-missing measurement for every requested biomarker.
ids_by_biomarkerA named list giving the subject IDs with at least one non-missing measurement for each biomarker.
presence_summaryA data frame summarizing biomarker presence among the included subjects, with one row per subject and one logical column per biomarker.
Shanpeng Li [email protected]
df_a <- data.frame( ID = c(1, 1, 2, 3, 4, 5), day = c(0, 30, 0, 0, 0, 0), sbp = c(120, 125, 130, NA, 110, 118) ) df_b <- data.frame( ID = c(1, 2, 2, 3, 5, 6), day = c(0, 0, 20, 0, 0, 0), dbp = c(80, 85, 84, 90, NA, 88) ) df_c <- data.frame( ID = c(1, 1, 2, 4, 5, 5), day = c(0, 40, 0, 0, 0, 10), bpm = c(70, 72, 68, 75, 77, 79) ) res <- combine_biomarkers( data_list = list(df_a, df_b, df_c), biomarkers = c("sbp", "dbp", "bpm"), id_col = "ID", time_col = "day" ) res$included_ids head(res$combined_long) res$presence_summarydf_a <- data.frame( ID = c(1, 1, 2, 3, 4, 5), day = c(0, 30, 0, 0, 0, 0), sbp = c(120, 125, 130, NA, 110, 118) ) df_b <- data.frame( ID = c(1, 2, 2, 3, 5, 6), day = c(0, 0, 20, 0, 0, 0), dbp = c(80, 85, 84, 90, NA, 88) ) df_c <- data.frame( ID = c(1, 1, 2, 4, 5, 5), day = c(0, 40, 0, 0, 0, 10), bpm = c(70, 72, 68, 75, 77, 79) ) res <- combine_biomarkers( data_list = list(df_a, df_b, df_c), biomarkers = c("sbp", "dbp", "bpm"), id_col = "ID", time_col = "day" ) res$included_ids head(res$combined_long) res$presence_summary
Concordance for joint models
Concordance for joint models
Concordance.JMMLSM( seed = 100, object, n.cv = 3, maxiter = 10000, initial.para = TRUE, ... ) Concordance.jmcs( seed = 100, object, n.cv = 3, maxiter = 10000, initial.para = TRUE, ... )Concordance.JMMLSM( seed = 100, object, n.cv = 3, maxiter = 10000, initial.para = TRUE, ... ) Concordance.jmcs( seed = 100, object, n.cv = 3, maxiter = 10000, initial.para = TRUE, ... )
seed |
a numeric value of seed to be specified for cross validation. |
object |
object of class 'jmcs'. |
n.cv |
number of folds for cross validation. Default is 3. |
maxiter |
the maximum number of iterations of the EM algorithm that the function will perform. Default is 10000. |
initial.para |
Initial guess of parameters for cross validation. Default is FALSE. |
... |
Further arguments passed to or from other methods. |
opt |
Optimization method to fit a linear mixed effects model, either nlminb (default) or optim. |
a list of matrices with conditional probabilities for subjects.
a list of matrices with conditional probabilities for subjects.
Shanpeng Li [email protected]
Dynamic prediction accuracy metrics for fitted joint models
DynPredAcc( seed = 100, object, landmark.time = NULL, horizon.time = NULL, obs.time = NULL, method = c("Laplace", "GH"), quadpoint = NULL, maxiter = NULL, n.cv = 3, quantile.width = 0.25, opt = c("nlminb", "optim"), LOCF = FALSE, LOCFcovariate = NULL, clongdata = NULL, metrics = c("AUC", "Cindex", "Brier Score", "MAE", "MAEQ"), cpu.cores = 1, ... )DynPredAcc( seed = 100, object, landmark.time = NULL, horizon.time = NULL, obs.time = NULL, method = c("Laplace", "GH"), quadpoint = NULL, maxiter = NULL, n.cv = 3, quantile.width = 0.25, opt = c("nlminb", "optim"), LOCF = FALSE, LOCFcovariate = NULL, clongdata = NULL, metrics = c("AUC", "Cindex", "Brier Score", "MAE", "MAEQ"), cpu.cores = 1, ... )
seed |
A numeric value used to set the random seed for cross-validation.
Default is |
object |
A fitted object of class |
landmark.time |
A numeric value specifying the landmark time at which dynamic prediction begins. |
horizon.time |
A numeric vector of future times at which predicted probabilities are evaluated. |
obs.time |
A character string specifying the longitudinal time variable in the longitudinal data. |
method |
A character string specifying the approximation method used for
dynamic prediction. Available options are |
quadpoint |
Number of Gauss–Hermite quadrature points used when
|
maxiter |
Maximum number of EM iterations allowed when refitting the
model within each cross-validation fold. If |
n.cv |
Number of cross-validation folds. Default is |
quantile.width |
Numeric value specifying the width of the quantile
groups used for |
opt |
Optimization method used when refitting the model in each fold.
Available options are |
LOCF |
Logical value indicating whether the last-observation-carried-
forward approach is applied for time-dependent survival covariates during
prediction. Default is |
LOCFcovariate |
A character vector specifying the time-dependent
survival covariates to be updated by last observation carried forward when
|
clongdata |
A long-format data frame containing time-dependent survival
covariates used when |
metrics |
A character vector specifying which prediction accuracy
metrics to compute. Available options are |
... |
Further arguments passed to model-specific methods. |
Computes dynamic prediction accuracy measures for fitted joint models of
class jmcs, JMMLSM, or mvjmcs using grouped
cross-validation.
At each cross-validation fold, the function refits the joint model on the training set, obtains subject-specific dynamic predictions for validation subjects at the requested horizon times, and evaluates the requested prediction accuracy metrics.
Supported metrics include:
"AUC"Time-dependent area under the ROC curve.
"Cindex"Concordance index for dynamic predictions.
"Brier Score"Inverse-probability-of-censoring weighted Brier score.
"MAE"Inverse-probability-of-censoring weighted mean absolute error.
"MAEQ"Quantile-based calibration summaries comparing empirical and predicted cumulative incidence rates or survival probabilities.
For competing-risks models, event-specific cumulative incidence predictions are evaluated. For single-event models, conditional survival probabilities are evaluated.
The function performs grouped cross-validation at the subject level. Within each fold, the model is refit on the training data, and dynamic predictions are computed for validation subjects who remain under observation beyond the landmark time and who have longitudinal observations observed up to that time. For single-event models, prediction accuracy is based on conditional survival probabilities. For competing-risks models, prediction accuracy is based on event-specific cumulative incidence functions.
An object of class DynPredAcc, returned as a list containing:
jm.classThe class of the fitted joint model.
n.cvThe number of cross-validation folds.
landmark.timeThe landmark time used for dynamic prediction.
horizon.timeThe vector of horizon times used for evaluation.
methodThe dynamic prediction approximation method used, if applicable.
quadpointThe number of quadrature points used, if applicable.
CompetingRiskLogical value indicating whether the fitted model accounts for competing risks.
seedThe random seed used for cross-validation.
metricsThe requested evaluation metrics.
quantile.widthThe width of quantile groups used for quantile-based calibration summaries.
AUC.cvA list of fold-specific time-dependent AUC estimates,
returned when "AUC" is requested.
Cindex.cvA list of fold-specific concordance index estimates,
returned when "Cindex" is requested.
Brier.cvA list of fold-specific inverse-probability-of-
censoring weighted Brier scores, returned when "Brier Score" is
requested.
MAE.cvA list of fold-specific inverse-probability-of-
censoring weighted mean absolute errors, returned when "MAE" is
requested.
MAEQ.cvA list of fold-specific quantile-based calibration
summaries, returned when "MAEQ" is requested.
jmcs, JMMLSM, mvjmcs,
survfitjmcs, survfitJMMLSM, survfitmvjmcs
Extract fitted values for joint models.
## S3 method for class 'jmcs' fitted( object, type = c("Marginal", "Subject"), process = c("Longitudinal", "Event"), ... )## S3 method for class 'jmcs' fitted( object, type = c("Marginal", "Subject"), process = c("Longitudinal", "Event"), ... )
object |
an object inheriting from class |
type |
for which type of fitted values to calculate. |
process |
for which sub-model to calculate the fitted values. |
... |
further arguments passed to or from other methods. |
a numeric vector of fitted values.
Shanpeng Li [email protected]
fit <- jmcs(ydata = ydata, cdata = cdata, long.formula = response ~ time + gender + x1 + race, surv.formula = Surv(surv, failure_type) ~ x1 + gender + x2 + race, random = ~ time| ID) # fitted for the longitudinal process head(cbind( "Marg" = fitted(fit, type = "Marginal", process = "Longitudinal"), "Subj" = fitted(fit, type = "Subject", process = "Longitudinal") )) # fitted for the levent process - marginal survival function head(fitted(fit, type = "Marginal", process = "Event"))fit <- jmcs(ydata = ydata, cdata = cdata, long.formula = response ~ time + gender + x1 + race, surv.formula = Surv(surv, failure_type) ~ x1 + gender + x2 + race, random = ~ time| ID) # fitted for the longitudinal process head(cbind( "Marg" = fitted(fit, type = "Marginal", process = "Longitudinal"), "Subj" = fitted(fit, type = "Subject", process = "Longitudinal") )) # fitted for the levent process - marginal survival function head(fitted(fit, type = "Marginal", process = "Event"))
Extracts the fixed effects for a fitted joint model.
fixef(object, process = c("Longitudinal", "Event"), ...)fixef(object, process = c("Longitudinal", "Event"), ...)
object |
an object inheriting from class |
process |
for which sub-model to extract the estimated coefficients. |
... |
further arguments passed to or from other methods. |
A numeric vector or a list of the estimated parameters for the fitted model.
Shanpeng Li [email protected]
# a joint model fit fit <- jmcs(ydata = ydata, cdata = cdata, long.formula = response ~ time + gender + x1 + race, surv.formula = Surv(surv, failure_type) ~ x1 + gender + x2 + race, random = ~ time| ID) # fixed effects for the longitudinal process fixef(fit, process = "Longitudinal") # fixed effects for the event process fixef(fit, process = "Event")# a joint model fit fit <- jmcs(ydata = ydata, cdata = cdata, long.formula = response ~ time + gender + x1 + race, surv.formula = Surv(surv, failure_type) ~ x1 + gender + x2 + race, random = ~ time| ID) # fixed effects for the longitudinal process fixef(fit, process = "Longitudinal") # fixed effects for the event process fixef(fit, process = "Event")
Joint modeling of longitudinal continuous data and competing risks
jmcs( ydata, cdata, long.formula, random = NULL, surv.formula, control = jmcs_control() )jmcs( ydata, cdata, long.formula, random = NULL, surv.formula, control = jmcs_control() )
ydata |
A longitudinal data frame in long format. |
cdata |
A survival data frame with one row per subject, containing the survival time, event indicator, and baseline covariates. |
long.formula |
A formula object specifying the response variable and fixed-effect covariates in the longitudinal submodel. |
random |
A one-sided formula object specifying the random-effects
structure in the longitudinal submodel. For example, a random-intercept model
can be specified as |
surv.formula |
A formula object specifying the survival time, event indicator, and covariates in the survival submodel. |
control |
A list of fitting-control options, typically generated by
|
Object of class jmcs with elements
beta |
the vector of fixed effects for the linear mixed effects model. |
gamma1 |
the vector of fixed effects for type 1 failure for the survival model. |
gamma2 |
the vector of fixed effects for type 2 failure for the survival model.
Valid only if |
nu1 |
the vector of association parameter(s) for type 1 failure. |
nu2 |
the vector of association parameter(s) for type 2 failure. Valid only if |
H01 |
the matrix that collects baseline hazards evaluated at each uncensored event time for type 1 failure. The first column denotes uncensored event times, the second column the number of events, and the third columns the hazards obtained by Breslow estimator. |
H02 |
the matrix that collects baseline hazards evaluated at each uncensored event time for type 2 failure.
The data structure is the same as |
Sig |
the variance-covariance matrix of the random effects. |
sigma |
the variance of the measurement error for the linear mixed effects model. |
iter |
the total number of iterations until convergence. |
convergence |
convergence identifier: 1 corresponds to successful convergence, whereas 0 to a problem (i.e., when 0, usually more iterations are required). |
vcov |
the variance-covariance matrix of all the fixed effects for both models. |
sebeta |
the standard error of |
segamma1 |
the standard error of |
segamma2 |
the standard error of |
senu1 |
the standard error of |
senu2 |
the standard error of |
seSig |
the vector of standard errors of covariance of random effects. |
sesigma |
the standard error of variance of measurement error for the linear mixed effects model. |
loglike |
the log-likelihood value. |
fitted |
a list with the fitted values:
|
fittedSurv |
the estimated survival rate evaluated at each uncensored event time. |
FUNB |
the estimated random effects for each subject. |
CompetingRisk |
logical value; TRUE if a competing event are accounted for. |
quadpoint |
the number of Gauss Hermite quadrature points used for numerical integration. |
ydata |
the input longitudinal dataset for fitting a joint model.
It has been re-ordered in accordance with descending observation times in |
cdata |
the input survival dataset for fitting a joint model. It has been re-ordered in accordance with descending observation times. |
PropEventType |
a frequency table of number of events. |
LongitudinalSubmodel |
the component of the |
SurvivalSubmodel |
the component of the |
random |
the component of the |
tol |
the convergence parameter. |
call |
the matched call. |
Quad.method |
the quadrature rule used for integration.
If pseudo-adaptive quadrature rule is used, then return |
id |
the grouping vector for the longitudinal outcome. |
Shanpeng Li [email protected]
ranef, fixef, fitted.jmcs,
residuals.jmcs, survfitjmcs, plot.jmcs,
vcov.jmcs
require(FastJM) require(survival) # Load a simulated longitudinal dataset data(ydata) # Load a simulated survival dataset with two competing events data(cdata) # Fit a joint model fit <- jmcs(ydata = ydata, cdata = cdata, long.formula = response ~ time + gender + x1 + race, surv.formula = Surv(surv, failure_type) ~ x1 + gender + x2 + race, random = ~ time| ID) fit # Extract the parameter estimates of longitudinal sub-model fixed effects fixef(fit, process = "Longitudinal") # Extract the parameter estimates of survival sub-model fixed effects fixef(fit, process = "Event") # Obtain the random effects estimates for first 6 subjects head(ranef(fit)) # Obtain the variance-covariance matrix of all parameter estimates vcov(fit) # Obtain the result summaries of the joint model fit summary(fit, process = "Longitudinal") summary(fit, process = "Event") # Prediction of cumulative incidence for competing risks data # Predict the conditional probabilities for two patients who are alive (censored) ND <- ydata[ydata$ID %in% c(419, 218), ] ID <- unique(ND$ID) NDc <- cdata[cdata$ID %in% ID, ] survfit <- survfitjmcs(fit, ynewdata = ND, cnewdata = NDc, u = seq(3, 4.8, by = 0.2), method = "GH", obs.time = "time") survfit res <- DynPredAccjmcs(object = fit, landmark.time = 3, horizon.time = c(3.6, 4, 4.4), obs.time = "time", method = "GH", maxiter = 1000, n.cv = 3, metrics = c("AUC", "Cindex", "Brier", "MAE", "MAEQ")) # Print all available evaluation metrics for the fitted joint model summary(res, metric = "Brier") summary(res, metric = "MAE") summary(res, metric = "MAEQ") summary(res, metric = "AUC") summary(res, metric = "Cindex")require(FastJM) require(survival) # Load a simulated longitudinal dataset data(ydata) # Load a simulated survival dataset with two competing events data(cdata) # Fit a joint model fit <- jmcs(ydata = ydata, cdata = cdata, long.formula = response ~ time + gender + x1 + race, surv.formula = Surv(surv, failure_type) ~ x1 + gender + x2 + race, random = ~ time| ID) fit # Extract the parameter estimates of longitudinal sub-model fixed effects fixef(fit, process = "Longitudinal") # Extract the parameter estimates of survival sub-model fixed effects fixef(fit, process = "Event") # Obtain the random effects estimates for first 6 subjects head(ranef(fit)) # Obtain the variance-covariance matrix of all parameter estimates vcov(fit) # Obtain the result summaries of the joint model fit summary(fit, process = "Longitudinal") summary(fit, process = "Event") # Prediction of cumulative incidence for competing risks data # Predict the conditional probabilities for two patients who are alive (censored) ND <- ydata[ydata$ID %in% c(419, 218), ] ID <- unique(ND$ID) NDc <- cdata[cdata$ID %in% ID, ] survfit <- survfitjmcs(fit, ynewdata = ND, cnewdata = NDc, u = seq(3, 4.8, by = 0.2), method = "GH", obs.time = "time") survfit res <- DynPredAccjmcs(object = fit, landmark.time = 3, horizon.time = c(3.6, 4, 4.4), obs.time = "time", method = "GH", maxiter = 1000, n.cv = 3, metrics = c("AUC", "Cindex", "Brier", "MAE", "MAEQ")) # Print all available evaluation metrics for the fitted joint model summary(res, metric = "Brier") summary(res, metric = "MAE") summary(res, metric = "MAEQ") summary(res, metric = "AUC") summary(res, metric = "Cindex")
Control options for jmcs()
jmcs_control( quadpoint = NULL, maxiter = 10000, verbose = FALSE, initial.para = NULL, tol = 1e-04, method = c("pseudo-adaptive", "standard"), opt = c("nlminb", "optim") )jmcs_control( quadpoint = NULL, maxiter = 10000, verbose = FALSE, initial.para = NULL, tol = 1e-04, method = c("pseudo-adaptive", "standard"), opt = c("nlminb", "optim") )
quadpoint |
Number of Gauss–Hermite quadrature points used for numerical
integration. The default is |
maxiter |
Maximum number of EM iterations. The default is |
verbose |
Logical value indicating whether to print iteration details.
The default is |
initial.para |
Optional list of user-supplied initial parameter values
for the EM algorithm. The default is |
tol |
Convergence tolerance. The default is |
method |
Numerical integration method used in the E-step. Available
options are |
opt |
Optimization method used to fit the initial linear mixed-effects
model. Available options are |
Specifies numerical integration, convergence, initialization, and optimizer
settings for jmcs().
A list of control parameters used by jmcs().
Joint modeling of longitudinal continuous data and competing risks
JMMLSM( cdata, ydata, long.formula, surv.formula, variance.formula, random, control = JMMLSM_control() )JMMLSM( cdata, ydata, long.formula, surv.formula, variance.formula, random, control = JMMLSM_control() )
cdata |
A survival data frame with one row per subject, containing the survival time, event indicator, and baseline covariates. |
ydata |
A longitudinal data frame in long format. |
long.formula |
A formula object specifying the response variable and fixed-effect covariates in the longitudinal mean submodel. |
surv.formula |
A formula object specifying the survival time, event indicator, and covariates in the survival submodel. |
variance.formula |
A one-sided formula object specifying the fixed-effect covariates in the within-subject variance submodel. |
random |
A one-sided formula object specifying the random-effects
structure in the longitudinal submodel. For example, a random-intercept model
can be specified as |
control |
A list of fitting-control options, typically generated by
|
Fits a joint mean and within-subject variability model for longitudinal continuous outcomes and competing risks or single-failure time-to-event outcomes.
Object of class JMMLSM with elements
ydata |
the input longitudinal dataset for fitting a joint model.
It has been re-ordered in accordance with descending observation times in |
cdata |
the input survival dataset for fitting a joint model. It has been re-ordered in accordance with descending observation times. |
PropEventType |
a frequency table of number of events. |
beta |
the vector of fixed effects for the mean trajectory in the mixed effects location and scale model. |
tau |
the vector of fixed effects for the within-subject variability in the mixed effects location and scale model. |
gamma1 |
the vector of fixed effects for type 1 failure for the survival model. |
gamma2 |
the vector of fixed effects for type 2 failure for the survival model.
Valid only if |
alpha1 |
the vector of association parameter(s) for the mean trajectory for type 1 failure. |
alpha2 |
the vector of association parameter(s) for the mean trajectory for type 2 failure. Valid only if |
vee1 |
the vector of association parameter(s) for the within-subject variability for type 1 failure. |
vee2 |
the vector of association parameter(s) for the within-subject variability for type 2 failure. Valid only if |
H01 |
the matrix that collects baseline hazards evaluated at each uncensored event time for type 1 failure. The first column denotes uncensored event times, the second column the number of events, and the third columns the hazards obtained by Breslow estimator. |
H02 |
the matrix that collects baseline hazards evaluated at each uncensored event time for type 2 failure.
The data structure is the same as |
Sig |
the variance-covariance matrix of the random effects. |
iter |
the total number of iterations until convergence. |
convergence |
convergence identifier: 1 corresponds to successful convergence, whereas 0 to a problem (i.e., when 0, usually more iterations are required). |
vcov |
the variance-covariance matrix of all the fixed effects for both models. |
sebeta |
the standard error of |
setau |
the standard error of |
segamma1 |
the standard error of |
segamma2 |
the standard error of |
sealpha1 |
the standard error of |
sealpha2 |
the standard error of |
sevee1 |
the standard error of |
sevee2 |
the standard error of |
seSig |
the vector of standard errors of covariance of random effects. |
loglike |
the log-likelihood value. |
EFuntheta |
a list with the expected values of all the functions of random effects. |
CompetingRisk |
logical value; TRUE if a competing event are accounted for. |
quadpoint |
the number of Gauss Hermite quadrature points used for numerical integration. |
LongitudinalSubmodelmean |
the component of the |
LongitudinalSubmodelvariance |
the component of the |
SurvivalSubmodel |
the component of the |
random |
the component of the |
call |
the matched call. |
require(FastJM) data(ydata) data(cdata) ## fit a joint model ## Not run: fit <- JMMLSM(cdata = cdata, ydata = ydata, long.formula = Y ~ Z1 + Z2 + Z3 + time, surv.formula = Surv(survtime, cmprsk) ~ var1 + var2 + var3, variance.formula = ~ Z1 + Z2 + Z3 + time) ## make dynamic prediction of two subjects cnewdata <- cdata[cdata$ID %in% c(122, 152), ] ynewdata <- ydata[ydata$ID %in% c(122, 152), ] survfit <- survfitJMMLSM(fit, seed = 100, ynewdata = ynewdata, cnewdata = cnewdata, u = seq(5.2, 7.2, by = 0.5), Last.time = "survtime", obs.time = "time", method = "GH") oldpar <- par(mfrow = c(2, 2), mar = c(5, 4, 4, 4)) plot(survfit, include.y = TRUE) par(oldpar) ## End(Not run)require(FastJM) data(ydata) data(cdata) ## fit a joint model ## Not run: fit <- JMMLSM(cdata = cdata, ydata = ydata, long.formula = Y ~ Z1 + Z2 + Z3 + time, surv.formula = Surv(survtime, cmprsk) ~ var1 + var2 + var3, variance.formula = ~ Z1 + Z2 + Z3 + time) ## make dynamic prediction of two subjects cnewdata <- cdata[cdata$ID %in% c(122, 152), ] ynewdata <- ydata[ydata$ID %in% c(122, 152), ] survfit <- survfitJMMLSM(fit, seed = 100, ynewdata = ynewdata, cnewdata = cnewdata, u = seq(5.2, 7.2, by = 0.5), Last.time = "survtime", obs.time = "time", method = "GH") oldpar <- par(mfrow = c(2, 2), mar = c(5, 4, 4, 4)) plot(survfit, include.y = TRUE) par(oldpar) ## End(Not run)
Control options for JMMLSM()
JMMLSM_control( maxiter = 1000, tol = 1e-04, quadpoint = NULL, verbose = FALSE, initial.para = NULL, method = c("adaptive", "standard"), opt = c("nlminb", "optim") )JMMLSM_control( maxiter = 1000, tol = 1e-04, quadpoint = NULL, verbose = FALSE, initial.para = NULL, method = c("adaptive", "standard"), opt = c("nlminb", "optim") )
maxiter |
Maximum number of EM iterations. The default is |
tol |
Convergence tolerance. The default is |
quadpoint |
Number of Gauss–Hermite quadrature points. The default is
|
verbose |
Logical value indicating whether to print iteration details.
The default is |
initial.para |
Optional list of user-supplied initial parameter values.
The default is |
method |
Numerical integration method used in the E-step. Available
options are |
opt |
Optimization method used to fit the initial linear mixed-effects
model. Available options are |
Specifies numerical integration, convergence, initialization, and optimizer
settings for JMMLSM().
A list of control parameters used by JMMLSM().
The mvcdata data frame has 500 rows and 5 columns.
data(mvcdata)data(mvcdata)
This data frame contains the following columns:
IDpatient identifier.
survtimeevent time.
cmprskevent indicator. 0 denotes censoring, 1 risk 1,
and 2 risk 2.
X21X21.
X22X22.
Joint modeling of multivariate longitudinal and competing risks data
mvjmcs( ydata, cdata, long.formula, random = NULL, surv.formula, control = mvjmcs_control() )mvjmcs( ydata, cdata, long.formula, random = NULL, surv.formula, control = mvjmcs_control() )
ydata |
A longitudinal data frame in long format. |
cdata |
A survival data frame with competing risks or single failure. Each subject has one data entry. |
long.formula |
A list of formula objects specifying fixed effects for each longitudinal outcome. |
random |
A formula or list of formulas describing random-effects
structures. For example, a random-intercept model can be specified as
|
surv.formula |
A formula object specifying the survival time, event indicator, and covariates in the survival submodel. |
control |
A list of fitting-control options, typically generated by
|
An object of class mvjmcs, returned as a list containing:
betaThe vector of all biomarker-specific fixed effects for the linear mixed-effects submodels.
betaListThe list of biomarker-specific fixed effects for the linear mixed-effects submodels.
gamma1The vector of fixed effects for type 1 failure in the survival submodel.
gamma2The vector of fixed effects for type 2 failure in the
survival submodel. Valid only if CompetingRisk = TRUE.
alpha1The vector of association parameters for type 1 failure.
alpha2The vector of association parameters for type 2
failure. Valid only if CompetingRisk = TRUE.
H01The matrix of baseline hazards evaluated at uncensored event times for type 1 failure.
H02The matrix of baseline hazards evaluated at uncensored
event times for type 2 failure. Valid only if
CompetingRisk = TRUE.
SigThe variance-covariance matrix of the random effects.
sigmaThe vector of biomarker-specific measurement-error variances.
iterThe total number of iterations until convergence.
convergenceConvergence identifier: 1 indicates
successful convergence, whereas 0 indicates a convergence problem,
often requiring more iterations.
vcovThe variance-covariance matrix of all fixed-effect parameters.
FisherInfoThe empirical Fisher information matrix.
ScoreA matrix of subject-specific score contributions.
sebetaThe standard errors of beta.
segamma1The standard errors of gamma1.
segamma2The standard errors of gamma2. Valid only if
CompetingRisk = TRUE.
sealpha1The standard errors of alpha1.
sealpha2The standard errors of alpha2. Valid only if
CompetingRisk = TRUE.
seSigThe vector of standard errors for covariance parameters of the random effects.
sesigmaThe standard errors of biomarker-specific measurement-error variances.
pos.modeThe posterior mode of the conditional distribution of random effects.
pos.covThe posterior covariance of the conditional distribution of random effects.
CompetingRiskLogical value indicating whether competing events are modeled.
ydataThe input longitudinal dataset, reordered according to
descending observation times in cdata.
cdataThe input survival dataset, reordered according to descending observation times.
PropEventTypeA frequency table of event types.
LongitudinalSubmodelThe longitudinal submodel specified by
long.formula.
SurvivalSubmodelThe survival submodel specified by
surv.formula.
randomThe random-effects specification.
controlThe fitting-control options used.
callThe matched function call.
idThe grouping vector for the longitudinal outcomes.
runtimeThe total computation time.
require(FastJM) require(survival) require(future) require(future.apply) data(mvcdata) data(mvydata) # Fit joint model with two biomarkers fit <- mvjmcs(ydata = mvydata, cdata = mvcdata, long.formula = list(Y1 ~ X11 + X12 + time, Y2 ~ X11 + X12 + time), random = list(~ time | ID, ~ 1 | ID), surv.formula = Surv(survtime, cmprsk) ~ X21 + X22) fit # Extract the parameter estimates of longitudinal sub-model fixed effects fixef(fit, process = "Longitudinal") # Extract the parameter estimates of survival sub-model fixed effects fixef(fit, process = "Event") # Obtain the random effects estimates for first 6 subjects head(ranef(fit))require(FastJM) require(survival) require(future) require(future.apply) data(mvcdata) data(mvydata) # Fit joint model with two biomarkers fit <- mvjmcs(ydata = mvydata, cdata = mvcdata, long.formula = list(Y1 ~ X11 + X12 + time, Y2 ~ X11 + X12 + time), random = list(~ time | ID, ~ 1 | ID), surv.formula = Surv(survtime, cmprsk) ~ X21 + X22) fit # Extract the parameter estimates of longitudinal sub-model fixed effects fixef(fit, process = "Longitudinal") # Extract the parameter estimates of survival sub-model fixed effects fixef(fit, process = "Event") # Obtain the random effects estimates for first 6 subjects head(ranef(fit))
Control options for mvjmcs()
mvjmcs_control( maxiter = 10000, opt = c("nlminb", "optim"), tol = 0.005, verbose = FALSE, initial.para = NULL, cpu.cores = NULL )mvjmcs_control( maxiter = 10000, opt = c("nlminb", "optim"), tol = 0.005, verbose = FALSE, initial.para = NULL, cpu.cores = NULL )
maxiter |
Maximum number of EM iterations. The default is |
opt |
Optimization method used to fit the initial mixed-effects models.
Available options are |
tol |
Convergence tolerance. The default is |
verbose |
Logical value indicating whether to print iteration details.
The default is |
initial.para |
Optional list of user-supplied initial parameter values
for the EM algorithm. The default is |
cpu.cores |
Number of CPU cores used for parallel computation. The
default is |
Specifies convergence, initialization, optimizer, verbosity, and parallel
computing settings for mvjmcs().
A list of control parameters used by mvjmcs().
The mvydata data frame has 4060 rows and 6 columns.
data(mvydata)data(mvydata)
This data frame contains the following columns:
IDpatient identifier.
timevisit time.
Y1response variable of biomarker 1.
Y2response variable of biomarker 2.
X11X11.
X12X12.
Plot Diagnostics for Joint Models.
## S3 method for class 'jmcs' plot(x, add.smooth = getOption("add.smooth"), ...)## S3 method for class 'jmcs' plot(x, add.smooth = getOption("add.smooth"), ...)
x |
x of class 'jmcs'. |
add.smooth |
logical; if |
... |
further arguments passed to or from other methods. |
The first two plots are longitudinal sub-model diagnostics and the last two are marginal survival function and marginal cumulative hazard.
Shanpeng Li [email protected]
fit <- jmcs(ydata = ydata, cdata = cdata, long.formula = response ~ time + gender + x1 + race, surv.formula = Surv(surv, failure_type) ~ x1 + gender + x2 + race, random = ~ time| ID) plot(fit)fit <- jmcs(ydata = ydata, cdata = cdata, long.formula = response ~ time + gender + x1 + race, surv.formula = Surv(surv, failure_type) ~ x1 + gender + x2 + race, random = ~ time| ID) plot(fit)
Plot conditional probabilities for new subjects.
If CompetingRisk = FALSE, print the survival probabilities.
Otherwise, print the cumulative incidence probabilities for each failure type.
## S3 method for class 'survfitJMMLSM' plot( x, include.y = FALSE, xlab = NULL, ylab = NULL, xlim = NULL, ylim.long = NULL, ylim.surv = NULL, ... )## S3 method for class 'survfitJMMLSM' plot( x, include.y = FALSE, xlab = NULL, ylab = NULL, xlim = NULL, ylim.long = NULL, ylim.surv = NULL, ... )
x |
x of class |
include.y |
include longitudinal responses of this subject versus time. Default is FALSE. |
xlab |
X axis label. |
ylab |
Y axis label. |
xlim |
X axis support. |
ylim.long |
Y axis support for the longitudinal outcome. |
ylim.surv |
Y axis support for the event / survival probability. |
... |
further arguments passed to or from other methods. |
plots of conditional probabilities over different pre-specified time points for subjects. If single failure type, then survival probabilities will be returned. Otherwise, cumulative incidence probabilities for each failure type will be returned.
Shanpeng Li [email protected]
Print jmcs
Print mvjmcs
## S3 method for class 'jmcs' print(x, digits = 4, ...) ## S3 method for class 'mvjmcs' print(x, digits = 4, ...)## S3 method for class 'jmcs' print(x, digits = 4, ...) ## S3 method for class 'mvjmcs' print(x, digits = 4, ...)
x |
Object of class 'mvjmcs'. |
digits |
the number of significant digits to use when printing. |
... |
Further arguments passed to or from other methods. |
a summary of data, joint model, log likelihood, and parameter estimates.
a summary of data, joint model, log likelihood, and parameter estimates.
Shanpeng Li [email protected]
Print contents of JMMLSM object.
## S3 method for class 'JMMLSM' print(x, digits = 4, ...)## S3 method for class 'JMMLSM' print(x, digits = 4, ...)
x |
Object of class 'JMMLSM'. |
digits |
number of digits of decimal to be printed. |
... |
Further arguments passed to or from other methods. |
a summary of data, joint model, log likelihood, and parameter estimates.
Shanpeng Li
Print survfitjmcs
## S3 method for class 'survfitjmcs' print(x, ...)## S3 method for class 'survfitjmcs' print(x, ...)
x |
x of class 'survfitjmcs'. |
... |
Further arguments passed to or from other methods. |
a list of matrices with conditional probabilities for subjects.
Shanpeng Li [email protected]
Print survfitJMMLSM
## S3 method for class 'survfitJMMLSM' print(x, ...)## S3 method for class 'survfitJMMLSM' print(x, ...)
x |
x of class 'survfitJMMLSM'. |
... |
Further arguments passed to or from other methods. |
a list of matrices with conditional probabilities for subjects.
Shanpeng Li [email protected]
Print survfitmvjmcs
## S3 method for class 'survfitmvjmcs' print(x, ...)## S3 method for class 'survfitmvjmcs' print(x, ...)
x |
x of class 'survfitmvjmcs'. |
... |
Further arguments passed to or from other methods. |
a list of matrices with conditional probabilities for subjects.
Shanpeng Li [email protected]
Extracts the posterior mean of the random effects for a fitted joint model.
ranef(object, ...)ranef(object, ...)
object |
an object inheriting from class |
... |
further arguments passed to or from other methods. |
a matrix of random effects estimates.
Shanpeng Li [email protected]
# a joint model fit fit <- jmcs(ydata = ydata, cdata = cdata, long.formula = response ~ time + gender + x1 + race, surv.formula = Surv(surv, failure_type) ~ x1 + gender + x2 + race, random = ~ time| ID) # extract random effects estimates head(ranef(fit))# a joint model fit fit <- jmcs(ydata = ydata, cdata = cdata, long.formula = response ~ time + gender + x1 + race, surv.formula = Surv(surv, failure_type) ~ x1 + gender + x2 + race, random = ~ time| ID) # extract random effects estimates head(ranef(fit))
Extract residuals for joint models.
## S3 method for class 'jmcs' residuals(object, type = c("Marginal", "Subject"), ...)## S3 method for class 'jmcs' residuals(object, type = c("Marginal", "Subject"), ...)
object |
an object inheriting from class |
type |
what type of residuals to calculate. |
... |
further arguments passed to or from other methods. |
a vector of residuals of the longitudinal sub-model.
Shanpeng Li [email protected]
# a joint model fit fit <- jmcs(ydata = ydata, cdata = cdata, long.formula = response ~ time + gender + x1 + race, surv.formula = Surv(surv, failure_type) ~ x1 + gender + x2 + race, random = ~ time| ID) # residuals of the longitudinal sub-model head(cbind( "Marg" = residuals(fit, type = "Marginal"), "Subj" = residuals(fit, type = "Subject") ))# a joint model fit fit <- jmcs(ydata = ydata, cdata = cdata, long.formula = response ~ time + gender + x1 + race, surv.formula = Surv(surv, failure_type) ~ x1 + gender + x2 + race, random = ~ time| ID) # residuals of the longitudinal sub-model head(cbind( "Marg" = residuals(fit, type = "Marginal"), "Subj" = residuals(fit, type = "Subject") ))
Simulates longitudinal biomarker data with heterogeneous within-subject variability and associated time-to-event data. The survival outcome may be generated either as a single-failure time-to-event outcome or as competing risks data with two failure types.
simJMWSVdata( seed = 100, N = 200, increment = 0.7, beta = c(5, 1.5, 2, 1, 2), tau = c(0.5, 0.5, -0.2, 0.2, 0.05), gamma1 = c(1, 0.5, 0.5), gamma2 = c(-0.5, 0.5, 0.25), alpha1 = c(1, 0.7), alpha2 = c(-1, -0.5), vee1 = 0.5, vee2 = -0.5, lambda1 = 0.05, lambda2 = 0.025, CL = 5, CU = 10, covbw = diag(rep(1, 3)), CR = TRUE )simJMWSVdata( seed = 100, N = 200, increment = 0.7, beta = c(5, 1.5, 2, 1, 2), tau = c(0.5, 0.5, -0.2, 0.2, 0.05), gamma1 = c(1, 0.5, 0.5), gamma2 = c(-0.5, 0.5, 0.25), alpha1 = c(1, 0.7), alpha2 = c(-1, -0.5), vee1 = 0.5, vee2 = -0.5, lambda1 = 0.05, lambda2 = 0.025, CL = 5, CU = 10, covbw = diag(rep(1, 3)), CR = TRUE )
seed |
Integer random seed used for data generation. Default is
|
N |
Integer specifying the sample size. Default is |
increment |
Numeric value specifying the increment of visit times for
longitudinal measurements. Default is |
beta |
Numeric vector of true fixed-effect parameters for the longitudinal mean sub-model. |
tau |
Numeric vector of true parameters for the within-subject variability sub-model. |
gamma1 |
Numeric vector of true fixed-effect parameters in the cause-specific hazard sub-model for failure type 1. |
gamma2 |
Numeric vector of true fixed-effect parameters in the cause-specific hazard sub-model for failure type 2. |
alpha1 |
Numeric vector of association parameters of individual mean linking the longitudinal process to the cause-specific hazard for failure type 1. |
alpha2 |
Numeric vector of association parameters individual mean linking the longitudinal process to the cause-specific hazard for failure type 2. |
vee1 |
Numeric association parameter of within-subject variability linking the longitudinal process to the cause-specific hazard for failure type 1. |
vee2 |
Numeric association parameter of within-subject variability linking the longitudinal process to the cause-specific hazard for failure type 2. |
lambda1 |
Baseline hazard rate for failure type 1. An exponential
baseline hazard with rate |
lambda2 |
Baseline hazard rate for failure type 2. An exponential
baseline hazard with rate |
CL |
Lower bound of the uniform distribution used to generate censoring times. |
CU |
Upper bound of the uniform distribution used to generate censoring times. |
covbw |
Variance-covariance matrix for the random effects in the longitudinal mean and within-subject variability sub-models. |
CR |
Logical; if |
Simulate joint model data with heterogeneous within-subject variability
A list with the following components:
ydatahA long-format data frame containing the simulated longitudinal biomarker measurements.
cdatahA data frame containing the simulated event-time data.
Data simulation from the joint model of multivariate longitudinal biomarkers and time-to-event data
simmvJMdata( seed = 100, N = 200, increment = 0.7, beta = list(beta1 = c(5, 1.5, 2, 1), beta2 = c(10, 1, 2, 1)), sigma = c(0.5, 0.5), gamma1 = c(1, 0.5), gamma2 = c(-0.5, 0.5), alpha1 = list(alpha11 = c(0.5, 0.7), alpha12 = c(-0.5, 0.5)), alpha2 = list(alpha21 = c(0.5, 0.7), alpha22 = c(-0.5, 0.5)), lambda1 = 0.05, lambda2 = 0.025, CL = 5, CU = 10, covb = diag(rep(1, 4)), missprob = 0, CR = TRUE )simmvJMdata( seed = 100, N = 200, increment = 0.7, beta = list(beta1 = c(5, 1.5, 2, 1), beta2 = c(10, 1, 2, 1)), sigma = c(0.5, 0.5), gamma1 = c(1, 0.5), gamma2 = c(-0.5, 0.5), alpha1 = list(alpha11 = c(0.5, 0.7), alpha12 = c(-0.5, 0.5)), alpha2 = list(alpha21 = c(0.5, 0.7), alpha22 = c(-0.5, 0.5)), lambda1 = 0.05, lambda2 = 0.025, CL = 5, CU = 10, covb = diag(rep(1, 4)), missprob = 0, CR = TRUE )
seed |
a random seed number specified for simulating a joint model dataset. |
N |
an integer to specify the sample size. |
increment |
a scalar to specify the increment of visit time for longitudinal measurements. |
beta |
a list of true parameters for the linear mixed effects sub-models. Each component of the list correspond to a specific biomarker. |
sigma |
a vector of true error variance for all biomarkers. |
gamma1 |
a vector of true parameters of survival fixed effects for failure 1. |
gamma2 |
a vector of true parameters of survival fixed effects for failure 2. |
alpha1 |
a list of true parameters for the association parameters for failure 1. Each component of the list correspond to a specific biomarker. |
alpha2 |
a list of true parameters for the association parameters for failure 2. Each component of the list correspond to a specific biomarker. |
lambda1 |
the baseline hazard rate of failure 1.
An exponential distribution with a rate parameter of |
lambda2 |
the baseline hazard rate of failure 2.
An exponential distribution with a rate parameter of |
CL |
a lower limit of a uniform distribution to be specified for the censoring time. |
CU |
an upper limit of a uniform distribution to be specified for the censoring time. |
covb |
a matrix of variance-covariance matrix of random effects. |
missprob |
a scalar (ranging from 0 to 1) to specify the probability of missing longitudinal observations. Default is 0. |
CR |
logical; if |
a list of datasets for both longitudinal and survival data with the elements
mvydata |
a long-format data frame of longitudinal data. |
mvcdata |
a dataframe of survival data. |
Produce result summaries of a joint model fit.
Produce result summaries of a joint model fit.
Produce result summaries of a joint model fit.
## S3 method for class 'ConcordanceJMMLSM' summary(object, digits = 4, ...) ## S3 method for class 'Concordancejmcs' summary(object, digits = 4, ...) ## S3 method for class 'DynPredAcc' summary( object, metric = c("AUC", "Cindex", "Brier Score", "MAE", "MAEQ"), digits = 4, ... ) ## S3 method for class 'JMMLSM' summary(object, process = c("longitudinal", "Event"), digits = 4, ...) ## S3 method for class 'jmcs' summary(object, process = c("Longitudinal", "Event"), digits = 4, ...) ## S3 method for class 'mvjmcs' summary(object, process = c("Longitudinal", "Event"), digits = 4, ...)## S3 method for class 'ConcordanceJMMLSM' summary(object, digits = 4, ...) ## S3 method for class 'Concordancejmcs' summary(object, digits = 4, ...) ## S3 method for class 'DynPredAcc' summary( object, metric = c("AUC", "Cindex", "Brier Score", "MAE", "MAEQ"), digits = 4, ... ) ## S3 method for class 'JMMLSM' summary(object, process = c("longitudinal", "Event"), digits = 4, ...) ## S3 method for class 'jmcs' summary(object, process = c("Longitudinal", "Event"), digits = 4, ...) ## S3 method for class 'mvjmcs' summary(object, process = c("Longitudinal", "Event"), digits = 4, ...)
object |
an object inheriting from class |
digits |
the number of significant digits to use when printing. Default is 4. |
... |
further arguments passed to or from other methods. |
metric |
a list to indicate what metric to summarize |
process |
for which model (i.e., longitudinal model or survival model) to extract the estimated coefficients. |
a list of matrices with conditional probabilities for subjects.
a list of matrices with conditional probabilities for subjects.
a summary of the list of matrices with conditional probabilities for subjects.
A table to summarize the model results.
A table to summarize the model results.
A table to summarize the model results.
Shanpeng Li [email protected]
survfitJM() is the recommended user-facing function for dynamic
prediction from fitted FastJM joint models. It dispatches automatically
according to the class of the fitted model object.
## S3 method for class 'JMMLSM' survfitJM( object, seed = 100, ynewdata = NULL, cnewdata = NULL, u = NULL, Last.time = NULL, obs.time = NULL, LOCF = FALSE, LOCFcovariate = NULL, clongdata = NULL, method = c("Laplace", "GH"), quadpoint = NULL, ... ) survfitJM(object, ...) ## S3 method for class 'jmcs' survfitJM( object, seed = 100, ynewdata = NULL, cnewdata = NULL, u = NULL, Last.time = NULL, obs.time = NULL, LOCF = FALSE, LOCFcovariate = NULL, clongdata = NULL, method = c("Laplace", "GH"), quadpoint = NULL, ... ) ## S3 method for class 'mvjmcs' survfitJM( object, seed = 100, ynewdata = NULL, cnewdata = NULL, u = NULL, Last.time = NULL, obs.time = NULL, LOCF = FALSE, LOCFcovariate = NULL, clongdata = NULL, ... )## S3 method for class 'JMMLSM' survfitJM( object, seed = 100, ynewdata = NULL, cnewdata = NULL, u = NULL, Last.time = NULL, obs.time = NULL, LOCF = FALSE, LOCFcovariate = NULL, clongdata = NULL, method = c("Laplace", "GH"), quadpoint = NULL, ... ) survfitJM(object, ...) ## S3 method for class 'jmcs' survfitJM( object, seed = 100, ynewdata = NULL, cnewdata = NULL, u = NULL, Last.time = NULL, obs.time = NULL, LOCF = FALSE, LOCFcovariate = NULL, clongdata = NULL, method = c("Laplace", "GH"), quadpoint = NULL, ... ) ## S3 method for class 'mvjmcs' survfitJM( object, seed = 100, ynewdata = NULL, cnewdata = NULL, u = NULL, Last.time = NULL, obs.time = NULL, LOCF = FALSE, LOCFcovariate = NULL, clongdata = NULL, ... )
object |
A fitted joint model object returned by |
seed |
a random seed number to proceed non-parametric bootstrap. Default is 100. |
ynewdata |
a data frame that contains the longitudinal and covariate information for the subjects for which prediction of survival probabilities is required. |
cnewdata |
a data frame that contains the survival and covariate information for the subjects for which prediction of survival probabilities is required. |
u |
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 cnewdata was known to be alive. If NULL, then this is automatically taken as the survival time of each subject. If a numeric vector, then it is assumed to be greater than or equals to the last available longitudinal time point for each subject. If a character string, then it should be a variable in cnewdata. |
obs.time |
a character string of specifying a longitudinal time variable in ynewdata. |
LOCF |
a logical value to indicate whether the last-observation-carried-forward approach applies to prediction.
If |
LOCFcovariate |
a vector of string with time-dependent survival covariates if |
clongdata |
a long format data frame where time-dependent survival covariates are incorporated. Default is NULL. |
method |
a character string specifying the type of probability approximation; if |
quadpoint |
number of quadrature points used for estimating conditional probabilities
when |
... |
Additional arguments passed to the model-specific prediction method. |
This function is an S3 generic. Depending on the class of object, it
dispatches to the corresponding model-specific prediction routine:
survfitJM.jmcs(), survfitJM.JMMLSM(), or
survfitJM.mvjmcs().
The model-specific functions survfitjmcs(),
survfitJMMLSM(), and survfitmvjmcs() are retained as
lower-level functions for backward compatibility.
An object containing dynamic prediction results. The exact structure depends on the fitted model class.
jmcs, JMMLSM, mvjmcs,
survfitjmcs, survfitJMMLSM,
survfitmvjmcs
This function computes the conditional probability of surviving later times than the last observed time for which a longitudinal measurement was available.
survfitjmcs( object, seed = 100, ynewdata = NULL, cnewdata = NULL, u = NULL, Last.time = NULL, obs.time = NULL, LOCF = FALSE, LOCFcovariate = NULL, clongdata = NULL, method = c("Laplace", "GH"), quadpoint = NULL, ... )survfitjmcs( object, seed = 100, ynewdata = NULL, cnewdata = NULL, u = NULL, Last.time = NULL, obs.time = NULL, LOCF = FALSE, LOCFcovariate = NULL, clongdata = NULL, method = c("Laplace", "GH"), quadpoint = NULL, ... )
object |
an object inheriting from class |
seed |
a random seed number to proceed Monte Carlo simulation. Default is 100. |
ynewdata |
a data frame that contains the longitudinal and covariate information for the subjects for which prediction of survival probabilities is required. |
cnewdata |
a data frame that contains the survival and covariate information for the subjects for which prediction of survival probabilities is required. |
u |
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 cnewdata was known to be alive. If NULL, then this is automatically taken as the survival time of each subject. If a numeric vector, then it is assumed to be greater than or equals to the last available longitudinal time point for each subject. If a character string, then it should be a variable in cnewdata. |
obs.time |
a character string of specifying a longitudinal time variable in ynewdata. |
LOCF |
a logical value to indicate whether the last-observation-carried-forward approach applies to prediction.
If |
LOCFcovariate |
a vector of string with time-dependent survival covariates if |
clongdata |
a long format data frame where time-dependent survival covariates are incorporated. Default is NULL. |
method |
a character string specifying the type of probability approximation; if |
quadpoint |
number of quadrature points used for estimating conditional probabilities
when |
... |
further arguments passed to or from other methods. |
This is a model-specific dynamic prediction function for objects fitted by
jmcs. It is retained for backward compatibility and for users
who prefer direct access to the single-marker prediction routine. For routine
use, users are encouraged to call survfitJM, which dispatches
automatically according to the class of the fitted model object.
a list of matrices with conditional probabilities for subjects.
Shanpeng Li [email protected]
This function computes the conditional probability of surviving later times than the last observed time for which a longitudinal measurement was available.
survfitJMMLSM( object, seed = 100, ynewdata = NULL, cnewdata = NULL, u = NULL, Last.time = NULL, obs.time = NULL, LOCF = FALSE, LOCFcovariate = NULL, clongdata = NULL, method = c("Laplace", "GH"), quadpoint = NULL, ... )survfitJMMLSM( object, seed = 100, ynewdata = NULL, cnewdata = NULL, u = NULL, Last.time = NULL, obs.time = NULL, LOCF = FALSE, LOCFcovariate = NULL, clongdata = NULL, method = c("Laplace", "GH"), quadpoint = NULL, ... )
object |
an object inheriting from class |
seed |
a random seed number to proceed non-parametric bootstrap. Default is 100. |
ynewdata |
a data frame that contains the longitudinal and covariate information for the subjects for which prediction of survival probabilities is required. |
cnewdata |
a data frame that contains the survival and covariate information for the subjects for which prediction of survival probabilities is required. |
u |
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 cnewdata was known to be alive. If NULL, then this is automatically taken as the survival time of each subject. If a numeric vector, then it is assumed to be greater than or equals to the last available longitudinal time point for each subject. If a character string, then it should be a variable in cnewdata. |
obs.time |
a character string of specifying a longitudinal time variable in ynewdata. |
LOCF |
a logical value to indicate whether the last-observation-carried-forward approach applies to prediction.
If |
LOCFcovariate |
a vector of string with time-dependent survival covariates if |
clongdata |
a long format data frame where time-dependent survival covariates are incorporated. Default is NULL. |
method |
a character string specifying the type of probability approximation; if |
quadpoint |
number of quadrature points used for estimating conditional probabilities
when |
... |
further arguments passed to or from other methods. |
This is a model-specific dynamic prediction function for objects fitted by
JMMLSM. It is retained for backward compatibility and for users
who prefer direct access to the mixed-effects location-scale prediction
routine. For routine use, users are encouraged to call
survfitJM, which dispatches automatically according to the class
of the fitted model object.
a list of matrices with conditional probabilities for subjects.
Shanpeng Li [email protected]
This function computes the conditional probability of surviving later times than the last observed time for which a longitudinal measurement was available.
survfitmvjmcs( object, seed = 100, ynewdata = NULL, cnewdata = NULL, u = NULL, Last.time = NULL, obs.time = NULL, LOCF = FALSE, LOCFcovariate = NULL, clongdata = NULL, ... )survfitmvjmcs( object, seed = 100, ynewdata = NULL, cnewdata = NULL, u = NULL, Last.time = NULL, obs.time = NULL, LOCF = FALSE, LOCFcovariate = NULL, clongdata = NULL, ... )
object |
an object inheriting from class |
seed |
a random seed number to proceed Monte Carlo simulation. Default is 100. |
ynewdata |
a data frame that contains the longitudinal and covariate information for the subjects for which prediction of survival probabilities is required. |
cnewdata |
a data frame that contains the survival and covariate information for the subjects for which prediction of survival probabilities is required. |
u |
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 cnewdata was known to be alive. If NULL, then this is automatically taken as the survival time of each subject. If a numeric vector, then it is assumed to be greater than or equals to the last available longitudinal time point for each subject. If a character string, then it should be a variable in cnewdata. |
obs.time |
a character string of specifying a longitudinal time variable in ynewdata. |
LOCF |
a logical value to indicate whether the last-observation-carried-forward approach applies to prediction.
If |
LOCFcovariate |
a vector of string with time-dependent survival covariates if |
clongdata |
a long format data frame where time-dependent survival covariates are incorporated. Default is NULL. |
... |
further arguments passed to or from other methods. |
This is a model-specific dynamic prediction function for objects fitted by
mvjmcs. It is retained for backward compatibility and for users
who prefer direct access to the multivariate prediction routine. For routine
use, users are encouraged to call survfitJM, which dispatches
automatically according to the class of the fitted model object.
a list of matrices with conditional probabilities for subjects.
Shanpeng Li [email protected]
Creates diagnostic plots for a fitted jmcs object from the
FastJM package, specifically longitudinal biomarker trajectory,
log residual variance, and event curve. The function always produces:
a longitudinal biomarker trajectory plot, and
a plot of log residual variance over follow-up time.
It also produces one event plot based on object$CompetingRisk:
if object$CompetingRisk = FALSE, a Kaplan-Meier plot is shown;
if object$CompetingRisk = TRUE, a cumulative incidence plot is shown.
The event time and status variables are inferred from
object$SurvivalSubmodel when event_time_col and
event_status_col are not supplied.
timeplot( object, biomarker, id_col, time_col, visit_col = NULL, n.obs = 100, seed = 100, window_days = 50, time_bin_width = 180, biomarker_y_lab = NULL, logvar_y_lab = "Log Residual Variance", event_x_lab = NULL, event_y_lab = NULL, x_lab = NULL, x_break_by = NULL, ylim_mean = NULL, ylim_logvar = NULL, event_time_col = NULL, event_status_col = NULL, fail_code = NULL, cr_code = NULL, censor_code = 0, primary_event_label = "Primary event", competing_event_label = NULL, km_title = NULL, cif_title = NULL, center_event_plot = TRUE )timeplot( object, biomarker, id_col, time_col, visit_col = NULL, n.obs = 100, seed = 100, window_days = 50, time_bin_width = 180, biomarker_y_lab = NULL, logvar_y_lab = "Log Residual Variance", event_x_lab = NULL, event_y_lab = NULL, x_lab = NULL, x_break_by = NULL, ylim_mean = NULL, ylim_logvar = NULL, event_time_col = NULL, event_status_col = NULL, fail_code = NULL, cr_code = NULL, censor_code = 0, primary_event_label = "Primary event", competing_event_label = NULL, km_title = NULL, cif_title = NULL, center_event_plot = TRUE )
object |
A fitted object of class |
biomarker |
Unquoted name of the longitudinal biomarker variable in
|
id_col |
Unquoted name of the subject identifier variable in
|
time_col |
Unquoted name of the longitudinal follow-up time variable in
|
visit_col |
Optional unquoted name of a visit variable in
|
n.obs |
Numeric value specifying the number of subjects randomly selected
for the longitudinal biomarker trajectory plot. Default is |
seed |
Optional integer random seed used for reproducible subject
sampling in the longitudinal biomarker trajectory plot. Default is
|
window_days |
Numeric value giving the half-width of the time window used
when selecting observations around each visit- or bin-level mean time.
Default is |
time_bin_width |
Numeric value giving the width of derived time bins when
|
biomarker_y_lab |
Optional character string for the y-axis label of the
biomarker trajectory plot. If |
logvar_y_lab |
Character string for the y-axis label of the log residual
variance plot. Default is |
event_x_lab |
Optional character string for the x-axis label of the event
plot. If |
event_y_lab |
Optional character string for the y-axis label of the event
plot. If |
x_lab |
Optional character string for the x-axis label of the longitudinal
plots. If |
x_break_by |
Numeric value controlling spacing of x-axis tick marks in
the longitudinal plots. Default is |
ylim_mean |
Optional numeric vector of length 2 giving y-axis limits for the biomarker trajectory plot. |
ylim_logvar |
Optional numeric vector of length 2 giving y-axis limits for the log residual variance plot. |
event_time_col |
Optional character string giving the event-time variable
in |
event_status_col |
Optional character string giving the event-status
variable in |
fail_code |
Numeric or integer code in |
cr_code |
Numeric or integer code in |
censor_code |
Numeric or integer code in |
primary_event_label |
Character string used in event plot labels for the
primary event. Default is |
competing_event_label |
Character string used in cumulative incidence plot
labels for the competing event. Required for informative competing-risk
labeling. Ignored for single-failure Kaplan-Meier plots. Default is
|
km_title |
Optional character string for the Kaplan-Meier plot title. If
|
cif_title |
Optional character string for the cumulative incidence plot
title. If |
center_event_plot |
Logical; if |
The longitudinal trajectory plot displays individual biomarker trajectories for
a random subset of subjects, along with a summary mean curve. If
visit_col is supplied and found in object$ydata, summaries
are calculated by observed visit. Otherwise, the function creates derived
time bins using floor(time_col / time_bin_width).
The residual variance plot displays the log residual variance over visit- or
bin-level follow-up time. Subject-level fitted values are obtained using
fitted(object, type = "Subject", process = "Longitudinal").
The event plot is chosen automatically from the fitted model:
For CompetingRisk = FALSE, the function creates a Kaplan-Meier
plot using fail_code as the event code and censor_code as the
censoring code.
For CompetingRisk = TRUE, the function creates a cumulative
incidence plot using fail_code as the primary event and
cr_code as the competing event.
In competing-risk settings, the model identifies event codes, but it does not
determine which event is scientifically "primary." The user should choose
fail_code based on the scientific question. For example, if
status = 1 is heart failure and status = 2 is death, then
fail_code = 1 and cr_code = 2 answer the question: "What is the
cumulative incidence of heart failure over time, accounting for death before
heart failure?"
Invisibly returns a list with components:
combinedThe combined plot object.
p1The biomarker trajectory plot.
p2The log residual variance plot.
p_cifThe cumulative incidence plot if
object$CompetingRisk = TRUE; otherwise NULL.
p_kmThe Kaplan-Meier plot if
object$CompetingRisk = FALSE; otherwise NULL.
cif_fitThe fitted cumulative incidence object if applicable;
otherwise NULL.
km_fitThe fitted Kaplan-Meier object if applicable; otherwise
NULL.
event_time_colThe event-time column used.
event_status_colThe event-status column used.
fail_codeThe primary event code used.
cr_codeThe competing event code used, or NULL for
single-failure models.
censor_codeThe censoring code used.
summary_dataA data frame of visit- or bin-level longitudinal summary statistics.
obs_per_subject_visitA data frame giving the number of observations per subject and visit/bin after window-based filtering.
grouping_usedA character string indicating whether summaries were based on an observed visit variable or derived time bins.
Shanpeng Li [email protected]
library(FastJM) data(ydata) data(cdata) # Single-failure example: # Treat failure_type == 1 as the only event and all other observations as censored. cdata_single <- cdata cdata_single$event_single <- as.integer(cdata_single$failure_type == 1) fit_single <- jmcs( ydata = ydata, cdata = cdata_single, long.formula = response ~ time + gender + x1 + race, surv.formula = Surv(surv, event_single) ~ x1 + gender + x2 + race, random = ~ time | ID ) singleplot <- timeplot( object = fit_single, biomarker = response, id_col = ID, time_col = time, time_bin_width = 0.5, primary_event_label = "Event type 1" ) singleplot$combined singleplot$p_km # Competing-risk example using FastJM simulated data. fit_cr <- jmcs( ydata = ydata, cdata = cdata, long.formula = response ~ time + gender + x1 + race, surv.formula = Surv(surv, failure_type) ~ x1 + gender + x2 + race, random = ~ time | ID ) crplot <- timeplot( object = fit_cr, biomarker = response, id_col = ID, time_col = time, time_bin_width = 0.5, fail_code = 1, cr_code = 2, censor_code = 0, primary_event_label = "Event type 1", competing_event_label = "Event type 2" ) crplot$combined crplot$p_ciflibrary(FastJM) data(ydata) data(cdata) # Single-failure example: # Treat failure_type == 1 as the only event and all other observations as censored. cdata_single <- cdata cdata_single$event_single <- as.integer(cdata_single$failure_type == 1) fit_single <- jmcs( ydata = ydata, cdata = cdata_single, long.formula = response ~ time + gender + x1 + race, surv.formula = Surv(surv, event_single) ~ x1 + gender + x2 + race, random = ~ time | ID ) singleplot <- timeplot( object = fit_single, biomarker = response, id_col = ID, time_col = time, time_bin_width = 0.5, primary_event_label = "Event type 1" ) singleplot$combined singleplot$p_km # Competing-risk example using FastJM simulated data. fit_cr <- jmcs( ydata = ydata, cdata = cdata, long.formula = response ~ time + gender + x1 + race, surv.formula = Surv(surv, failure_type) ~ x1 + gender + x2 + race, random = ~ time | ID ) crplot <- timeplot( object = fit_cr, biomarker = response, id_col = ID, time_col = time, time_bin_width = 0.5, fail_code = 1, cr_code = 2, censor_code = 0, primary_event_label = "Event type 1", competing_event_label = "Event type 2" ) crplot$combined crplot$p_cif
Extract variance-covariance matrix for joint models.
Extract variance-covariance matrix for joint models.
Extract variance-covariance matrix for joint models.
## S3 method for class 'JMMLSM' vcov(object, ...) ## S3 method for class 'jmcs' vcov(object, ...) ## S3 method for class 'mvjmcs' vcov(object, ...)## S3 method for class 'JMMLSM' vcov(object, ...) ## S3 method for class 'jmcs' vcov(object, ...) ## S3 method for class 'mvjmcs' vcov(object, ...)
object |
an object inheriting from class |
... |
further arguments passed to or from other methods. |
a matrix of variance covariance of all parameter estimates.
a matrix of variance covariance of all parameter estimates.
a matrix of variance covariance of all parameter estimates.
Shanpeng Li [email protected]
The ydata data frame has 3067 rows and 6 columns.
data(ydata)data(ydata)
This data frame contains the following columns:
IDpatient identifier.
responseresponse variable.
timevisit time.
x1treatment indicator. 0 denotes the placebo group and 1 the treatment group.
gendergender indicator.
racerace indicator.
The ydatah data frame has 1353 rows and 6 columns.
data(ydatah)data(ydatah)
This data frame contains the following columns:
IDpatient identifier.
Yresponse variable.
timevisit time.
Z1treatment indicator. 0 denotes the placebo group and 1 the treatment group.
Z2continuous variable..
Z3continuous variable..