Function to generate a random sample of survival data from proportional odds 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 = rporeg(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> -1.1422132, -0.9301405, 0.1053670, 0.2732270, -0.9740712, -0.82…
#> $ sex <chr> "f", "m", "m", "m", "m", "f", "f", "m", "f", "m", "f", "m", "m"…
#> $ t <dbl> 0.322956533, 0.731323342, 0.025335643, 0.007979669, 0.655896927…
#> $ c <dbl> 5.2751784, 2.7173149, 5.8006588, 0.1070868, 2.7210765, 5.108660…
#> $ time <dbl> 0.322956533, 0.731323342, 0.025335643, 0.007979669, 0.655896927…
#> $ status <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, …