Function to generate a random sample of survival data from Yang and Prentice 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 short-term regression coefficients.
- phi
vector of long-term 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 = rypreg(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> -0.3194983, 0.6586742, -0.5764291, -0.1301443, 0.0477878, -0.52…
#> $ sex <chr> "m", "m", "m", "m", "f", "m", "f", "m", "f", "f", "m", "m", "m"…
#> $ t <dbl> 0.52929541, 0.26096194, 0.37880398, 0.53884157, 1.34703765, 0.2…
#> $ c <dbl> 1.3665020, 5.1078673, 2.7427878, 6.1235070, 9.3289321, 4.584463…
#> $ time <dbl> 0.52929541, 0.26096194, 0.37880398, 0.53884157, 1.34703765, 0.2…
#> $ status <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, …
# }