Function to generate a random sample of survival data from accelerated hazard 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 = rahreg(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.07957744, -0.37283157, 1.29217027, 0.24680683, -1.71876166, …
#> $ sex <chr> "m", "f", "m", "m", "m", "f", "m", "f", "m", "f", "m", "m", "m"…
#> $ t <dbl> 4.7724909, 0.3177694, 4.2323675, 3.1660868, 0.4123813, 0.161969…
#> $ c <dbl> 6.3434063, 7.7024087, 9.1999357, 9.7401338, 6.3918558, 6.085308…
#> $ time <dbl> 4.7724909, 0.3177694, 4.2323675, 3.1660868, 0.4123813, 0.161969…
#> $ status <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, …