Function to generate a random sample of survival data from extended 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.
- phi
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 = rehreg(runif(n), ~ age+sex, beta = c(1, 2), phi = 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> 1.188388111, -1.453813786, 2.246822449, 0.693021578, 1.15871966…
#> $ sex <chr> "m", "m", "m", "m", "m", "m", "f", "f", "m", "m", "f", "m", "f"…
#> $ t <dbl> 1.58025732, 0.02470154, 1.59748849, 0.18823373, 1.48361679, 0.5…
#> $ c <dbl> 2.0501924, 6.1714454, 1.5651517, 7.0949758, 5.8532739, 6.077027…
#> $ time <dbl> 1.58025732, 0.02470154, 1.56515168, 0.18823373, 1.48361679, 0.5…
#> $ status <dbl> 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, …
# }