Skip to content

ryantibs/quantgen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

80 Commits
 
 
 
 
 
 
 
 

Repository files navigation

quantgen

The quantgen package provides tools for generalized quantile modeling: regularized quantile regression (with generalized lasso penalties and noncrossing constraints), cross-validation, quantile extrapolation, and quantile ensembles.

Its original goal was to support the development of Delphi's COVID forecasts, and the development an ensemble forecaster out of individual component models submitted to the COVID Forecast Hub. The latter is a collaborative repo organized by the Reich lab, containing COVID forecasts from many groups (visualized here), and serves as the official data source behind the CDC's reports on COVID forecasting.

Summary of package tools

The R package quantgen provides:

  • Tools for quantile regression not found in existing R packages (to our knowledge), allowing for generalized lasso penalties, and noncrossing constraints.

  • Tools for building quantile model ensembles via linear stacking, with weights chosen to minimize the weighted interval score, in a variety of setups (one weight per model, one weight per model per quantile, and everything in between).

  • Tools for extrapolating a smaller set of quantiles into richer set of quantiles, in such a way that is nonparametric "in the middle" of the distribution (monotone cubic spline interpolation), and parametric "in the tails" (with a tail behavior of the user's choosing).

Consult the package documentation and vignettes for full details.

Linear program solvers

All quantile regression and stacking problems are reformulated as linear programs (LPs), and solved using one of two LP solvers:

  1. GLPK, the default, which is open-source, and available thorugh the Rglpk package.

  2. Gurobi, which is not open-source but free for academic use, and available through the gurobi package (see below).

If at all possible, Gurobi should be used because it is much faster and more stable. The mathematical details for how these LPs are formed are given in the notebooks linked below.

Example notebooks

Beyond the vignettes, for examples in the form of R notebooks, see:

  • simple_test.html: simple tests comparing the outputs and speeds of the two LP solvers to rqPen (which is based on the quantreg package).

  • cv_example.html: examples of how to use cross-validation to select the tuning parameters in penalized quantile regression, how to extrapolate a smaller set of quantiles into richer set of quantiles at prediction time, and how to use noncrossing constraints.

  • stacking_example.html: examples of how to use linear stacking to build quantile model ensembles.

Install the quantgen R package

To install the quantgen R package directly from GitHub, run the following in R:

devtools::install_github(repo="ryantibs/quantgen", subdir="quantgen")

Install the gurobi R package

  • First install the latest version of Gurobi optimizer here.

  • For academics, you can obtain a free license here.

  • Then follow these instructions to install the gurobi R package.

About

Tools for generalized quantile modeling

Resources

Stars

Watchers

Forks

Languages