Title: | Cox Non-Proportional Hazards Model with Time-Varying Coefficients |
---|---|
Description: | Fit Cox non-proportional hazards models with time-varying coefficients. Both unpenalized procedures (Newton and proximal Newton) and penalized procedures (P-splines and smoothing splines) are included using B-spline basis functions for estimating time-varying coefficients. For penalized procedures, cross validations, mAIC, TIC or GIC are implemented to select tuning parameters. Utilities for carrying out post-estimation visualization, summarization, point-wise confidence interval and hypothesis testing are also provided. For more information, see Wu et al. (2022) <doi: 10.1007/s10985-021-09544-2> and Luo et al. (2023) <doi:10.1177/09622802231181471>. |
Authors: | Lingfeng Luo [aut, cre], Wenbo Wu [aut], Kevin He [aut] |
Maintainer: | Lingfeng Luo <[email protected]> |
License: | GPL-3 |
Version: | 1.0.0 |
Built: | 2024-11-10 06:23:30 UTC |
Source: | CRAN |
coxtv
or coxtp
objectThe baseline estimation is the baseline hazard at each observed failure time when holding all the covariates to be zero.
baseline(fit)
baseline(fit)
fit |
model from |
A list with three components:
time |
the unique observed failure times. |
hazard |
the baseline hazard corresponding to each unique failure time point. |
cumulHaz |
the cumulative baseline hazard corresponding to each unique failure time point. |
data(ExampleData) z <- ExampleData$z time <- ExampleData$time event <- ExampleData$event fit <- coxtv(event = event, z = z, time = time) base.est <- baseline(fit)
data(ExampleData) z <- ExampleData$z time <- ExampleData$time event <- ExampleData$event fit <- coxtv(event = event, z = z, time = time) base.est <- baseline(fit)
Get confidence intervals of time-varying coefficients from a fitted coxtv
or coxtp
object.
## S3 method for class 'coxtp' confint(object, parm, level = 0.95, time, ...) ## S3 method for class 'coxtv' confint(object, parm, level = 0.95, time, ...)
## S3 method for class 'coxtp' confint(object, parm, level = 0.95, time, ...) ## S3 method for class 'coxtv' confint(object, parm, level = 0.95, time, ...)
object |
fitted |
parm |
the names of parameters. |
level |
the confidence level. The default value is 0.95. |
time |
the time points for which the confidence intervals to be estimated. The default value is the unique observed event times in the dataset fitting the time-varying effects model. |
... |
other parameters to function |
A list where each element corresponds to one of the parameters specified in parm
. Each element in the
list is a matrix, with rows corresponding to the specified time
points and three columns representing the
estimated values of the parameter, and the lower and upper bounds of the confidence interval at the specified
confidence level
. The length of the list is determined by the number of parameters in parm
, and each matrix
has rows equal to the number of specified time
points.
A list where each element corresponds to one of the parameters specified in parm
. Each element in the
list is a matrix, with rows corresponding to the specified time
points and three columns representing the
estimated values of the parameter, and the lower and upper bounds of the confidence interval at the specified
confidence level
. The length of the list is determined by the number of parameters in parm
, and each matrix
has rows equal to the number of specified time
points.
data(ExampleData) z <- ExampleData$z time <- ExampleData$time event <- ExampleData$event fit <- coxtp(event = event, z = z, time = time) IC <- IC(fit) confint(IC$model.mAIC) data(ExampleData) z <- ExampleData$z time <- ExampleData$time event <- ExampleData$event fit <- coxtv(event = event, z = z, time = time) confint <- confint(fit)
data(ExampleData) z <- ExampleData$z time <- ExampleData$time event <- ExampleData$event fit <- coxtp(event = event, z = z, time = time) IC <- IC(fit) confint(IC$model.mAIC) data(ExampleData) z <- ExampleData$z time <- ExampleData$time event <- ExampleData$event fit <- coxtv(event = event, z = z, time = time) confint <- confint(fit)
Fit a Cox non-proportional hazards model via penalized maximum likelihood.
coxtp( event, z, time, strata = NULL, penalty = "Smooth-spline", nsplines = 8, lambda = c(0.1, 1, 10), degree = 3L, knots = NULL, ties = "Breslow", tol = 1e-06, iter.max = 20L, method = "ProxN", gamma = 1e+08, btr = "dynamic", tau = 0.5, stop = "ratch", parallel = FALSE, threads = 2L, fixedstep = FALSE )
coxtp( event, z, time, strata = NULL, penalty = "Smooth-spline", nsplines = 8, lambda = c(0.1, 1, 10), degree = 3L, knots = NULL, ties = "Breslow", tol = 1e-06, iter.max = 20L, method = "ProxN", gamma = 1e+08, btr = "dynamic", tau = 0.5, stop = "ratch", parallel = FALSE, threads = 2L, fixedstep = FALSE )
event |
failure event response variable of length |
z |
input covariate matrix, with |
time |
observed event times, which should be a vector with non-negative values. |
strata |
a vector of indicators for stratification.
Default = |
penalty |
a character string specifying the spline term for the penalized Newton method.
This term is added to the log-partial likelihood, and the penalized log-partial likelihood serves as the new objective function to
control the smoothness of the time-varying coefficients.
Default is
If |
nsplines |
number of basis functions in the splines to span the time-varying effects. The default value is 8.
We use the R function |
lambda |
a user-specified |
degree |
degree of the piecewise polynomial for generating the B-spline basis functions—default is 3 for cubic splines.
If the If the |
knots |
the internal knot locations (breakpoints) that define the B-splines.
The number of the internal knots should be |
ties |
a character string specifying the method for tie handling. If there are no tied events,
the methods are equivalent.
By default |
tol |
tolerance used for stopping the algorithm. See details in |
iter.max |
maximum iteration number if the stopping criterion specified by |
method |
a character string specifying whether to use Newton method or proximal Newton method. If |
gamma |
parameter for proximal Newton method |
btr |
a character string specifying the backtracking line-search approach. |
tau |
a positive scalar used to control the step size inside the backtracking line-search. The default value is 0.5. |
stop |
a character string specifying the stopping rule to determine convergence.
|
parallel |
if |
threads |
an integer indicating the number of threads to be used for parallel computation. The default value is |
fixedstep |
if |
The sequence of models implied by lambda.spline
is fit by the (proximal) Newton method.
The objective function is
where is a penalty matrix for
P-spline
or Smooth-spline
.
The is the tuning parameter (See details in
lambda
). Users can define the initial sequence.
The function IC
below provides different information criteria to choose the tuning parameter . Another function
cv.coxtp
uses the cross-validation to choose the tuning parameter.
A list of objects with S3 class "coxtp"
. The length is the same as that of lambda
; each represents the model output with each value of the tuning parameter lambda
.
call |
the call that produced this object. |
beta |
the estimated time-varying coefficient for each predictor at each unique time.
It is a matrix of dimension |
bases |
the basis matrix used in model fitting. If |
ctrl.pts |
estimated coefficient of the basis matrix of dimension |
Hessian |
the Hessian matrix of the log-partial likelihood, of which the dimension is |
internal.knots |
the internal knot locations (breakpoints) that define the B-splines. |
nobs |
number of observations. |
penalty |
the spline term |
theta.list |
the history of |
VarianceMatrix |
the variance matrix of the estimated coefficients of the basis matrix, which is the inverse of the negative Hessian matrix. |
Boyd, S., and Vandenberghe, L. (2004) Convex optimization.
Cambridge University Press.
Gray, R. J. (1992) Flexible methods for analyzing survival data using splines, with applications to breast cancer prognosis.
Journal of the American Statistical Association, 87(420): 942-951.
Gray, R. J. (1994) Spline-based tests in survival analysis.
Biometrics, 50(3): 640-652.
Luo, L., He, K., Wu, W., and Taylor, J. M. (2023) Using information criteria to select smoothing parameters when analyzing survival data with time-varying coefficient hazard models.
Statistical Methods in Medical Research, in press.
Perperoglou, A., le Cessie, S., and van Houwelingen, H. C. (2006) A fast routine for fitting Cox models with time varying effects of the covariates.
Computer Methods and Programs in Biomedicine, 81(2): 154-161.
Wu, W., Taylor, J. M., Brouwer, A. F., Luo, L., Kang, J., Jiang, H., and He, K. (2022) Scalable proximal methods for cause-specific hazard modeling with time-varying coefficients.
Lifetime Data Analysis, 28(2): 194-218.
Wood, S. N. (2017) P-splines with derivative based penalties and tensor product smoothing of unevenly distributed data.
Statistics and Computing, 27(4): 985-989.
IC
, cv.coxtp
plot
, get.tvcoef
and baseline
.
data(ExampleData) z <- ExampleData$z time <- ExampleData$time event <- ExampleData$event lambda = c(0,1) fit <- coxtp(event = event, z = z, time = time, lambda=lambda)
data(ExampleData) z <- ExampleData$z time <- ExampleData$time event <- ExampleData$event lambda = c(0,1) fit <- coxtp(event = event, z = z, time = time, lambda=lambda)
Fit a Cox non-proportional hazards model via maximum likelihood.
coxtv( event, z, time, strata = NULL, nsplines = 8, knots = NULL, degree = 3, ties = "Breslow", stop = "ratch", tol = 1e-06, iter.max = 20, method = "ProxN", gamma = 1e+08, btr = "dynamic", tau = 0.5, parallel = FALSE, threads = 2L, fixedstep = FALSE )
coxtv( event, z, time, strata = NULL, nsplines = 8, knots = NULL, degree = 3, ties = "Breslow", stop = "ratch", tol = 1e-06, iter.max = 20, method = "ProxN", gamma = 1e+08, btr = "dynamic", tau = 0.5, parallel = FALSE, threads = 2L, fixedstep = FALSE )
event |
failure event response variable of length |
z |
input covariate matrix, with |
time |
observed event times, which should be a vector with non-negative values. |
strata |
a vector of indicators for stratification.
Default = |
nsplines |
number of basis functions in the splines to span the time-varying effects. The default value is 8.
We use the R function |
knots |
the internal knot locations (breakpoints) that define the B-splines.
The number of the internal knots should be |
degree |
degree of the piecewise polynomial for generating the B-spline basis functions—default is 3 for cubic splines.
|
ties |
a character string specifying the method for tie handling. If there are no tied events,
the methods are equivalent.
By default |
stop |
a character string specifying the stopping rule to determine convergence.
|
tol |
tolerance used for stopping the algorithm. See details in |
iter.max |
maximum iteration number if the stopping criterion specified by |
method |
a character string specifying whether to use Newton method or proximal Newton method. If |
gamma |
parameter for proximal Newton method |
btr |
a character string specifying the backtracking line-search approach. |
tau |
a positive scalar used to control the step size inside the backtracking line-search. The default value is 0.5. |
parallel |
if |
threads |
an integer indicating the number of threads to be used for parallel computation. The default value is |
fixedstep |
if |
The model is fit by Newton method (proximal Newton method).
An object with S3 class coxtv
.
call |
the call that produced this object. |
beta |
the estimated time-varying coefficient for each predictor at each unique time.
It is a matrix of dimension |
bases |
the basis matrix used in model fitting. If |
ctrl.pts |
estimated coefficient of the basis matrix of dimension |
Hessian |
the Hessian matrix of the log-partial likelihood, of which the dimension is |
internal.knots |
the internal knot locations (breakpoints) that define the B-splines. |
nobs |
number of observations. |
theta.list |
the history of |
VarianceMatrix |
the variance matrix of the estimated coefficients of the basis matrix, which is the inverse of the negative Hessian matrix. |
Boyd, S., and Vandenberghe, L. (2004) Convex optimization.
Cambridge University Press.
Gray, R. J. (1992) Flexible methods for analyzing survival data using splines, with applications to breast cancer prognosis.
Journal of the American Statistical Association, 87(420): 942-951.
Gray, R. J. (1994) Spline-based tests in survival analysis.
Biometrics, 50(3): 640-652.
Luo, L., He, K., Wu, W., and Taylor, J. M. (2023) Using information criteria to select smoothing parameters when analyzing survival data with time-varying coefficient hazard models.
Perperoglou, A., le Cessie, S., and van Houwelingen, H. C. (2006) A fast routine for fitting Cox models with time varying effects of the covariates.
Computer Methods and Programs in Biomedicine, 81(2): 154-161.
Wu, W., Taylor, J. M., Brouwer, A. F., Luo, L., Kang, J., Jiang, H., and He, K. (2022) Scalable proximal methods for cause-specific hazard modeling with time-varying coefficients.
Lifetime Data Analysis, 28(2): 194-218.
coef
, plot
, and the coxtp
function.
data(ExampleData) z <- ExampleData$z time <- ExampleData$time event <- ExampleData$event fit <- coxtv(event = event, z = z, time = time)
data(ExampleData) z <- ExampleData$z time <- ExampleData$time event <- ExampleData$event fit <- coxtv(event = event, z = z, time = time)
Fit a Cox non-proportional hazards model via penalized maximum likelihood. The penalization tuning parameter is provided by cross-validation.
cv.coxtp( event, z, time, strata = NULL, lambda = c(0.1, 1, 10), nfolds = 5, foldid = NULL, knots = NULL, penalty = "Smooth-spline", nsplines = 8, ties = "Breslow", tol = 1e-06, iter.max = 20L, method = "ProxN", gamma = 1e+08, btr = "dynamic", tau = 0.5, stop = "ratch", parallel = FALSE, threads = 1L, degree = 3L, fixedstep = FALSE )
cv.coxtp( event, z, time, strata = NULL, lambda = c(0.1, 1, 10), nfolds = 5, foldid = NULL, knots = NULL, penalty = "Smooth-spline", nsplines = 8, ties = "Breslow", tol = 1e-06, iter.max = 20L, method = "ProxN", gamma = 1e+08, btr = "dynamic", tau = 0.5, stop = "ratch", parallel = FALSE, threads = 1L, degree = 3L, fixedstep = FALSE )
event |
failure event response variable of length |
z |
input covariate matrix, with |
time |
observed event times, which should be a vector with non-negative values. |
strata |
a vector of indicators for stratification.
Default = |
lambda |
a user specified sequence as the penalization coefficients in front of the spline term specified by |
nfolds |
number of folds for cross-validation, the default value is 5. The smallest value allowable is |
foldid |
an optional vector of values between 1 and |
knots |
the internal knot locations (breakpoints) that define the B-splines.
The number of the internal knots should be |
penalty |
a character string specifying the spline term for the penalized Newton method.
This term is added to the log-partial likelihood, and the penalized log-partial likelihood serves as the new objective function to
control the smoothness of the time-varying coefficients.
Default is
If |
nsplines |
number of basis functions in the splines to span the time-varying effects. The default value is 8.
We use the R function |
ties |
a character string specifying the method for tie handling. If there are no tied events,
the methods are equivalent.
By default |
tol |
tolerance used for stopping the algorithm. See details in |
iter.max |
maximum iteration number if the stopping criterion specified by |
method |
a character string specifying whether to use Newton method or proximal Newton method. If |
gamma |
parameter for proximal Newton method |
btr |
a character string specifying the backtracking line-search approach. |
tau |
a positive scalar used to control the step size inside the backtracking line-search. The default value is |
stop |
a character string specifying the stopping rule to determine convergence.
|
parallel |
if |
threads |
an integer indicating the number of threads to be used for parallel computation. The default value is |
degree |
degree of the piecewise polynomial for generating the B-spline basis functions—default is 3 for cubic splines.
If If |
fixedstep |
if |
The function runs coxtp
length of lambda
by nfolds
times; each is to compute the fit with each of the folds omitted.
An object of class "cv.coxtp"
is returned, which is a list with the ingredients of the cross-validation fit.
model.cv |
a |
lambda |
the values of |
cve |
the mean cross-validated error - a vector having the same length as lambda.
For the k-th testing fold (k = 1, ..., |
lambda.min |
the value of |
Boyd, S., and Vandenberghe, L. (2004) Convex optimization.
Cambridge University Press.
Gray, R. J. (1992) Flexible methods for analyzing survival data using splines, with applications to breast cancer prognosis.
Journal of the American Statistical Association, 87(420): 942-951.
Gray, R. J. (1994) Spline-based tests in survival analysis.
Biometrics, 50(3): 640-652.
Luo, L., He, K., Wu, W., and Taylor, J. M. (2023) Using information criteria to select smoothing parameters when analyzing survival data with time-varying coefficient hazard models.
Statistical Methods in Medical Research, in press.
Perperoglou, A., le Cessie, S., and van Houwelingen, H. C. (2006) A fast routine for fitting Cox models with time varying effects of the covariates.
Computer Methods and Programs in Biomedicine, 81(2): 154-161.
Verweij, P. J., and Van Houwelingen, H. C. (1993) Cross‐validation in survival analysis.
Statistics in Medicine, 12(24): 2305-2314.
Wu, W., Taylor, J. M., Brouwer, A. F., Luo, L., Kang, J., Jiang, H., and He, K. (2022) Scalable proximal methods for cause-specific hazard modeling with time-varying coefficients.
Lifetime Data Analysis, 28(2): 194-218.
Wood, S. N. (2017) P-splines with derivative based penalties and tensor product smoothing of unevenly distributed data.
Statistics and Computing, 27(4): 985-989.
data(ExampleData) z <- ExampleData$z time <- ExampleData$time event <- ExampleData$event lambda = c(0.1, 1) fit <- cv.coxtp(event = event, z = z, time = time, lambda=lambda, nfolds = 5)
data(ExampleData) z <- ExampleData$z time <- ExampleData$time event <- ExampleData$event lambda = c(0.1, 1) fit <- cv.coxtp(event = event, z = z, time = time, lambda=lambda, nfolds = 5)
A simulated data set containing 2 continuous variables.
data(ExampleData)
data(ExampleData)
A list containing the following elements:
simulated continuous covariates V1 and V2, with a time-independent coefficient
and a time-varying coefficient
simulated failure event response; binary variable with 0 or 1.
simulated observed event times; continuous variable with non-negative values.
A simulated data set containing 2 binary variables.
data(ExampleDataBinary)
data(ExampleDataBinary)
A list containing the following elements:
simulated binary covariates V1 and V2, with a time-independent coefficient
and a time-varying coefficient
simulated failure event response; binary variable with 0 or 1.
simulated observed event times; continuous variable with non-negative values.
The function gives the time-varying coefficients based on a fitted coxtv
or coxtp
subject.
Users can specify the time points to calculate the time-varying coefficients.
get.tvcoef(fit, time)
get.tvcoef(fit, time)
fit |
model from |
time |
time points to calculate the time-varying coefficients. If |
A matrix of the time-varying coefficients. The dimension is the length of time
by nvars
, where nvars
is the number
of covariates in the fitted mode.
Each row represents the time-varying coefficients at the corresponding time.
z <- ExampleData$z time <- ExampleData$time event <- ExampleData$event fit <- coxtv(event = event, z = z, time = time, degree = 2) coef <- get.tvcoef(fit)
z <- ExampleData$z time <- ExampleData$time event <- ExampleData$event fit <- coxtv(event = event, z = z, time = time, degree = 2) coef <- get.tvcoef(fit)
coxtp
objectThis function is to calculate information criteria from a coxtp
object to select the penalization tuning parameter.
IC(fit, IC.prox)
IC(fit, IC.prox)
fit |
model from |
IC.prox |
when calculating information criteria, there might be numerical issues (e.g. the Hessian matrix is close to be singular).
In such cases, warnings will be given.
If |
In order to select the proper smoothing parameter, we utilize the idea of information criteria.
We provide four different information criteria to select the optimal smoothing parameter .
Generally, mAIC, TIC and GIC select similar parameters and the difference of resulting estimates are barely noticeable.
See details in the Luo et al. (2023).
model.mAIC |
an object with S3 class |
model.TIC |
an object with S3 class |
model.GIC |
an object with S3 class |
mAIC |
a sequence of mAIC values corresponding to each of the tuning parameter |
TIC |
a sequence of TIC values corresponding to each of the tuning parameter |
GIC |
a sequence of GIC values corresponding to each of the tuning parameter |
Akaike, H. (1998) Information theory and an extension of the maximum likelihood principle.
In Selected Papers of Hirotugu Akaike. 199–213.
Luo, L., He, K., Wu, W., and Taylor, J. M. (2023) Using information criteria to select smoothing parameters when analyzing survival data with time-varying coefficient hazard models.
Statistical Methods in Medical Research, in press.
Takeuchi, K. (1976) Distribution of information statistics and criteria for adequacy of models.
Mathematical Sciences, 153: 12–18.
Wu, W., Taylor, J. M., Brouwer, A. F., Luo, L., Kang, J., Jiang, H., and He, K. (2022) Scalable proximal methods for cause-specific hazard modeling with time-varying coefficients.
Lifetime Data Analysis, 28(2): 194-218.
data(ExampleData) z <- ExampleData$z time <- ExampleData$time event <- ExampleData$event fit <- coxtp(event = event, z = z, time = time) IC <- IC(fit)
data(ExampleData) z <- ExampleData$z time <- ExampleData$time event <- ExampleData$event fit <- coxtp(event = event, z = z, time = time) IC <- IC(fit)
Plotting the baseline hazard from a fitted baseline
object.
## S3 method for class 'baseline' plot(x, xlab, ylab, xlim, ylim, title, ...)
## S3 method for class 'baseline' plot(x, xlab, ylab, xlim, ylim, title, ...)
x |
fitted object from |
xlab |
the title for the x axis. |
ylab |
the title for the y axis. |
xlim |
the limits of the x axis. |
ylim |
the limits of the y axis. |
title |
the title for the plot. |
... |
other graphical parameters to plot |
A plot is produced, and nothing is returned.
data(ExampleData) z <- ExampleData$z time <- ExampleData$time event <- ExampleData$event fit <- coxtv(event = event, z = z, time = time) base.est <- baseline(fit) plot(base.est)
data(ExampleData) z <- ExampleData$z time <- ExampleData$time event <- ExampleData$event fit <- coxtv(event = event, z = z, time = time) base.est <- baseline(fit) plot(base.est)
coxtp
objectThis function creates a plot of the time-varying coefficients from a fitted coxtp
model.
## S3 method for class 'coxtp' plot( x, parm, CI = TRUE, level = 0.95, exponentiate = FALSE, xlab, ylab, xlim, ylim, allinone = FALSE, title, linetype, color, fill, time, ... )
## S3 method for class 'coxtp' plot( x, parm, CI = TRUE, level = 0.95, exponentiate = FALSE, xlab, ylab, xlim, ylim, allinone = FALSE, title, linetype, color, fill, time, ... )
x |
model obtained from |
parm |
covariate names fitted in the model to be plotted. If |
CI |
if |
level |
the level of confidence intervals. The default value is |
exponentiate |
if |
xlab |
the title for the x axis. |
ylab |
the title for the y axis. |
xlim |
the limits for the x axis. |
ylim |
the limits for the y axis. |
allinone |
if |
title |
the title for the plot. |
linetype |
the line type for the plot. |
color |
the aesthetics parameter for the plot. |
fill |
the aesthetics parameter for the plot. |
time |
the time points for which the time-varying coefficients to be plotted. The default value is the unique observed event times in the dataset fitting the time-varying effects model. |
... |
other graphical parameters to plot |
A plot is produced, and nothing is returned.
data(ExampleData) z <- ExampleData$z time <- ExampleData$time event <- ExampleData$event fit <- coxtp(event = event, z = z, time = time) plot(fit$lambda1)
data(ExampleData) z <- ExampleData$z time <- ExampleData$time event <- ExampleData$event fit <- coxtp(event = event, z = z, time = time) plot(fit$lambda1)
coxtv
objectThis function creates a plot of the time-varying coefficients from a fitted coxtv
model.
## S3 method for class 'coxtv' plot( x, parm, CI = TRUE, level = 0.95, exponentiate = FALSE, xlab, ylab, xlim, ylim, allinone = FALSE, title, linetype, color, fill, time, ... )
## S3 method for class 'coxtv' plot( x, parm, CI = TRUE, level = 0.95, exponentiate = FALSE, xlab, ylab, xlim, ylim, allinone = FALSE, title, linetype, color, fill, time, ... )
x |
model obtained from |
parm |
covariate names fitted in the model to be plotted. If |
CI |
if |
level |
the level of confidence intervals. The default value is |
exponentiate |
if |
xlab |
the title for the x axis. |
ylab |
the title for the y axis. |
xlim |
the limits for the x axis. |
ylim |
the limits for the y axis. |
allinone |
if |
title |
the title for the plot. |
linetype |
the line type for the plot. |
color |
the aesthetics parameter for the plot. |
fill |
the aesthetics parameter for the plot. |
time |
the time points for which the time-varying coefficients to be plotted. The default value is the unique observed event times in the dataset fitting the time-varying effects model. |
... |
other graphical parameters to plot |
A plot is produced, and nothing is returned.
data(ExampleData) z <- ExampleData$z time <- ExampleData$time event <- ExampleData$event fit <- coxtv(event = event, z = z, time = time) plot(fit)
data(ExampleData) z <- ExampleData$z time <- ExampleData$time event <- ExampleData$event fit <- coxtv(event = event, z = z, time = time) plot(fit)
A simulated data set containing 2 binary variables from 10 distinct stratums.
data(StrataExample)
data(StrataExample)
A list containing the following elements:
simulated binary covariates V1 and V2, with a time-independent coefficient
and a time-varying coefficient
simulated failure event response; binary variable with 0 or 1.
simulated observed event times; continuous variable with non-negative values.
simulated strata variable; patients in different stratums have different baseline hazards.
The SUPPORT dataset tracks five response variables: hospital death, severe functional disability, hospital costs, and time until death and death itself. The patients are followed for up to 5.56 years. See Bhatnagar et al. (2020) for details.
data(support)
data(support)
A data frame with 9,104 observations and 34 variables after imputation and the removal of response variables like hospital charges, patient ratio of costs to charges and micro-costs following Bhatnagar et al. (2020). Ordinal variables, namely functional disability and income, were also removed. Finally, Surrogate activities of daily living were removed due to sparsity. There were 6 other model scores in the data-set and they were removed; only aps and sps were kept.
stores a double representing age.
death at any time up to NDI (National Death Index) date: 12/31/1994.
0=female, 1=male.
days from study entry to discharge.
days of follow-up.
each level of dzgroup: ARF/MOSF w/Sepsis, COPD, CHF, Cirrhosis, Coma, Colon Cancer, Lung Cancer, MOSF with malignancy.
ARF/MOSF, COPD/CHF/Cirrhosis, Coma and cancer disease classes.
the number of comorbidities.
years of education of patients.
the SUPPORT coma score based on Glasgow D3.
average TISS, days 3-25.
indicates race: White, Black, Asian, Hispanic or other.
day in Hospital at Study Admit.
diabetes (Com27-28, Dx 73).
dementia (Comorbidity 6).
cancer state.
mean arterial blood pressure day 3.
white blood cell count on day 3.
heart rate day 3.
respiration rate day 3.
temperature, in Celsius, on day 3.
PaO2/(0.01*FiO2) day 3.
serum albumin day 3.
bilirubin day 3.
serum creatinine day 3.
serum sodium day 3.
serum pH (in arteries) day 3.
serum glucose day 3.
bun day 3.
urine output day 3.
adl patient day 3.
imputed adl calibrated to surrogate, if a surrogate was used for a follow up.
SUPPORT physiology score.
apache III physiology score.
Some of the original data was missing. Before imputation, there were
a total of 9,104 individuals and 47 variables. Following Bhatnagar et al. (2020), a few variables
were removed. Three response variables were removed:
hospital charges, patient ratio of costs to charges and patient
micro-costs. Hospital death was also removed as it was directly informative
of the event of interest, namely death. Additionally, functional disability and
income were removed as they are ordinal covariates. Finally, 8
covariates were removed related to the results of previous findings: SUPPORT
day 3 physiology score (sps
), APACHE III day 3 physiology score
(aps
), SUPPORT model 2-month survival estimate, SUPPORT model
6-month survival estimate, Physician's 2-month survival estimate for pt.,
Physician's 6-month survival estimate for pt., Patient had Do Not
Resuscitate (DNR) order, and Day of DNR order (<0 if before study). Of
these, sps
and aps
were added on after imputation, as they
were missing only 1 observation. First the imputation is done manually using the normal
values for physiological measures recommended by Knaus et al. (1995). Next,
a single dataset was imputed using mice with default settings. After
imputation, the covariate for surrogate activities of daily
living was not imputed. This is due to collinearity between the other two
covariates for activities of daily living. Therefore, surrogate activities
of daily living were removed. See details in the R package (casebase) by Bhatnagar et al. (2020).
Available at the following website: https://biostat.app.vumc.org/wiki/Main/SupportDesc.
Bhatnagar, S., Turgeon, M., Islam, J., Hanley, J. A., and Saarela, O. (2020) casebase: Fitting Flexible Smooth-in-Time Hazards and Risk Functions via Logistic and Multinomial Regression. R package version 0.9.0, https://CRAN.R-project.org/package=casebase.
Knaus, W. A., Harrell, F. E., Lynn, J., Goldman, L., Phillips, R. S., Connors, A. F., et al. (1995)
The SUPPORT prognostic model: Objective estimates of survival for seriously ill hospitalized adults.
Annals of Internal Medicine, 122(3): 191-203.
data(support) support <- support[support$ca %in% c("metastatic"),] time <- support$d.time death <- support$death diabetes <- model.matrix(~factor(support$diabetes))[,-1] #sex: female as the reference group sex <- model.matrix(~support$sex)[,-1] #age: continuous variable age <-support$age age[support$age<=50] <- "<50" age[support$age>50 & support$age<=60] <- "50-59" age[support$age>60 & support$age<70] <- "60-69" age[support$age>=70] <- "70+" age <- factor(age, levels = c("60-69", "<50", "50-59", "70+")) z_age <- model.matrix(~age)[,-1] z <- data.frame(z_age, sex, diabetes) colnames(z) <- c("age_50", "age_50_59", "age_70", "diabetes", "male") data <- data.frame(time, death, z) fit.coxtv <- coxtv(event = death, z = z, time = time)
data(support) support <- support[support$ca %in% c("metastatic"),] time <- support$d.time death <- support$death diabetes <- model.matrix(~factor(support$diabetes))[,-1] #sex: female as the reference group sex <- model.matrix(~support$sex)[,-1] #age: continuous variable age <-support$age age[support$age<=50] <- "<50" age[support$age>50 & support$age<=60] <- "50-59" age[support$age>60 & support$age<70] <- "60-69" age[support$age>=70] <- "70+" age <- factor(age, levels = c("60-69", "<50", "50-59", "70+")) z_age <- model.matrix(~age)[,-1] z <- data.frame(z_age, sex, diabetes) colnames(z) <- c("age_50", "age_50_59", "age_70", "diabetes", "male") data <- data.frame(time, death, z) fit.coxtv <- coxtv(event = death, z = z, time = time)
coxtv
or coxtp
objectTesting the proportional hazards assumption using a Wald test statistic.
tvef.ph(fit, parm)
tvef.ph(fit, parm)
fit |
fitted |
parm |
the names of parameters to be tested. |
tvef.ph
produces a matrix. Each row corresponds to a covariate from the fitted object. The three
columns give the test statistic, degrees of freedom and P-value.
data(ExampleData) z <- ExampleData$z time <- ExampleData$time event <- ExampleData$event fit <- coxtv(event = event, z = z, time = time) tvef.ph(fit)
data(ExampleData) z <- ExampleData$z time <- ExampleData$time event <- ExampleData$event fit <- coxtv(event = event, z = z, time = time) tvef.ph(fit)
coxtv
or coxtp
objectTesting the significance of the covariates from a coxtv
or coxtp
object using a Wald test statistic.
The null hypothesis for any
, where
denotes the event time.
tvef.zero(fit, parm)
tvef.zero(fit, parm)
fit |
fitted |
parm |
the names of parameters to be tested. |
tvef.zero
produces a matrix. Each row corresponds to a covariate from the fitted object. The three
columns give the test statistic, degrees of freedom and P-value.
data(ExampleData) z <- ExampleData$z time <- ExampleData$time event <- ExampleData$event fit <- coxtv(event = event, z = z, time = time) tvef.ph(fit)
data(ExampleData) z <- ExampleData$z time <- ExampleData$time event <- ExampleData$event fit <- coxtv(event = event, z = z, time = time) tvef.ph(fit)
coxtv
or coxtp
object using a Wald test statisticTesting the significance of the covariates at each time point.
tvef.zero.time(fit, time, parm)
tvef.zero.time(fit, time, parm)
fit |
fitted |
time |
the time points to test if the covariate is significant or not. |
parm |
the names of parameters to be tested. |
tvef.zero.time
produces a list of length nvars
. Each element of the list is a matrix with respect to a
covariate. The matrix is of dimension len_unique_t
by 4, where len_unique_t
is the length of unique observed event time.
Each row corresponds to the testing result at that time. The four
columns give the estimations, standard error, test-statistic and P-value.
data(ExampleData) z <- ExampleData$z time <- ExampleData$time event <- ExampleData$event fit <- coxtv(event = event, z = z, time = time) test <- tvef.zero.time(fit)
data(ExampleData) z <- ExampleData$z time <- ExampleData$time event <- ExampleData$event fit <- coxtv(event = event, z = z, time = time) test <- tvef.zero.time(fit)