Generate left-truncated (and right-cencored) data from the Cox model.

Share:

Description

Various baseline survival functions and truncation distribution are available. Censoring rate can be designated through tuning the parameter Cmax; Cmas = Inf means no censoring.

Usage

1
2
3
4
sim.ltrc(n = 200, b = c(1, 1), time.dep = FALSE, Zv.depA = FALSE,
  distr.T = "weibull", shape.T = 2, scale.T = 1, meanlog.T = 0,
  sdlog.T = 1, distr.A = "weibull", shape.A = 1, scale.A = 5,
  p.A = 0.3, Cmax = Inf, fix.seed = NULL)

Arguments

n

the sample size.

b

a numeric vector for true regression coefficients.

time.dep

logical, whether there is the time-dependent covariate (only one indicator function Zv = I(t >= zeta) is supported); the default is FALSE.

Zv.depA

logical, whether the time-dependent covariate Zv depends on A^* (the only form supported is Zv = I(t >= zeta + A^*)); the default is FALSE.

distr.T

the baseline survival time (T*) distribution ("exp" or "weibull").

shape.T

the shape parameter for the Weibull distribution of T*.

scale.T

the scale parameter for the Weibull distributiof of T*.

meanlog.T

the mean for the log-normal distribution of T*.

sdlog.T

the sd for the log-normal distribution of T*.

distr.A

the baseline truncation time (A*) distribution: either of "weibull" (the default), "unif" (Length-Biased Sampling), "binomial" or "dunif"). Note: If distribution name other than these are provided, "unif" will be used.

shape.A

the shape parameter for the Weibull distribution of A*.

scale.A

the scale parameter for the Weibull distribution of A*.

p.A

the success probability for the binomial distribution of A*.

Cmax

the upper bound of the uniform distribution of the censoring time (C).

fix.seed

an optional random seed for simulation.

Value

a list with a data.frame containing the observed survival times (Ys), the observed truncation times (As), the event indicator (Ds) and the covariates (Zs); a vector of certain quantiles of Ys (taus); the censoring proportion (PC) and the truncation proportiona (PT).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# With time-invariant covariates only
sim1 = sim.ltrc(n = 100)
head(sim1$dat)
# With one time-dependent covariate
sim2 = sim.ltrc(n = 100, time.dep = TRUE,
         distr.A = "binomial", p.A = 0.8, Cmax = 5)
head(sim2$dat)
# With one time-dependent covariate with dependence on the truncation time
sim3 = sim.ltrc(n = 100, time.dep = TRUE, Zv.depA = TRUE, Cmax = 5)
head(sim3$dat)