Quantile regression
{{Short description|Statistical modeling technique}}
{{Regression bar}}
Quantile regression is a type of regression analysis used in statistics and econometrics. Whereas the method of least squares estimates the conditional mean of the response variable across values of the predictor variables, quantile regression estimates the conditional median (or other quantiles) of the response variable. [There is also a method for predicting the conditional geometric mean of the response variable, Tofallis (2015). "A Better Measure of Relative Prediction Accuracy for Model Selection and Model Estimation", Journal of the Operational Research Society, 66(8):1352-1362. [https://ssrn.com/abstract=2635088].] Quantile regression is an extension of linear regression used when the conditions of linear regression are not met.
Advantages and applications
One advantage of quantile regression relative to ordinary least squares regression is that the quantile regression estimates are more robust against outliers in the response measurements. However, the main attraction of quantile regression goes beyond this and is advantageous when conditional quantile functions are of interest. Different measures of central tendency and statistical dispersion can be used to more comprehensively analyze the relationship between variables.{{cite book|title=Quantile Regression|url=https://archive.org/details/quantileregressi00koen_757|url-access=limited|last=Koenker|first=Roger|publisher=Cambridge University Press|year=2005|isbn=978-0-521-60827-5|pages=[https://archive.org/details/quantileregressi00koen_757/page/n151 146]–7}}
In ecology, quantile regression has been proposed and used as a way to discover more useful predictive relationships between variables in cases where there is no relationship or only a weak relationship between the means of such variables. The need for and success of quantile regression in ecology has been attributed to the complexity of interactions between different factors leading to data with unequal variation of one variable for different ranges of another variable.{{cite journal |first1=Brian S. |last1=Cade |first2=Barry R. |last2=Noon |year=2003 |url=http://www.econ.uiuc.edu/~roger/research/rq/QReco.pdf |title=A gentle introduction to quantile regression for ecologists |journal=Frontiers in Ecology and the Environment |volume=1 |issue=8 |pages=412–420 |doi= 10.2307/3868138|jstor=3868138 }}
Another application of quantile regression is in the areas of growth charts, where percentile curves are commonly used to screen for abnormal growth.{{cite journal |last1=Wei |first1=Y. |last2=Pere |first2=A. |last3=Koenker |first3=R. |last4=He |first4=X. |year=2006 |title=Quantile Regression Methods for Reference Growth Charts |journal=Statistics in Medicine |volume=25 |issue=8 |pages=1369–1382 |doi=10.1002/sim.2271 |pmid=16143984 |s2cid=7830193 }}{{cite journal |last1=Wei |first1=Y. |last2=He |first2=X.|author2-link=Xuming He |year=2006 |title=Conditional Growth Charts (with discussions) |journal=Annals of Statistics |volume=34 |issue=5 |pages=2069–2097 and 2126–2131 |doi=10.1214/009053606000000623 |arxiv=math/0702634 |s2cid=88516697 }}
History
The idea of estimating a median regression slope, a major theorem about minimizing sum of the absolute deviances and a geometrical algorithm for constructing median regression was proposed in 1760 by Ruđer Josip Bošković, a Jesuit Catholic priest from Dubrovnik.{{rp|4}}{{cite journal |last=Stigler |first=S. |year=1984 |title=Boscovich, Simpson and a 1760 manuscript note on fitting a linear relation |journal=Biometrika |volume=71 |issue=3 |pages=615–620 |doi=10.1093/biomet/71.3.615 }} He was interested in the ellipticity of the earth, building on Isaac Newton's suggestion that its rotation could cause it to bulge at the equator with a corresponding flattening at the poles.{{Cite book|title=Quantile Regression|url=https://archive.org/details/quantileregressi00koen_757|url-access=limited|last=Koenker|first=Roger|publisher=Cambridge University Press|year=2005|isbn=9780521845731|location=Cambridge|pages=[https://archive.org/details/quantileregressi00koen_757/page/n7 2]}} He finally produced the first geometric procedure for determining the equator of a rotating planet from three observations of a surface feature. More importantly for quantile regression, he was able to develop the first evidence of the least absolute criterion and preceded the least squares introduced by Legendre in 1805 by fifty years.{{Cite book|title=Quantile Regression: Estimation and Simulation|last1=Furno|first1=Marilena|last2=Vistocco|first2=Domenico|publisher=John Wiley & Sons|year=2018|isbn=9781119975281|location=Hoboken, NJ|pages=xv}}
Other thinkers began building upon Bošković's idea such as Pierre-Simon Laplace, who developed the so-called "methode de situation." This led to Francis Edgeworth's plural median{{Cite web|url=http://www.econ.uiuc.edu/~roger/research/galton/Galton.pdf|title=Galton, Edgeworth, Frisch, and prospects for quantile regression in economics|last=Koenker|first=Roger|date=August 1998|website=UIUC.edu|access-date=August 22, 2018}} - a geometric approach to median regression - and is recognized as the precursor of the simplex method. The works of Bošković, Laplace, and Edgeworth were recognized as a prelude to Roger Koenker's contributions to quantile regression.
Median regression computations for larger data sets are quite tedious compared to the least squares method, for which reason it has historically generated a lack of popularity among statisticians, until the widespread adoption of computers in the latter part of the 20th century.
Background: quantiles
Quantile regression expresses the conditional quantiles of a dependent variable as a linear function of the explanatory variables. Crucial to the practicality of quantile regression is that the quantiles can be expressed as the solution of a minimization problem, as we will show in this section before discussing conditional quantiles in the next section.
=Quantile of a random variable=
{{Main|Quantile function}}
Let be a real-valued random variable with cumulative distribution function . The th quantile of Y is given by
:
where
Define the loss function as , where is an indicator function.
A specific quantile can be found by minimizing the expected loss of with respect to :({{pp.|5|6}}):
:
This can be shown by computing the derivative of the expected loss with respect to via an application of the Leibniz integral rule, setting it to 0, and letting be the solution of
:
This equation reduces to
:
and then to
:
If the solution is not unique, then we have to take the smallest such solution to obtain
the th quantile of the random variable Y.
==Example==
Let be a discrete random variable that takes values with with equal probabilities. The task is to find the median of Y, and hence the value is chosen. Then the expected loss of is
:
Since
:
Suppose that u is increased by 1 unit. Then the expected loss will be changed by
:
and any change in u will increase the expected loss. Thus u=5 is the median. The Table below shows the expected loss (divided by
class="wikitable" | |||||||||
u | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
Expected loss | 36 | 29 | 24 | 21 | 20 | 21 | 24 | 29 | 36 |
==Intuition==
Consider
:
In order to minimize the expected loss, we move the value of q a little bit to see whether the expected loss will rise or fall.
Suppose we increase q by 1 unit. Then the change of expected loss would be
:
The first term of the equation is
In order to minimize the expected loss function, we would increase (decrease) L(q) if q is smaller (larger) than the median, until q reaches the median. The idea behind the minimization is to count the number of points (weighted with the density) that are larger or smaller than q and then move q to a point where q is larger than
=Sample quantile=
The
:
:,
where the function
Conditional quantile and quantile regression
The
Conditional probability distribution of
:
We use a capital
In quantile regression for the
:
Given the distribution function of
:
Solving the sample analog gives the estimator of
:
Note that when
linear regression by least absolute deviations.
Computation of estimates for regression parameters
The mathematical forms arising from quantile regression are distinct from those arising in the method of least squares. The method of least squares leads to a consideration of problems in an inner product space, involving projection onto subspaces, and thus the problem of minimizing the squared errors can be reduced to a problem in numerical linear algebra. Quantile regression does not have this structure, and instead the minimization problem can be reformulated as a linear programming problem
:
where
:
Simplex methods{{rp|181}} or interior point methods{{rp|190}} can be applied to solve the linear programming problem.
Asymptotic properties
For
:
where
:
Direct estimation of the asymptotic variance-covariance matrix is not always satisfactory. Inference for quantile regression parameters can be made with the regression rank-score tests or with the bootstrap methods.{{cite journal |last1=Kocherginsky |first1=M. |last2=He |first2=X. |last3=Mu |first3=Y. |year=2005 |title=Practical Confidence Intervals for Regression Quantiles |journal=Journal of Computational and Graphical Statistics |volume=14 |issue=1 |pages=41–55 |doi=10.1198/106186005X27563 |s2cid=120598656 }}
Equivariance
See invariant estimator for background on invariance or see equivariance.
=Scale equivariance=
For any
:
:
=Shift equivariance=
For any
:
=Equivariance to reparameterization of design=
Let
:
=Invariance to monotone transformations=
If
:
Example (1):
If
Inference
= Interpretation of the slope parameters =
The linear model
= Goodness of fit =
The goodness of fit for quantile regression for the
where
Variants
= Bayesian methods for quantile regression =
Because quantile regression does not normally assume a parametric likelihood for the conditional distributions of Y|X, the Bayesian methods work with a working likelihood. A convenient choice is the asymmetric Laplacian likelihood,{{cite journal |last1=Kozumi |first1=H. |last2=Kobayashi |first2=G. |year=2011 |title=Gibbs sampling methods for Bayesian quantile regression |journal=Journal of Statistical Computation and Simulation |volume=81 |issue=11 |pages=1565–1578 |doi=10.1080/00949655.2010.496117 |s2cid=44015988 |url=https://www.b.kobe-u.ac.jp/papers_files/2009_02.pdf }} because the mode of the resulting posterior under a flat prior is the usual quantile regression estimates. The posterior inference, however, must be interpreted with care. Yang, Wang and He{{cite journal |last1=Yang |first1=Y. |last2=Wang |first2=H.X. | last3=He |first3=X.| year=2016 |title=Posterior Inference in Bayesian Quantile Regression with Asymmetric Laplace Likelihood |journal=International Statistical Review |volume=84 |issue=3 |pages=327–344 |doi=10.1111/insr.12114 |hdl=2027.42/135059 |s2cid=14947362 |hdl-access=free }} provided a posterior variance adjustment for valid inference. In addition,
Yang and He{{cite journal |last1=Yang |first1=Y. |last2=He |first2=X. |year=2010 |title=Bayesian empirical likelihood for quantile regression |journal=Annals of Statistics |volume=40 |issue=2 |pages=1102–1131 |doi=10.1214/12-AOS1005 |arxiv=1207.5378 |s2cid=88519086 }} showed that one can have asymptotically valid posterior inference if the working likelihood is chosen to be the empirical likelihood.
=Machine learning methods for quantile regression=
Beyond simple linear regression, there are several machine learning methods that can be extended to quantile regression. A switch from the squared error to the tilted absolute value loss function (a.k.a. the pinball loss{{cite journal | last1 = Steinwart | first1 = Ingo | last2 = Christmann | first2 = Andreas | title = Estimating conditional quantiles with the help of the pinball loss | journal = Bernoulli | volume = 17 | issue = 1 | pages = 211–225 | year = 2011 | publisher = Bernoulli Society for Mathematical Statistics and Probability | doi = 10.3150/10-BEJ267 | url = https://doi.org/10.3150/10-BEJ267| arxiv = 1102.2101 }}) allows gradient descent-based learning algorithms to learn a specified quantile instead of the mean. It means that we can apply all neural network and deep learning algorithms to quantile regression,{{cite arXiv | last=Petneházi | first=Gábor | title=QCNN: Quantile Convolutional Neural Network | date=2019-08-21 | eprint=1908.07978 | class=cs.LG }}{{cite arXiv | last1=Rodrigues | first1=Filipe | last2=Pereira | first2=Francisco C. | title=Beyond expectation: Deep joint mean and quantile regression for spatio-temporal problems | date=2018-08-27 | eprint=1808.08798 | class=stat }} which is then referred to as nonparametric quantile regression.Nonparametric Quantile Regression: Non-Crossing Constraints and Conformal Prediction by Wenlu Tang, Guohao Shen, Yuanyuan Lin, Jian Huang, https://arxiv.org/pdf/2210.10161.pdf
Tree-based learning algorithms are also available for quantile regression (see, e.g., Quantile Regression Forests,{{cite journal | last=Meinshausen | first=Nicolai | title=Quantile Regression Forests | url=http://www.jmlr.org/papers/volume7/meinshausen06a/meinshausen06a.pdf | journal=Journal of Machine Learning Research | volume=7 | issue=6 | pages=983–999 | year=2006 }} as a simple generalization of Random Forests).
=Censored quantile regression=
If the response variable is subject to censoring, the conditional mean is not identifiable without additional distributional assumptions, but the conditional quantile is often identifiable. For recent work on censored quantile regression, see: Portnoy{{cite journal |last=Portnoy |first=S. L. |year=2003 |title=Censored Regression Quantiles |journal=Journal of the American Statistical Association |volume=98 |issue=464 |pages=1001–1012 |doi=10.1198/016214503000000954 |s2cid=120674851 }}
and Wang and Wang{{cite journal |last1=Wang |first1=H. |author1-link= Huixia Judy Wang |last2=Wang |first2=L. |year=2009 |title=Locally Weighted Censored Quantile Regression |journal=Journal of the American Statistical Association |volume=104 |issue=487 |pages=1117–1128 |doi=10.1198/jasa.2009.tm08230 |citeseerx=10.1.1.504.796 |s2cid=34494316 }}
Example (2):
Let
For random censoring on the response variables, the censored quantile regression of Portnoy (2003) provides consistent estimates of all identifiable quantile functions based on reweighting each censored point appropriately.
Censored quantile regression has close links to survival analysis.
File:Km plot.jpgs for the survival probabilities
= Heteroscedastic errors =
The quantile regression loss needs to be adapted in the presence of heteroscedastic errors in order to be efficient.Efficient Quantile Regression for Heteroscedastic
Models by, Yoonsuh Jung, Yoonkyung Lee, Steven N. MacEachern, https://www.tandfonline.com/doi/abs/10.1080/00949655.2014.967244?journalCode=gscs20
Implementations
Numerous statistical software packages include implementations of quantile regression:
- Matlab function
quantreg
{{Cite web|title = quantreg(x,y,tau,order,Nboot) - File Exchange - MATLAB Central|url = http://www.mathworks.com/matlabcentral/fileexchange/32115-quantreg-x-y-tau-order-nboot-|website = www.mathworks.com|access-date = 2016-02-01}} - gretl has the
quantreg
command.{{Cite web|title = Gretl Command Reference|url = http://ricardo.ecn.wfu.edu/pub//gretl/manual/en/gretl-ref.pdf|date = April 2017|access-date = 2017-04-22|archive-date = 2018-12-15|archive-url = https://web.archive.org/web/20181215121225/http://ricardo.ecn.wfu.edu/pub//gretl/manual/en/gretl-ref.pdf|url-status = dead}} - R offers several packages that implement quantile regression, most notably
quantreg
by Roger Koenker,{{cite web |title=quantreg: Quantile Regression |work=R Project |date= 2018-12-18|url=https://cran.r-project.org/web/packages/quantreg/index.html }} but alsogbm
,{{cite web |title=gbm: Generalized Boosted Regression Models |work=R Project |date= 2019-01-14|url=https://cran.r-project.org/web/packages/gbm/ }}quantregForest
,{{cite web |title=quantregForest: Quantile Regression Forests |work=R Project |date= 2017-12-19|url=https://cran.r-project.org/web/packages/quantregForest/index.html }}qrnn
{{cite web |title=qrnn: Quantile Regression Neural Networks |work=R Project |date= 2018-06-26|url=https://cran.r-project.org/web/packages/qrnn/index.html }} andqgam
{{cite web |title=qgam: Smooth Additive Quantile Regression Models |work=R Project |date= 2019-05-23|url=https://cran.r-project.org/web/packages/qgam/index.html }} - Python, via
Scikit-garden
{{cite web |title=Quantile Regression Forests |url=https://scikit-garden.github.io/examples/QuantileRegressionForests/ |website=Scikit-garden |access-date=3 January 2019}} andstatsmodels
{{cite web |title=Statsmodels: Quantile Regression |url=https://www.statsmodels.org/dev/examples/notebooks/generated/quantile_regression.html |website=Statsmodels |access-date=15 November 2019}} - SAS through
proc quantreg
(ver. 9.2){{cite web |title=An Introduction to Quantile Regression and the QUANTREG Procedure |work=SAS Support |url=http://www2.sas.com/proceedings/sugi30/213-30.pdf }} andproc quantselect
(ver. 9.3).{{cite web |title=The QUANTSELECT Procedure |work=SAS Support |url=https://support.sas.com/rnd/app/stat/procedures/quantselect.html }} - Stata, via the
qreg
command.{{cite web |title=qreg — Quantile regression |work=Stata Manual |url=https://www.stata.com/manuals15/rqreg.pdf }}{{cite book |first1=A. Colin |last1=Cameron |first2=Pravin K. |last2=Trivedi |title=Microeconometrics Using Stata |location=College Station |publisher=Stata Press |edition=Revised |year=2010 |isbn=978-1-59718-073-3 |chapter=Quantile Regression |pages=211–234 |chapter-url=https://books.google.com/books?id=UkKQRAAACAAJ&pg=PA211 }} - Vowpal Wabbit, via
--loss_function quantile
.{{Cite web|url=https://github.com/JohnLangford/vowpal_wabbit/wiki/Loss-functions|title=JohnLangford/vowpal_wabbit|website=GitHub|access-date=2016-07-09}} - Mathematica package
QuantileRegression.m
{{cite web |title=QuantileRegression.m |url=https://github.com/antononcube/MathematicaForPrediction/blob/master/QuantileRegression.m |website=MathematicaForPrediction |access-date=3 January 2019}} hosted at the MathematicaForPrediction project at GitHub. - Wolfram Language function
QuantileRegression
{{cite web |title=QuantileRegression |url=https://resources.wolframcloud.com/FunctionRepository/resources/QuantileRegression |website=Wolfram Function Repository |access-date=14 September 2022}} hosted at Wolfram Function Repository.
See also
Literature
{{wikibooks
|1= R Programming
|2= Quantile Regression
}}
- {{cite book |last1=Angrist |first1=Joshua D. |author-link=Joshua Angrist |last2=Pischke |first2=Jörn-Steffen |title=Mostly Harmless Econometrics: An Empiricist's Companion |publisher=Princeton University Press |year=2009 |isbn=978-0-691-12034-8 |chapter=Quantile Regression |pages=269–291 |chapter-url=https://books.google.com/books?id=ztXL21Xd8v8C&pg=PA269 }}
- {{cite book |last=Koenker |first=Roger |author-link=Roger Koenker |year=2005 |title=Quantile Regression |publisher=Cambridge University Press |isbn=978-0-521-60827-5 |url=https://books.google.com/books?id=hdkt7V4NXsgC }}