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
- data
data frame containing the covariates used to generate the survival times.
- ...
further arguments passed to other methods.
Examples
# \donttest{
library(rsurv)
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.42914737, 0.12210341, -1.13801240, -0.55801513, 1.05253854, 0…
#> $ sex <chr> "f", "m", "f", "f", "f", "f", "m", "m", "f", "f", "f", "m", "m"…
#> $ t <dbl> 1.51199820, 10.19038185, 0.35253307, 0.55724079, 1.05991019, 3.…
#> $ c <dbl> 0.9808380, 6.1171378, 7.9466706, 2.9383137, 9.9868554, 5.603129…
#> $ time <dbl> 0.98083797, 6.11713781, 0.35253307, 0.55724079, 1.05991019, 3.0…
#> $ status <dbl> 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, …
# }