View source: R/user_utilities.R
survCIs | R Documentation |
Confidence/Credible intervals for survival curves
survCIs(
fit,
newdata = NULL,
p = NULL,
q = NULL,
ci_level = 0.95,
MC_samps = 4000
)
fit |
Fitted model from |
newdata |
|
p |
Percentiles of distribution to sample |
q |
Times of disitribution to sample. Only p OR q should be specified, not p AND q |
ci_level |
Confidence/credible level |
MC_samps |
Number of Monte Carlo samples taken |
Creates a set of confidence intervals for the survival curves conditional
on the covariates provided in newdata
. Several rows can be provided in newdata;
this will lead to several sets of confidence/credible intervals.
For Bayesian models, these are draws directly from the posterior; a set of parameters drawn
from those saved in fit$samples
repeatedly and then for each set of parameters,
the given set of quantiles is calculated. For parametric models, the procedure is virtually the
same, but rather than randomly drawing rows from saved samples, random samples are drawn using
the asymptotic normal approximation of the estimator.
This function is not compatible with ic_np
or ic_sp
objects, as the distribution
of the baseline distribution of these estimators is still an open question.
Clifford Anderson-Bergman
data("IR_diabetes")
fit <- ic_par(cbind(left, right) ~ gender,
data = IR_diabetes)
# Getting confidence intervals for survival curves
# for males and females
newdata <- data.frame(gender = c("male", "female"))
rownames(newdata) <- c("Males", "Females")
diab_cis <- survCIs(fit, newdata)
diab_cis
# Can add this to any plot
plot(fit, newdata = newdata,
cis = FALSE)
# Would have been included by default
lines(diab_cis, col = c("black", "red"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.