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

sim.dat.tvarying.twoR Documentation

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.

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.

Value

Return a data frame with the following columns:

ptid

subject identifier

trt

treatment indicator 0/1

for.non.tvarying.ana

Boolean, used to subset dataset for non-time dependent analysis

C

censoring time

baseline.age

age years at baseline

agegrp

a factor with levels [0,6) [6,12) [12,100)

baseline.agegrp

a factor with levels [0,6) [6,12) [12,100)

tstart

left bound of time interval

tstop

right bound of time interval

d

event indicator

X

followup time, in years

Author(s)

Youyi Fong

See Also

make.timedep.dataset

Examples


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








kyotil documentation built on Nov. 28, 2023, 1:09 a.m.