sim.dat.tvarying.two {kyotil} | R Documentation |
sim.dat.tvarying.three simulates from a model with time varing age group variale of three levels, sim.dat.tvarying.two two.
sim.dat.tvarying.three(n, followup.length, incidence.density, age.sim = c("tvaryinggroup", "baselinegroup", "continuous","bt"), random.censoring.rate = 0.05, seed) sim.dat.tvarying.two(n, followup.length, incidence.density, age.sim = c("tvaryinggroup", "baselinegroup", "continuous","bt"), random.censoring.rate = 0.05, seed)
n |
integer. Sample size. |
followup.length |
numeric. Length of followup, in years. |
incidence.density |
numeric. Incidence rate per year. |
age.sim |
string. Choose between one of three possibilities. tvaryinggroup: age group is time-varying covariate; baselinegroup: age group is a baseline covariate; continuous: age is a continuous covariate; bt: age group by treatment interaction uses baseline age group, while age group main effect uses time-dependent age group |
random.censoring.rate |
numeric. Amount of random censoring. |
seed |
integer. Random number generator seed. |
In sim.dat.tvarying.three, baseline age is uniformly distributed between 2.0 and 16.0, and divivded into three groups at 6 and 12. In sim.dat.tvarying.two, baseline age is uniformly distributed between 2.0 and 12.0, and divivded into two groups at 6.
Return a data frame with the following columns:
|
subject identifier |
|
treatment indicator 0/1 |
|
Boolean, used to subset dataset for non-time dependent analysis |
|
censoring time |
|
age years at baseline |
|
a factor with levels |
|
a factor with levels |
|
left bound of time interval |
|
right bound of time interval |
|
event indicator |
|
followup time, in years |
Youyi Fong
library(survival) dat=sim.dat.tvarying.three(n=6000,followup.length=3, incidence.density=0.05, age.sim="tvaryinggroup", seed=1) f.tvarying = Surv(tstart,tstop,d) ~ trt*agegrp f = Surv(X,d) ~ trt*baseline.agegrp fits=list() fits[["tvarying"]]=coxph(f.tvarying, dat) fits[["baseline"]]=coxph(f, subset(dat, for.non.tvarying.ana)) fits