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
- 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 = 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.11299534, -0.36876161, -1.81381842, -0.72799437, -0.32334346,…
#> $ sex <chr> "f", "f", "m", "m", "f", "f", "m", "m", "m", "m", "m", "m", "f"…
#> $ t <dbl> 0.55259448, 0.73865300, 0.42237942, 0.72524703, 0.48294275, 1.5…
#> $ c <dbl> 7.897474, 1.198410, 4.235852, 8.294588, 4.520126, 4.808883, 4.0…
#> $ time <dbl> 0.55259448, 0.73865300, 0.42237942, 0.72524703, 0.48294275, 1.5…
#> $ status <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, …
# }