loo_conformal {conformalbayes} | R Documentation |
Enable leave-one-out conformal predictive intervals for a fit model
Description
Prepares for jackknife(+) conformal prediction by performing Pareto-smoothed importance sampling to yield leave-one-out residuals.
Usage
loo_conformal(fit, ...)
## Default S3 method:
loo_conformal(fit, truth, chain = NULL, est_fun = c("mean", "median"), ...)
## S3 method for class 'stanreg'
loo_conformal(fit, est_fun = c("mean", "median"), ...)
## S3 method for class 'brmsfit'
loo_conformal(fit, est_fun = c("mean", "median"), ...)
Arguments
fit |
Model fit; an object with |
... |
Ignored. |
truth |
True values to predict. Not required for |
chain |
An integer vector identifying the chain numbers for the posterior draws. Should be provided if multiple chains are used. |
est_fun |
Whether to use the posterior |
Value
A modified fit
object with an additional class conformal
.
Calling predictive_interval()
on this new object will yield conformal
intervals.
References
Vehtari, A., Simpson, D., Gelman, A., Yao, Y., & Gabry, J. (2015). Pareto smoothed importance sampling. arXiv preprint arXiv:1507.02646.
Examples
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)
loo_conformal(m)
})