View source: R/make.timedep.dataset.R
| make.timedep.dataset | R Documentation | 
Returns a data frame that is suitable for time-dependent covariate Cox model fit.
make.timedep.dataset(dat, X, d, baseline.ageyrs, t.1, t.2 = NULL)
dat | 
 data frame  | 
X | 
 string. Name of the followup time column in dat. Unit needs to be years.  | 
d | 
 string. Name of the followup time column in dat.  | 
baseline.ageyrs | 
 string. Name of the followup time column in dat.  | 
t.1 | 
 numerical. Cutoff for age group  | 
t.2 | 
 numerical. Second cutoff for age group  | 
The function assumes that the followup length is such that only one change of age group is possible.
Returns a data frame with the following columns added: tstart, tstop, .timedep.agegrp, .baseline.agegrp
tstart | 
 left bound of time interval  | 
tstop | 
 right bound of time interval  | 
.timedep.agegrp | 
 time-dependent age group  | 
.baseline.agegrp | 
 baseline age group  | 
Youyi Fong
Therneau, T. and Crowson, C. Using Time Dependent Covariates and Time Dependent Coefficients in the Cox Model. A vignette from the R package surival.
library(survival)
n=3000; followup.length=5; incidence.density=0.015; age.sim="continuous"
dat.0=sim.dat.tvarying.two(n, followup.length, incidence.density, age.sim, seed=1)
dat=subset(dat.0, for.non.tvarying.ana, select=c(ptid, X, d, baseline.age, trt))
dat.timedep = make.timedep.dataset (dat, "X", "d", "baseline.age", 6)
coxph(Surv(tstart,tstop,d) ~ trt*.timedep.agegrp, dat.timedep)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.