survCIs: Confidence/Credible intervals for survival curves

Description Usage Arguments Details Author(s) Examples

View source: R/user_utilities.R

Description

Confidence/Credible intervals for survival curves

Usage

1
2
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
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"))

Example output

Loading required package: survival
Loading required package: Rcpp
Loading required package: coda
Model call:
  ic_par(formula = cbind(left, right) ~ gender, data = IR_diabetes)
Credible Level = 0.95 
Rowname:  Males 
      Percentile estimate (mean) estimate (median)     lower     upper
 [1,]      0.025        5.232367          5.229064  4.775583  5.709513
 [2,]      0.075        7.785955          7.782810  7.250639  8.325932
 [3,]      0.125        9.417141          9.420957  8.856009  9.978189
 [4,]      0.175       10.714502         10.718690 10.141502 11.292171
 [5,]      0.225       11.835345         11.838273 11.255832 12.416806
 [6,]      0.275       12.849012         12.848579 12.262696 13.433806
 [7,]      0.325       13.793806         13.792358 13.188565 14.391897
 [8,]      0.375       14.694216         14.693958 14.089842 15.291306
 [9,]      0.425       15.567836         15.568550 14.955614 16.175466
[10,]      0.475       16.428731         16.428390 15.804853 17.042752
[11,]      0.525       17.289399         17.289432 16.663408 17.911326
[12,]      0.575       18.162193         18.161488 17.535784 18.800848
[13,]      0.625       19.060675         19.061084 18.421972 19.723900
[14,]      0.675       20.001311         20.000635 19.337966 20.678491
[15,]      0.725       21.006118         21.002769 20.316827 21.705577
[16,]      0.775       22.107601         22.101571 21.390896 22.838458
[17,]      0.825       23.359445         23.352528 22.605118 24.134229
[18,]      0.875       24.864574         24.859465 24.077780 25.692432
[19,]      0.925       26.873935         26.866359 25.991553 27.804070
[20,]      0.975       30.455042         30.445445 29.393770 31.582379
Rowname:  Females 
      Percentile estimate (mean) estimate (median)     lower     upper
 [1,]      0.025        4.993545          4.988430  4.525088  5.478294
 [2,]      0.075        7.431576          7.429532  6.877043  7.995630
 [3,]      0.125        8.989094          8.984624  8.393994  9.598882
 [4,]      0.175       10.227929         10.222720  9.613327 10.863881
 [5,]      0.225       11.298250         11.290869 10.663873 11.957785
 [6,]      0.275       12.266255         12.261524 11.618270 12.949974
 [7,]      0.325       13.168513         13.163791 12.504672 13.860090
 [8,]      0.375       14.028405         14.027552 13.343176 14.734673
 [9,]      0.425       14.862729         14.861305 14.155298 15.584878
[10,]      0.475       15.684916         15.684170 14.958122 16.424359
[11,]      0.525       16.506901         16.507358 15.757751 17.253882
[12,]      0.575       17.340481         17.342416 16.564739 18.098394
[13,]      0.625       18.198609         18.201735 17.397630 18.980899
[14,]      0.675       19.097011         19.100535 18.264064 19.903917
[15,]      0.725       20.056720         20.060101 19.201848 20.894073
[16,]      0.775       21.108783         21.108762 20.228017 21.990090
[17,]      0.825       22.304482         22.307844 21.370438 23.224384
[18,]      0.875       23.742135         23.745961 22.756170 24.727221
[19,]      0.925       25.661461         25.659192 24.583624 26.753475
[20,]      0.975       29.082224         29.069214 27.857349 30.391958

icenReg documentation built on Oct. 23, 2020, 8:11 p.m.