Skip to content

R package to compute distribution-free prediction bands using density estimators

Notifications You must be signed in to change notification settings

rizbicki/predictionBands

Repository files navigation

predictionBands

R package to compute distribution-free prediction bands using density estimators according to

Izbicki, R., Shimizu, G. Y., Stern, R. B. (2019). Flexible distribution-free conditional predictive bands using density estimators.

The package estimates conditional densities using FlexCode. (More on FlexCoDE: Izbicki, R.; Lee, A.B. Converting High-Dimensional Regression to High-Dimensional Conditional Density Estimation. Electronic Journal of Statistics, 2017)

Two types of bands are available: 'dist-split' returns intervals (ideal for unimodal response distributions); 'cd-split' returns unions of intervals (ideal for multimodal response distributions)

To install the package, run

# install.packages("devtools")
devtools::install_github("rizbicki/FlexCoDE")
devtools::install_github("rizbicki/predictionBands")

(this package requires FlexCoDE).

A simple example:

library(predictionBands)

library(FlexCoDE)

n<-1000
n_new<-50
d<-10
data<-matrix(NA,n,d+1)
x<-matrix(rnorm(n*d),n,d)
y<-x[,1]+rnorm(n,0,0.1)

# fit predictionBands object
fit<-fit_predictionBands(x,y,0.5,0.4,0.1)

# generate new data:
xnew<-matrix(rnorm(n_new*d),n_new,d)
ynew<-xnew[,1]+rnorm(n_new,0,0.1)

# compute prediction bands for new data:

#Dist-split
bands<-predict(fit,xnew,type="dist")
plot(bands)
plot(bands,ynew) # if ynew is available

#CD-split
bands<-predict(fit,xnew,type="cd")
plot(bands)
plot(bands,ynew) # if ynew is available

#Hpd-split
bands<-predict(fit,xnew,type="hpd")
#bands[[1]]
#bands[[2]]
plot(bands)
plot(bands,ynew) # if ynew is available

About

R package to compute distribution-free prediction bands using density estimators

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages