rahreg {rsurv} | R Documentation |
Random generation from accelerated hazard models
Description
Function to generate a random sample of survival data from accelerated hazard models.
Usage
rahreg(u, formula, baseline, beta, dist = NULL, data, ...)
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. |
Value
a numeric vector containing the generated random sample.
Examples
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)
[Package rsurv version 0.0.1 Index]