kyotil (version 2016.11-9)

sim.dat.tvarying.two: Simulation Functions for Time-dependent Proportional Hazard Model

Description

sim.dat.tvarying.three simulates from a model with time varing age group variale of three levels, sim.dat.tvarying.two two.

Usage

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)

Arguments

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.

Value

Return a data frame with the following columns:

Details

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.

See Also

make.timedep.dataset

Examples

Run this code

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







Run the code above in your browser using DataLab