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
- 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 = 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> 0.42059335, -0.27211044, 1.38681782, 0.69496293, -0.07927130, 0…
#> $ sex <chr> "m", "f", "m", "f", "f", "m", "f", "f", "m", "m", "m", "f", "m"…
#> $ t <dbl> 0.08382661, 0.29643560, 0.08421470, 0.73610150, 0.87807519, 0.3…
#> $ c <dbl> 8.5766709, 5.3722423, 7.8845829, 8.8639853, 9.2144244, 9.639779…
#> $ time <dbl> 0.08382661, 0.29643560, 0.08421470, 0.73610150, 0.87807519, 0.3…
#> $ status <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, …
# }