survCIs: Confidence/Credible intervals for survival curves

View source: R/user_utilities.R

survCIsR Documentation

Confidence/Credible intervals for survival curves

Description

Confidence/Credible intervals for survival curves

Usage

survCIs(
  fit,
  newdata = NULL,
  p = NULL,
  q = NULL,
  ci_level = 0.95,
  MC_samps = 4000
)

Arguments

fit

Fitted model from ic_par or ic_bayes

newdata

data.frame containing covariates for survival curves

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

Details

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.

Author(s)

Clifford Anderson-Bergman

Examples

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"))

icenReg documentation built on May 29, 2024, 5:32 a.m.