Function to generate a random sample of survival data from accelerated failure time models.
Arguments
- u
a numeric vector of quantiles.
- formula
formula specifying the linear predictors.
- baseline
the name of the baseline survival distribution.
- beta
vector of regression coefficients.
- dist
an alternative way to specify the baseline survival distribution.
- package
the name of the package where the assumed quantile function is implemented.
- data
data frame containing the covariates used to generate the survival times.
- ...
further arguments passed to other methods.
Examples
library(rsurv)
library(dplyr)
n <- 1000
simdata <- data.frame(
age = rnorm(n),
sex = sample(c("f", "m"), size = n, replace = TRUE)
) %>%
mutate(
t = raftreg(runif(n), ~ age+sex, beta = c(1, 2),
dist = "weibull", shape = 1.5, scale = 1),
c = runif(n, 0, 10)
) %>%
rowwise() %>%
mutate(
time = min(t, c),
status = as.numeric(time == t)
)
glimpse(simdata)
#> Rows: 1,000
#> Columns: 6
#> Rowwise:
#> $ age <dbl> 0.69639390, 1.60853414, 2.23836513, -1.11901717, 0.64653626, -0…
#> $ sex <chr> "m", "m", "f", "f", "m", "f", "m", "m", "f", "f", "m", "f", "f"…
#> $ t <dbl> 12.73057373, 19.08638479, 2.07901391, 0.24776016, 2.46264134, 0…
#> $ c <dbl> 7.2301897, 7.1553368, 1.5846726, 0.2583867, 0.2120974, 3.886833…
#> $ time <dbl> 7.23018967, 7.15533683, 1.58467257, 0.24776016, 0.21209739, 0.8…
#> $ status <dbl> 0, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 0, …