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

Description Usage Arguments Value Examples

View source: R/data.gen.R

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)

Example output

Loading required package: survival
  ID          Z1          Z2          As        Ys Ds
1  1 -0.05794994 -0.56067967 0.006594377 0.3064866  1
2  2  0.30908280  0.25700526 0.098915825 0.3230650  1
3  3  0.43945194  0.78265342 0.009320842 0.4018560  1
4  4  0.75368908  0.01336563 0.248157477 0.4830007  1
5  5 -0.29599876 -0.74500139 0.034513235 0.4882381  1
6  6  0.58151274 -0.61354078 0.471080856 0.4896087  1
  ID          Z      zeta As        Ys Ds
1  1  0.8134014 1.6565813  0 0.1810225  1
2  2 -0.3499317 0.1067943  0 0.3927399  0
3  3  0.4480640 0.6103944  0 0.4876157  1
4  4  0.2703624 0.8399184  0 0.5377882  1
5  5 -0.2978959 0.3697065  0 0.6244274  1
6  6  0.1667923 1.0629658  0 0.6847081  0
  ID          Z      zeta         As        Ys Ds
1  1 -0.2046990 0.2648195 0.05359751 0.2566111  1
2  2  0.4297351 1.9599245 0.17504437 0.2616451  1
3  3  0.2208840 1.3646486 0.28011206 0.2873246  1
4  4 -0.8071351 0.3428700 0.08941304 0.3497221  1
5  5  0.4088787 1.5734314 0.32444585 0.3612966  0
6  6 -0.7205251 2.8894430 0.01494935 0.3917046  1

plac documentation built on May 29, 2017, 1:43 p.m.