itsamp: Inverse Transform Sampling To Generate Time-to-event Data...

Description Usage Arguments Details Value See Also Examples

View source: R/itsamp.R

Description

Random survival times generation for the weibull or log-logistic distributions with parameters 'scale' and 'shape'.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
itsamp(
  n,
  beta = c(2, -1),
  event_scale = 10,
  censor_scale = 4,
  features = data.frame(x1 = rnorm(n, 0), x2 = rnorm(n, 0)),
  shape = 2,
  model = c("ph", "po", "aft"),
  dist = c("weibull", "llogis"),
  censor = TRUE
)

Arguments

n

integer; sample size

beta

vector of regression coefficients

event_scale, censor_scale

event and censoring scale parameters

features

matrix of features (columns)

shape

event and censoring distribution shape

model

either "ph" (default) or "aft" for weibull and "po" or "aft" for log-logistic distribution

dist

"weibull" or "llogis"

censor

logical; if 'TRUE', censoring is required, that is mean(status) > 0

Details

sim_surv returns weibull (log-logistic) randomly generated survival times. According to Collett (2003), the accelerated failure time model encompasses a wide variety of parametric models, including weibull and log-logistic models.

Value

data.frame of 'ncol(x) +2' columns in which the survival times are the response variable denoted by 'y', 'status' indicates failure (0 = failure) and the features are appended to the next columns.

See Also

spbp

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
rows <- 200

categorical <- rbinom(rows, size = 3, prob = .5)
x <- data.frame(numerical = rnorm(rows),
           cat0 = as.numeric(categorical == 0),
           cat1 = as.numeric(categorical == 1),
           cat2 = as.numeric(categorical == 2),
           cat3 = as.numeric(categorical == 3))

newdata <- itsamp(n = rows, beta = c(1, -2, .5, .1, 1),
  features = x, model = 'ph', dist = 'weibull')

spsurv documentation built on April 14, 2020, 7:20 p.m.