View source: R/user_utilities.R
sampleSurv | R Documentation |
Samples fitted survival function
sampleSurv(fit, newdata = NULL, p = NULL, q = NULL, samples = 100)
fit |
Either an ic_bayes or ic_par fit |
newdata |
A data.frame with a single row of covariates |
p |
A set of survival probabilities to sample corresponding time for |
q |
A set of times to sample corresponding cumulative probability for |
samples |
Number of samples to draw |
For Bayesian models, draws samples from the survival distribution with a given set of covariates.
Does this by first drawing a set of parameters (both regression and baseline) from fit$samples
and then computing the quantiles of
the distribution (if p
is provided) or the CDF at q
.
If a ic_par
model is provided, the procedure is the same, but the sampled parameters are drawn using
the normal approximation.
Not compatible with ic_np
or ic_sp
objects.
Clifford Anderson-Bergman
data("IR_diabetes")
fit <- ic_par(cbind(left, right) ~ gender, data = IR_diabetes)
newdata <- data.frame(gender = "male")
time_samps <- sampleSurv(fit, newdata,
p = c(0.5, .9),
samples = 100)
# 100 samples of the median and 90th percentile for males
prob_samps <- sampleSurv(fit, newdata,
q = c(10, 20),
samples = 100)
# 100 samples of the cumulative probability at t = 10 and 20 for males
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.