Learn R Programming

dynsurv (version 0.4-7)

splineCox: Fit Spline Based Cox Model for Right Censored Survival Data

Description

Rearrange the rignt censored survival data in a counting process style. Model the time-varying coefficient function using B-splines. The fit is done by introducing pseudo time-dependent covariates and then calling function coxph in survival package.

Usage

splineCox(formula, data, control = list())

Value

An object of S3 class splineCox representing the fit.

Arguments

formula

A formula object, with the response on the left of a '~' operator, and the terms on the right. The response must be a survival object as returned by the Surv function.

data

A data.frame in which to interpret the variables named in the formula.

control

List of control options.

Details

The control argument is a list of components:

df:

degree of freedom for the B-splines, default 5;

knots:

interior knots point, default NULL. If NULL, the knots will be automatically choosen;

boundary:

lower and upper boundaries for the spline function, default NULL. If NULL, the minimun and maximun finite event time or censoring time will be specified.

References

Perperoglou, A., le Cessie, S., & 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.

See Also

coef.splineCox, plotCoef.

Examples

Run this code
if (FALSE) {
## Attach the veteran data from the survival package
mydata <- survival::veteran
mydata$celltype <- relevel(mydata$celltype, ref = "large")
myformula <- Surv(time, status) ~ karno + celltype

## Fit the time-varying transformation model
fit <- splineCox(myformula, mydata, control = list(df = 5))

## Plot the time-varying coefficient function between two time points
plotCoef(subset(coef(fit), Time > 15 & Time < 175), smooth = TRUE)
}

Run the code above in your browser using DataLab