# Quantile regression

> Source: https://aiwiki.ai/wiki/quantile_regression
> Updated: 2026-11-18
> Fact-checked: 2026-11-18
> Categories: Machine Learning, Model Evaluation, Statistics
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/) - attribute to "AI Wiki (aiwiki.ai)"
> Cite as: AI Wiki. "Quantile regression." aiwiki.ai, 18 Nov 2026. https://aiwiki.ai/wiki/quantile_regression
> From AI Wiki (https://aiwiki.ai), the free encyclopedia of artificial intelligence. Reuse freely with attribution.

**Quantile regression** is a family of statistical and [machine learning](https://aiwiki.ai/wiki/machine_learning) methods that estimate conditional quantiles of a response variable, such as its median or its 10th and 90th percentiles given a set of covariates, instead of only its conditional mean. Roger Koenker and Gilbert Bassett Jr. introduced the linear version in "Regression Quantiles", published in *Econometrica* in January 1978, by showing that the minimization problem that yields ordinary sample [quantiles](https://aiwiki.ai/wiki/quantile) generalizes naturally to the linear model.[1] The method replaces the squared-error objective of [linear regression](https://aiwiki.ai/wiki/linear_regression) with an asymmetric absolute-error objective, now usually called the pinball loss, and fitting it at several quantile levels gives a picture of how covariates shift the whole conditional distribution rather than only its center.[2][3]

The modern method was developed in econometrics, where early applications studied wages, household spending and birthweight.[2] In machine learning the pinball loss is used both as a training objective and as an evaluation metric for prediction intervals and probabilistic forecasts. It is built into the main [gradient boosting](https://aiwiki.ai/wiki/gradient_boosting) libraries, and neural forecasters such as the Multi-Horizon Quantile Recurrent Forecaster, the Temporal Fusion Transformer and the pretrained Chronos-2 model are trained with it.[4][5][6][7][8] It also underlies conformalized quantile regression, a method for distribution-free prediction intervals, and the quantile-based family of distributional [reinforcement learning](https://aiwiki.ai/wiki/reinforcement_learning) agents.[9][10]

<figure>
<img src="/images/media-2026-11-18-quantile_regression-a9a9e36f3505.png" alt="Scatter plot with grey fitted lines for quantiles 0.1 to 0.9, a red dashed mean line and a blue median line" width="672" height="671" />
<figcaption>Linear quantile regression lines fitted at quantile levels from 0.1 to 0.9, compared with the least-squares mean line and the median line. Usuário:Rbaliq, via <a href="https://commons.wikimedia.org/wiki/File:Regressao_quantilica.png">Wikimedia Commons</a>, <a href="https://creativecommons.org/licenses/by/3.0">CC BY 3.0</a>.</figcaption>
</figure>

## From the median to every quantile

Koenker and Hallock's 2001 survey in the *Journal of Economic Perspectives* explains the idea in two steps.[2] The sample mean is the number that minimizes a sum of squared residuals, and the sample median is the number that minimizes a sum of absolute residuals. Because the absolute value function is symmetric, the minimizer has as many observations above it as below it. Giving positive and negative residuals different weights tilts this balance, and the minimizer then becomes another sample quantile. Koenker and Hallock call the resulting function the "tilted absolute value function".[2]

The second step copies the move from the sample mean to least squares regression. Replacing the single number with a parametric function of covariates, $\xi(x, \beta)$, turns the problem of finding a sample quantile into a regression problem for a conditional quantile function. Koenker and Hallock note that variants of median regression had been proposed by Roger Boscovich in the mid-eighteenth century and were later studied by Pierre-Simon Laplace and Francis Edgeworth.[2] Portnoy and Koenker describe the history the same way: since Gauss, least squares methods had been accepted as computationally easier than the earlier absolute-error methods advocated by Boscovich, Laplace and others.[11]

### The 1978 paper

Koenker and Bassett's abstract describes regression quantiles as "a new class of statistics" and identifies the estimator that minimizes the sum of absolute residuals as an important special case.[1] The paper established equivariance properties and the joint asymptotic distribution of regression quantiles, and used them to extend well-known robust estimators of location to the linear model. The authors reported that the estimators they proposed have efficiency comparable to least squares for Gaussian linear models while substantially outperforming least squares over a wide class of non-Gaussian error distributions.[1] Koenker later wrote a book-length treatment of the subject, *Quantile Regression*, published by Cambridge University Press in 2005.[12]

<figure class="embedvideo">
<iframe src="https://www.youtube-nocookie.com/embed/P9lMmEkXuBw" title="Quantile Regression"></iframe>
<figcaption>"Quantile Regression", video from econometricsacademy, published February 25, 2013. <a href="https://www.youtube.com/watch?v=P9lMmEkXuBw">Watch on YouTube</a>.</figcaption>
</figure>

## The pinball loss

For a quantile level $\tau$ strictly between 0 and 1 and a residual $u = y - \hat{y}$ (the observed value minus the prediction), the loss is

$$\rho_\tau(u) = u\,\big(\tau - \mathbb{1}\{u < 0\}\big) = \begin{cases} \tau\, u & \text{if } u \geq 0 \\ (\tau - 1)\, u & \text{if } u < 0 \end{cases}$$

where $\mathbb{1}\{u < 0\}$ equals 1 when the prediction is too high and 0 otherwise.[10] An equivalent form, used in the scikit-learn documentation, is $\tau \max(u, 0) + (1 - \tau)\max(-u, 0)$.[3] The same function appears in the literature under several names: the check function, the pinball loss, the quantile loss and, in scikit-learn, the linear loss.[3][9][6]

Under-predictions are penalized with weight $\tau$ and over-predictions with weight $1 - \tau$.[9] For a distribution of outcomes, the value that minimizes the expected loss is the $\tau$-quantile of that distribution.[10] At $\tau = 0.5$ the loss is half the absolute error, so minimizing it is equivalent to minimizing the [mean absolute error](https://aiwiki.ai/wiki/mean_absolute_error_mae) and yields the median. The Multi-Horizon Quantile Recurrent Forecaster paper notes that at this level the quantile loss reduces to the mean absolute error, whose minimizer is the median.[6]

The asymmetry is easiest to see with numbers. The table applies the definition above to a single observation whose true value is 100.

| Quantile level $\tau$ | Prediction 90 (too low by 10) | Prediction 110 (too high by 10) |
|---|---|---|
| 0.1 | 1 | 9 |
| 0.5 | 5 | 5 |
| 0.9 | 9 | 1 |

A model trained for the 0.9 quantile is therefore pushed upward until about 90 percent of observations fall below its predictions, and a model trained for the 0.1 quantile is pushed downward.

### The linear estimator

With a linear model $\xi(x, \beta) = x^\top \beta$, the estimator for quantile level $\tau$ is

$$\hat{\beta}(\tau) = \arg\min_{\beta \in \mathbb{R}^p} \sum_{i=1}^{n} \rho_\tau\big(y_i - x_i^\top \beta\big).$$

Each coefficient is read as the effect of a one-unit change in that covariate on the $\tau$-th conditional quantile of the response, holding the other covariates fixed.[2] Repeating the fit over a grid of $\tau$ values traces out a "quantile regression process". If a covariate only shifts the location of the distribution, its coefficient is roughly constant across $\tau$; if it stretches or skews the distribution, the coefficient changes with $\tau$.[2]

Koenker and Hallock warn against a common shortcut: splitting the sample by the response variable's unconditional distribution and running least squares on each subset. They describe this "truncation on the dependent variable" as yielding disastrous results, whereas splitting by covariates is always valid.[2]

## Computation

When the conditional quantile function is linear in its parameters, the minimization is a [linear programming](https://aiwiki.ai/wiki/linear_programming) problem. Koenker and Hallock write that this has been recognized since the early 1950s for median regression and that the simplex-based algorithm of Barrodale and Roberts (1974) proved particularly influential.[2] In 1997 Stephen Portnoy and Koenker combined interior point methods for linear programs with a statistical preprocessing step and reported a 10- to 100-fold speedup over simplex-based algorithms on large problems. Their paper, "The Gaussian hare and the Laplacian tortoise", argued that absolute-error methods could be made competitive with least squares in speed across the whole range of problem sizes.[11]

Modern libraries use several solvers:

| Library | Interface | How it fits |
|---|---|---|
| R | `quantreg` package, maintained by Koenker | Linear, nonlinear and nonparametric conditional quantile models, plus censored survival data methods[13] |
| [scikit-learn](https://aiwiki.ai/wiki/scikit_learn) | `QuantileRegressor` | Linear program solved with `scipy.optimize.linprog` (HiGHS solvers by default), with an optional L1 penalty[3][14] |
| statsmodels | `QuantReg` | Iterative reweighted least squares[15] |

The scikit-learn implementation adds an L1 penalty on the coefficients controlled by a parameter `alpha`, similar to the Lasso.[14] Koenker and Hallock trace the software lineage back to a public-domain package for the S language that Koenker maintained from the mid-1980s and later ported to R.[2]

## Uses in econometrics and finance

Koenker and Hallock's 2001 survey illustrates the method with two worked examples.[2]

- **Engel curves.** Using Ernst Engel's 1857 data on food expenditure and income for 235 European working-class households, seven quantile regression lines (at $\tau$ = 0.05, 0.1, 0.25, 0.5, 0.75, 0.9 and 0.95) show that the spread of food spending grows with income and that the conditional distribution is skewed to the left. The median fit and the least squares fit differ markedly, partly because two unusual households with high income and low food spending pull the least squares line.
- **Infant birthweight.** On 198,377 US births from the June 1997 Detailed Natality Data, boys were about 100 grams heavier than girls according to least squares, but the gap was about 45 grams at the 0.05 quantile and about 130 grams at the 0.95 quantile. The gap between babies of black and white mothers was roughly a third of a kilogram at the 5th percentile. High school graduation was one of the few covariates with an almost uniform effect, a pure location shift.

The same survey summarizes applied work in labor economics. Gary Chamberlain found that the union wage premium for manufacturing workers was 28 percent at the first decile and fell to 0.3 percent at the upper decile, against a least squares estimate of 15.8 percent.[2] Koenker and Hallock also list applications to school quality, wage inequality, demand analysis and unemployment duration.[2]

In finance, value at risk is a quantile of the distribution of future portfolio values. Robert Engle and Simone Manganelli's CAViaR model (NBER working paper, 1999) estimates that conditional quantile directly with regression quantile methods, without assuming normal or independent and identically distributed returns. Because their objective is not differentiable, they optimized it with a differential evolutionary genetic algorithm.[16] James W. Taylor's 2000 paper in the *Journal of Forecasting* applied a quantile regression [neural network](https://aiwiki.ai/wiki/neural_network) to estimating the conditional density of multiperiod returns.[17]

## Machine learning models

Because the pinball loss can be minimized by any model that accepts a custom loss, conditional quantiles can be estimated by far more flexible models than the linear one.[3]

### Gradient boosting and forests

Scikit-learn, LightGBM, XGBoost and CatBoost all ship a quantile objective:

| Library | Setting | Notes |
|---|---|---|
| scikit-learn | `GradientBoostingRegressor(loss="quantile", alpha=...)` | `alpha` is the quantile to predict[3] |
| scikit-learn | `HistGradientBoostingRegressor(loss="quantile", quantile=...)` | Level set by `quantile`; option added in version 1.1; uses the pinball loss[18] |
| [LightGBM](https://aiwiki.ai/wiki/lightgbm) | `objective="quantile"` | Level set by `alpha` (default 0.9); `quantile` is also an evaluation metric[4] |
| [XGBoost](https://aiwiki.ai/wiki/xgboost) | `objective="reg:quantileerror"` | Added in version 2.0.0; `quantile_alpha` accepts one quantile or an ascending list; optimizes a smooth approximation of the loss[5] |
| [CatBoost](https://aiwiki.ai/wiki/catboost) | `Quantile`, `MultiQuantile` | `MultiQuantile` takes a vector of quantile levels[19] |

Quantile objectives also figured in forecasting competitions. The M5 Uncertainty competition asked entrants to forecast nine quantiles for 42,840 hierarchical time series of Walmart unit sales.[20] Its scoring rule was a weighted, scaled version of the pinball loss, and a later study by Long and colleagues reports that the winning entry, by Lainder and Wolfinger, was a quantile forecasting method built on LightGBM with data augmentation.[21] The same study notes a practical cost: in most gradient boosting frameworks the model has to be trained again for each quantile of interest.[21]

Nicolai Meinshausen's quantile regression forests (2006) take a different route. A [random forest](https://aiwiki.ai/wiki/random_forest) for regression normally approximates the conditional mean, but Meinshausen showed that the forest also carries information about the full conditional distribution, from which conditional quantiles can be read off. He proved the algorithm consistent.[22] Romano, Patterson and Candès point out that quantile regression forests are asymptotically consistent even though they do not minimize the pinball loss.[9]

### Neural networks and forecasting

[Deep learning](https://aiwiki.ai/wiki/deep_learning) forecasters often output several quantiles at once and sum the pinball loss over all of them.

- **MQ-RNN (2017).** Ruofeng Wen and colleagues combined sequence-to-sequence networks with quantile regression and direct multi-horizon forecasting, demonstrated it on forecasting demand for items sold on Amazon.com, and trained it on the total quantile loss over horizons and quantiles.[6] On the GEFCom2014 electricity price and load problems, the paper reports average quantile losses that would have placed first in both tracks.[6]
- **Temporal Fusion Transformer (2019).** Bryan Lim and co-authors from the University of Oxford and Google Cloud AI trained the TFT, an attention-based multi-horizon forecaster, by jointly minimizing the quantile loss summed over the quantiles {0.1, 0.5, 0.9}, and evaluated it on P50 and P90 quantile risk.[7]
- **Simultaneous quantile regression (2018).** Natasa Tagasovska and David Lopez-Paz proposed a single loss for learning all conditional quantiles of a target with one network, as a way to estimate aleatoric uncertainty and build calibrated prediction intervals.[23]

Some pretrained [time series](https://aiwiki.ai/wiki/time_series) foundation models use the same objective. The original Chronos models (2024) tokenized time series values and were trained with a cross-entropy loss.[24] Chronos-2, released by researchers at Amazon Web Services in October 2025, instead uses a quantile head that predicts 21 quantiles from 0.01 to 0.99 and is trained with the quantile regression objective; its authors contrast this with the nine-quantile grid from 0.1 to 0.9 that they describe as common in existing pretrained models.[8] Google Research's TimesFM 2.5 (September 2025) added an optional quantile head of about 30 million parameters, and as of November 2026 the TimesFM repository's examples show TimesFM 3.0 returning nine decile forecasts alongside its median forecast.[25]

### Distributional reinforcement learning

Will Dabney of DeepMind and his co-authors used quantile regression to learn the distribution of returns in reinforcement learning rather than only its expected value. Their QR-DQN algorithm (2017) represents the return distribution by N locations that each carry equal probability, and learns where those locations lie with the quantile regression loss. Because that loss is not smooth at zero, the authors also introduced a "quantile Huber loss", which is an asymmetric squared loss in a small interval around zero and the ordinary quantile loss outside it.[10] They reported that on Atari 2600 games QR-DQN significantly outperformed many recent improvements to [DQN](https://aiwiki.ai/wiki/dqn), including the related distributional algorithm C51.[10] Implicit quantile networks (IQN), presented at ICML 2018, extended the idea by learning the full quantile function of the return distribution, which also allows risk-sensitive policies.[26]

## Prediction intervals and conformal calibration

A pair of quantile models, for example at $\tau = 0.05$ and $\tau = 0.95$, gives a 90 percent prediction interval whose width can vary with the inputs. The scikit-learn documentation notes that such intervals stay sensible when errors have non-constant but predictable variance or are not normally distributed, unlike intervals that assume normally distributed errors with constant variance.[3] Romano, Patterson and Candès caution, however, that intervals from fitted quantile models carry no finite-sample guarantee and that in their experiments intervals built by neural networks could substantially undercover.[9]

Their 2019 method, conformalized quantile regression (CQR), corrects this with a held-out calibration set. After fitting lower and upper quantile models on one part of the data, it computes a conformity score on the other part, $E_i = \max\{\hat{q}_{\text{lo}}(X_i) - Y_i,\; Y_i - \hat{q}_{\text{hi}}(X_i)\}$, and widens or narrows the interval by an empirical quantile of those scores. If the data are exchangeable, the resulting interval covers a new observation with probability at least $1 - \alpha$.[9] This guarantee is marginal, averaged over the inputs, rather than conditional on a particular input. The authors reported that CQR tends to produce shorter intervals than other conformal methods while remaining adaptive to heteroscedasticity.[9]

## Evaluating quantile forecasts

Tilmann Gneiting showed that a scoring function is consistent for a quantile, meaning that its expected value is minimized by reporting the true quantile, if and only if it is generalized piecewise linear. The pinball loss belongs to this class, so quantiles are elicitable: a strictly consistent scoring function exists for them. The same paper notes that not every functional is elicitable; conditional value at risk, despite its popularity in quantitative finance, is not.[27] Several forecasting benchmarks report the pinball loss averaged over a set of quantile levels, often scaled or weighted. The TFT paper reports a normalized "q-risk", and the Chronos-2 paper ranks models by scaled and weighted quantile losses on the fev-bench and GIFT-Eval benchmarks.[7][8]

## Limitations

- **Quantile crossing.** Quantile curves fitted separately can cross, so that an estimated 0.9 quantile falls below the 0.8 quantile for some inputs, which is impossible for a true distribution. Victor Chernozhukov, Iván Fernández-Val and Alfred Galichon called this a longstanding problem and proposed sorting, or monotone rearrangement, of the estimated curve; they showed that the rearranged curve is closer to the true quantile curve in finite samples than the original.[28] The XGBoost documentation notes that its expectile objective, unlike its quantile objective, does not suffer from curve crossing.[5]
- **Non-smooth objective.** The pinball loss has a kink at zero. Linear models handle this through linear programming, while XGBoost optimizes a smooth approximation and CAViaR resorted to a genetic algorithm.[2][5][16]
- **One model per quantile.** Unless the model is built to output several quantiles, each quantile level needs its own fit, which multiplies training cost for wide quantile grids.[21]
- **Coverage is not guaranteed.** Intervals from fitted quantile models can undercover in finite samples unless they are calibrated, for example with conformal methods.[9]

## See also

- [Quantile](https://aiwiki.ai/wiki/quantile)
- [Mean Absolute Error (MAE)](https://aiwiki.ai/wiki/mean_absolute_error_mae)
- [Probabilistic Regression Model](https://aiwiki.ai/wiki/probabilistic_regression_model)
- [Linear regression](https://aiwiki.ai/wiki/linear_regression)
- [Gradient boosting](https://aiwiki.ai/wiki/gradient_boosting)
- [Loss function](https://aiwiki.ai/wiki/loss_function)

## References

1. Koenker, Roger and Gilbert Bassett, Jr. "Regression Quantiles". Econometrica 46(1): 33-50, January 1978. https://www.econometricsociety.org/publications/econometrica/1978/01/01/regression-quantiles
2. Koenker, Roger and Kevin F. Hallock. "Quantile Regression". Journal of Economic Perspectives 15(4): 143-156, Fall 2001. https://doi.org/10.1257/jep.15.4.143
3. scikit-learn developers. "1.1.15. Quantile Regression". scikit-learn User Guide, Linear Models. https://scikit-learn.org/stable/modules/linear_model.html#quantile-regression
4. LightGBM developers. "Parameters". LightGBM documentation. https://lightgbm.readthedocs.io/en/latest/Parameters.html
5. XGBoost developers. "XGBoost Parameters". XGBoost documentation. https://xgboost.readthedocs.io/en/stable/parameter.html
6. Wen, Ruofeng, Kari Torkkola, Balakrishnan Narayanaswamy and Dhruv Madeka. "A Multi-Horizon Quantile Recurrent Forecaster". NIPS 2017 Time Series Workshop, arXiv:1711.11053, November 2017. https://arxiv.org/abs/1711.11053
7. Lim, Bryan, Sercan O. Arik, Nicolas Loeff and Tomas Pfister. "Temporal Fusion Transformers for Interpretable Multi-horizon Time Series Forecasting". arXiv:1912.09363, December 2019. https://arxiv.org/abs/1912.09363
8. Ansari, Abdul Fatir et al. "Chronos-2: From Univariate to Universal Forecasting". arXiv:2510.15821, October 2025. https://arxiv.org/abs/2510.15821
9. Romano, Yaniv, Evan Patterson and Emmanuel J. Candès. "Conformalized Quantile Regression". arXiv:1905.03222, May 2019. https://arxiv.org/abs/1905.03222
10. Dabney, Will, Mark Rowland, Marc G. Bellemare and Rémi Munos. "Distributional Reinforcement Learning with Quantile Regression". arXiv:1710.10044, October 2017. https://arxiv.org/abs/1710.10044
11. Portnoy, Stephen and Roger Koenker. "The Gaussian hare and the Laplacian tortoise: computability of squared-error versus absolute-error estimators". Statistical Science 12(4): 279-300, November 1997. https://doi.org/10.1214/ss/1030037960
12. Koenker, Roger. "Quantile Regression". Cambridge University Press, 2005. https://doi.org/10.1017/CBO9780511754098
13. Koenker, Roger et al. "quantreg: Quantile Regression". CRAN (Comprehensive R Archive Network). https://cran.r-project.org/package=quantreg
14. scikit-learn developers. "QuantileRegressor". scikit-learn API Reference. https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.QuantileRegressor.html
15. statsmodels developers. "statsmodels.regression.quantile_regression.QuantReg". statsmodels documentation. https://www.statsmodels.org/stable/generated/statsmodels.regression.quantile_regression.QuantReg.html
16. Engle, Robert F. and Simone Manganelli. "CAViaR: Conditional Value at Risk by Quantile Regression". NBER Working Paper 7341, September 1999. https://www.nber.org/papers/w7341
17. Taylor, James W. "A quantile regression neural network approach to estimating the conditional density of multiperiod returns". Journal of Forecasting 19(4): 299-311, 2000. https://doi.org/10.1002/1099-131X(200007)19:4<299::AID-FOR775>3.0.CO;2-V
18. scikit-learn developers. "HistGradientBoostingRegressor". scikit-learn API Reference. https://scikit-learn.org/stable/modules/generated/sklearn.ensemble.HistGradientBoostingRegressor.html
19. CatBoost developers. "Regression: objectives and metrics". CatBoost documentation. https://catboost.ai/docs/en/concepts/loss-functions-regression
20. Makridakis, Spyros, Evangelos Spiliotis, Vassilios Assimakopoulos, Zhi Chen, Anil Gaba, Ilia Tsetlin and Robert L. Winkler. "The M5 uncertainty competition: Results, findings and conclusions". International Journal of Forecasting 38(4): 1365-1385, 2022. https://doi.org/10.1016/j.ijforecast.2021.10.009
21. Long, Xueying et al. "Scalable Probabilistic Forecasting in Retail with Gradient Boosted Trees: A Practitioner's Approach". arXiv:2311.00993, November 2023. https://arxiv.org/abs/2311.00993
22. Meinshausen, Nicolai. "Quantile Regression Forests". Journal of Machine Learning Research 7(35): 983-999, 2006. https://jmlr.org/papers/v7/meinshausen06a.html
23. Tagasovska, Natasa and David Lopez-Paz. "Single-Model Uncertainties for Deep Learning". NeurIPS 2019, arXiv:1811.00908, November 2018. https://arxiv.org/abs/1811.00908
24. Ansari, Abdul Fatir et al. "Chronos: Learning the Language of Time Series". arXiv:2403.07815, March 2024. https://arxiv.org/abs/2403.07815
25. Google Research. "TimesFM" (README). GitHub, accessed November 2026. https://github.com/google-research/timesfm
26. Dabney, Will, Georg Ostrovski, David Silver and Rémi Munos. "Implicit Quantile Networks for Distributional Reinforcement Learning". ICML 2018, arXiv:1806.06923. https://arxiv.org/abs/1806.06923
27. Gneiting, Tilmann. "Making and Evaluating Point Forecasts". Journal of the American Statistical Association 106(494): 746-762, 2011 (arXiv:0912.0902, 2009). https://arxiv.org/abs/0912.0902
28. Chernozhukov, Victor, Iván Fernández-Val and Alfred Galichon. "Quantile and Probability Curves Without Crossing". Econometrica 78(3): 1093-1125, 2010 (arXiv:0704.3649). https://arxiv.org/abs/0704.3649

