View source: R/predictive_interval.R
predictive_interval.conformal | R Documentation |
Construct finite-sample calibrated predictive intervals for Bayesian models, following the approach in Barber et al. (2021). By default, the intervals will also reflect the relative uncertainty in the Bayesian model, using the locally-weighted conformal methods of Lei et al. (2018).
## S3 method for class 'conformal'
predictive_interval(object, probs = 0.9, plus = NULL, local = TRUE, ...)
object |
A fitted model which has been passed through |
probs |
The coverage probabilities to calculate intervals for.
Empirically, the coverage rate of the constructed intervals will generally
match these probabilities, but the theoretical guarantee for a probability
of |
plus |
If |
local |
If |
... |
Further arguments to the |
A matrix with the number of rows matching the number of predictions.
Columns will be labeled with a percentile corresponding to probs
; e.g. if
probs=0.9
the columns will be 5%
and 95%
.
Barber, R. F., Candes, E. J., Ramdas, A., & Tibshirani, R. J. (2021). Predictive inference with the jackknife+. The Annals of Statistics, 49(1), 486-507.
Lei, J., G’Sell, M., Rinaldo, A., Tibshirani, R. J., & Wasserman, L. (2018). Distribution-free predictive inference for regression. Journal of the American Statistical Association, 113(523), 1094-1111.
if (requireNamespace("rstanarm", quietly=TRUE)) suppressWarnings({
library(rstanarm)
# fit a simple linear regression
m = stan_glm(mpg ~ disp + cyl, data=mtcars,
chains=1, iter=1000,
control=list(adapt_delta=0.999), refresh=0)
m = loo_conformal(m)
# make predictive intervals
predictive_interval(m)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.