Learn R Programming

pintervals (version 1.0.1)

Model Agnostic Prediction Intervals

Description

Provides tools for estimating model-agnostic prediction intervals using conformal prediction, bootstrapping, and parametric prediction intervals. The package is designed for ease of use, offering intuitive functions for both binned and full conformal prediction methods, as well as parametric interval estimation with diagnostic checks. Currently only working for continuous predictions. For details on the conformal and bin-conditional conformal prediction methods, see Randahl, Williams, and Hegre (2024) .

Copy Link

Version

Install

install.packages('pintervals')

Monthly Downloads

412

Version

1.0.1

License

GPL (>= 3)

Maintainer

David Randahl

Last Published

January 11th, 2026

Functions in pintervals (1.0.1)

interval_coverage

Empirical coverage of prediction intervals
interval_miscoverage

Empirical miscoverage of prediction intervals
interval_score

Mean interval score (MIS) for prediction intervals
heterogeneous_error

Heterogeneous Error Function for Non-Conformity Scores
interval_width

Mean width of prediction intervals
county_turnout

U.S. county-level turnout and demographic context (MIT Election Lab 2018 Election Analysis Dataset + additions)
minq_to_alpha

Helper for minimum quantile to alpha function
logistic_kern

Logistic Kernel Function
ks_cluster

Function to perform Kolmogorov-Smirnov clustering on non-conformity scores
pinterval_parametric

#' Parametric prediction intervals for continuous predictions
kmeans_cluster_qecdf

Function to perform K-means clustering on quantile empirical cumulative distribution functions (qECDFs) of non-conformity scores
pinterval_mondrian

Mondrian conformal prediction intervals for continuous predictions
pinterval_conformal

Conformal Prediction Intervals of Continuous Values
ks_cluster_assignment_step

Function to assign classes to clusters based on Kolmogorov-Smirnov clustering
ks_cluster_init_step

Function to initialize clusters for Kolmogorov-Smirnov clustering
pinterval_ccp

Clustered conformal prediction intervals for continuous predictions
pinterval_bootstrap

Bootstrap prediction intervals
pinterval_bccp

Bin-conditional conformal prediction intervals for continuous predictions
wcss_compute

Function to compute the within-cluster sum of squares (WCSS) for a set of clusters
za_rel_error

Zero-adjusted Relative Error Function for Non-Conformity Scores by predicted Values with a small adjustment
pintervals-package

pintervals: Model Agnostic Prediction Intervals
raw_error

Raw Error Function for Non-Conformity Scores
reciprocal_linear_kern

Reciprocal Linear Kernel Function
rel_error

Relative Error Function for Non-Conformity Scores by predicted Values
ncs_compute

Non-Conformity Score Computation Function
optimize_clusters

Function to optimize clusters based on the Calinski-Harabasz index
ch_index

Function to compute the Calinski-Harabasz index for a set of clusters
bcss_compute

Function to compute the between-cluster sum of squares (BCSS) for a set of clusters
bin_chopper

Bin chopper function for binned bootstrapping
cauchy_kern

Cauchy Kernel Function
class_to_clusters

Function to convert class vector to cluster vector based on calibrated clusters
grid_finder

Grid search for lower and upper bounds of continuous conformal prediction intervals
gauss_kern

Gaussian Kernel Function
clusterer

Function to cluster non-conformity scores using either Kolmogorov-Smirnov or K-means clustering
Dm_finder

Function to find the minimum distance between a class and a set of clusters
bindividual_alpha

Bin-individual alpha function for conformal prediction
abs_error

Absolute Error Function for Non-Conformity Scores
coverage_gap_finder

Function to find the coverage gap for a set of clusters
grid_inner

Inner function for grid search
contiguize_intervals

Contiguize non-contiguous intervals
bootstrap_inner

Bootstrap function for bootstrapping the prediction intervals
flatten_cp_bin_intervals

Flatten binned conformal prediction intervals to contiguous intervals
elections

Election-year democracy indicators from V-Dem (1946–2024)
dm_to_prob

Function to convert distance measure to probability