sim.ltrc: Generate left-truncated (and right-cencored) data from the...

View source: R/data.gen.R

sim.ltrcR Documentation

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

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

sim.ltrc(
  n = 200,
  b = c(1, 1),
  Z.type = c("C", "B"),
  time.dep = FALSE,
  Zv.depA = FALSE,
  A.depZ = 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,
  b.A = c(0, 0),
  Cmax = Inf,
  fix.seed = NULL
)

Arguments

n

the sample size.

b

a numeric vector for true regression coefficients.

Z.type

a vector indicating the type of the time-invariant covariates; "C" = uniform[-1, 1], "B" = binary(0.5).

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.

A.depZ

logical, whether the truncation times depends on the covariate Z.

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*.

b.A

the vector of coefficients for the model of A on the covariates.

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 biased sample of survival times (Ys) and 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 proportion (PT).

Examples

# With time-invariant covariates only
sim1 = sim.ltrc(n = 40)
head(sim1$dat)
# With one time-dependent covariate
sim2 = sim.ltrc(n = 40, 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 = 40, time.dep = TRUE, Zv.depA = TRUE, Cmax = 5)
head(sim3$dat)

942kid/plac documentation built on July 20, 2023, 2:43 a.m.