Quantile regression explained

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. 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.[1]

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.[2]

Another application of quantile regression is in the areas of growth charts, where percentile curves are commonly used to screen for abnormal growth.[3] [4]

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.[5] 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.[6] 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.[7]

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[8] - 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

See main article: Quantile function. Let

Y

be a real-valued random variable with cumulative distribution function

FY(y)=P(Y\leqy)

. The

\tau

th quantile of Y is given by

qY

-1
(\tau)=F
Y

(\tau)=inf\left\{y:FY(y)\geq\tau\right\}

where

\tau\in(0,1).

Define the loss function as

\rho\tau(m)=m(\tau-I(m<0))

, where

I

is an indicator function.A specific quantile can be found by minimizing the expected loss of

Y-u

with respect to

u

::

qY(\tau)=\underset{u}{argmin

}E(\rho_(Y-u))=\underset\biggl\.

This can be shown by computing the derivative of the expected loss with respect to

u

via an application of the Leibniz integral rule, setting it to 0, and letting

q\tau

be the solution of
q\tau
0=(1-\tau)\int
-infty

dFY

infty
(y)-\tau\int
q\tau

dFY(y).

This equation reduces to

0=FY(q\tau)-\tau,

and then to

FY(q\tau)=\tau.

If the solution

q\tau

is not unique, then we have to take the smallest such solution to obtainthe

\tau

th quantile of the random variable Y.

Example

Let

Y

be a discrete random variable that takes values

yi=i

with

i=1,2,...,9

with equal probabilities. The task is to find the median of Y, and hence the value

\tau=0.5

is chosen. Then the expected loss of

Y-u

is

L(u)=E(\rho\tau(Y-u))=

(\tau-1)
9
\sum
yi<u

(yi-u)

+\tau
9
\sum
yi\gequ

(yi-u)

=0.5
9

l(

-

\sum
yi<u

(yi-u)

+\sum
yi\gequ

(yi-u)

r).

Since

{0.5/9}

is a constant, it can be taken out of the expected loss function (this is only true if

\tau=0.5

). Then, at u=3,

L(3)

2
\propto\sum
i=1

-(i-3)

9
+\sum
i=3

(i-3)

=[(2+1)+(0+1+2+...+6)]=24.

Suppose that u is increased by 1 unit. Then the expected loss will be changed by

(3)-(6)=-3

on changing u to 4. If, u=5, the expected loss is

L(5)\propto

4
\sum
i=1
4
i+\sum
i=0

i=20,

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

{0.5/9}

) for different values of u.
u 123456789
Expected loss3629242120212429 36

Intuition

Consider

\tau=0.5

and let q be an initial guess for

q\tau

. The expected loss evaluated at q is
q
L(q)=-0.5\int
-infty

(y-q)dFY

infty
(y)+0.5\int
q

(y-q)dFY(y).

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
q
\int
-infty

1dFY

infty
(y)-\int
q

1dFY(y).

The first term of the equation is

FY(q)

and second term of the equation is

1-FY(q)

. Therefore, the change of expected loss function is negative if and only if

FY(q)<0.5

, that is if and only if q is smaller than the median. Similarly, if we reduce q by 1 unit, the change of expected loss function is negative if and only if q is larger than the median.

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

100\tau

% of the points.

Sample quantile

The

\tau

sample quantile can be obtained by using an importance sampling estimate and solving the following minimization problem

\hat{q}\tau=\underset{q\inR

}\sum_^\rho_(y_-q),

=\underset{q\inR

} \left[(\tau-1)\sum_{y_{i}<q}(y_{i}-q)+\tau\sum_{y_{i}\geq q}(y_{i}-q) \right], where the function

\rho\tau

is the tilted absolute value function. The intuition is the same as for the population quantile.

Conditional quantile and quantile regression

The

\tau

th conditional quantile of

Y

given

X

is the

\tau

th quantile of theConditional probability distribution of

Y

given

X

,

QY|X(\tau)=inf\left\{y:FY|X(y)\geq\tau\right\}

.We use a capital

Q

to denote the conditional quantile to indicate that it is a random variable.

In quantile regression for the

\tau

th quantile we make the assumption that the

\tau

th conditional quantile is given as a linear function of the explanatory variables:

QY|X(\tau)=X\beta\tau

. Given the distribution function of

Y

,

\beta\tau

can be obtained by solving

\beta\tau=\underset{\beta\inRk

}E(\rho_(Y-X\beta)).

Solving the sample analog gives the estimator of

\beta

.

\hat{\beta\tau

}=\underset\sum_^(\rho_(Y_-X_\beta)) .

Note that when

\tau=0.5

, the loss function

\rho\tau

is proportional to the absolute value function, and thus median regression is the same as 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

\underset{\beta,u+,u-\inRk x

2n
R
+
}\left\,

where

+
u
j

=max(uj,0)

,   
-
u
j

=-min(uj,0).

Simplex methods or interior point methods can be applied to solve the linear programming problem.

Asymptotic properties

For

\tau\in(0,1)

, under some regularity conditions,

\hat{\beta}\tau

is asymptotically normal:

\sqrt{n}(\hat{\beta}\tau-\beta\tau)\overset{d}{}N(0,\tau(1-\tau)D-1\OmegaxD-1),

where

D=E(fY(X\beta)XX\prime)

and

\Omegax=E(X\primeX).

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.[9]

Equivariance

See invariant estimator for background on invariance or see equivariance.

Scale equivariance

For any

a>0

and

\tau\in[0,1]

\hat{\beta}(\tau;aY,X)=a\hat{\beta}(\tau;Y,X),

\hat{\beta}(\tau;-aY,X)=-a\hat{\beta}(1-\tau;Y,X).

Shift equivariance

For any

\gamma\inRk

and

\tau\in[0,1]

\hat{\beta}(\tau;Y+X\gamma,X)=\hat{\beta}(\tau;Y,X)+\gamma.

Equivariance to reparameterization of design

Let

A

be any

p x p

nonsingular matrix and

\tau\in[0,1]

\hat{\beta}(\tau;Y,XA)=A-1\hat{\beta}(\tau;Y,X).

Invariance to monotone transformations

If

h

is a nondecreasing function on

R

, the following invariance property applies:

h(QY|X(\tau))\equivQh(Y)|X(\tau).

Example (1):

If

W=\exp(Y)

and

QY|X(\tau)=X\beta\tau

, then

QW|X(\tau)=\exp(X\beta\tau)

. The mean regression does not have the same property since

\operatorname{E}(ln(Y))ln(\operatorname{E}(Y)).

Inference

Interpretation of the slope parameters

The linear model

QY|X(\tau)=X\beta\tau

mis-specifies the true systematic relation

QY|X(\tau)=f(X,\tau)

when

f(,\tau)

is nonlinear. However,

QY|X(\tau)=X\beta\tau

minimizes a weighted distanced to

f(X,\tau)

among linear models.[10] Furthermore, the slope parameters

\beta\tau

of the linear model can be interpreted as weighted averages of the derivatives

\nablaf(X,\tau)

so that

\beta\tau

can be used for causal inference.[11] Specifically, the hypothesis

H0:\nablaf(x,\tau)=0

for all

x

implies the hypothesis

H0:\beta\tau=0

, which can be tested using the estimator

\hat{\beta\tau

} and its limit distribution.

Goodness of fit

The goodness of fit for quantile regression for the

\tau

quantile can be defined as:[12]
2(\tau)=1-\hat{V
\tau}{\tilde{V}
R
\tau},
where

\hat{V}\tau

is the sum of squares of the conditional quantile, while

\tilde{V}\tau

is the sum of squares of the unconditional quantile.

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,[13] 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[14] provided a posterior variance adjustment for valid inference. In addition,Yang and He[15] 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[16]) 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,[17] [18] which is then referred to as nonparametric quantile regression.[19] Tree-based learning algorithms are also available for quantile regression (see, e.g., Quantile Regression Forests,[20] 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[21] and Wang and Wang[22]

Example (2):

Let

Yc=max(0,Y)

and

QY|X=X\beta\tau

. Then
Q
Yc|X

(\tau)=max(0,X\beta\tau)

. This is the censored quantile regression model: estimated values can be obtained without making any distributional assumptions, but at the cost of computational difficulty,[23] some of which can be avoided by using a simple three step censored quantile regression procedure as an approximation.[24]

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.

Heteroscedastic errors

The quantile regression loss needs to be adapted in the presence of heteroscedastic errors in order to be efficient.[25]

Implementations

Numerous statistical software packages include implementations of quantile regression:

See also

Literature

Notes and References

  1. Book: Koenker, Roger. Quantile Regression. limited. Cambridge University Press. 2005. 978-0-521-60827-5. 146–7.
  2. Brian S. . Cade . Barry R. . Noon . 2003 . A gentle introduction to quantile regression for ecologists . Frontiers in Ecology and the Environment . 1 . 8 . 412–420 . 10.2307/3868138. 3868138 .
  3. Wei . Y. . Pere . A. . Koenker . R. . He . X. . 2006 . Quantile Regression Methods for Reference Growth Charts . . 25 . 8 . 1369–1382 . 10.1002/sim.2271 . 16143984 . 7830193 .
  4. Wei . Y. . He . X.. Xuming He . 2006 . Conditional Growth Charts (with discussions) . . 34 . 5 . 2069–2097 and 2126–2131 . 10.1214/009053606000000623 . math/0702634 . 88516697 .
  5. Stigler . S. . 1984 . Boscovich, Simpson and a 1760 manuscript note on fitting a linear relation . Biometrika . 71 . 3 . 615–620 . 10.1093/biomet/71.3.615 .
  6. Book: Koenker, Roger. Quantile Regression. limited. Cambridge University Press. 2005. 9780521845731. Cambridge. 2.
  7. Book: Quantile Regression: Estimation and Simulation. Furno. Marilena. Vistocco. Domenico. John Wiley & Sons. 2018. 9781119975281. Hoboken, NJ. xv.
  8. Web site: Galton, Edgeworth, Frisch, and prospects for quantile regression in economics. Koenker. Roger. August 1998. UIUC.edu. August 22, 2018.
  9. Kocherginsky . M. . He . X. . Mu . Y. . 2005 . Practical Confidence Intervals for Regression Quantiles . . 14 . 1 . 41–55 . 10.1198/106186005X27563 . 120598656 .
  10. Angrist . J. . Chernozhukov . V. . Fernandez-Val . I.. 2006 . Quantile Regression under Misspecification, with an Application to the U.S. Wage Structure . . 74 . 2 . 539–563 . 10.1111/j.1468-0262.2006.00671.x .
  11. Kato . R. . Sasaki . Y. . 2017 . On Using Linear Quantile Regressions for Causal Inference . . 33 . 3 . 664–690 . 10.1017/S0266466616000177 . free .
  12. Roger Koenker & José A. F. Machado (1999) Goodness of Fit and Related Inference Processes for Quantile Regression, Journal of the American Statistical Association, 94:448, 1296-1310, DOI: 10.1080/01621459.1999.10473882
  13. Kozumi . H. . Kobayashi . G. . 2011 . Gibbs sampling methods for Bayesian quantile regression . . 81 . 11 . 1565–1578 . 10.1080/00949655.2010.496117 . 44015988 .
  14. Yang . Y. . Wang . H.X. . He . X.. 2016 . Posterior Inference in Bayesian Quantile Regression with Asymmetric Laplace Likelihood . . 84 . 3 . 327–344 . 10.1111/insr.12114 . 2027.42/135059 . 14947362 . free .
  15. Yang . Y. . He . X. . 2010 . Bayesian empirical likelihood for quantile regression . . 40 . 2 . 1102–1131 . 10.1214/12-AOS1005 . 1207.5378 . 88519086 .
  16. Steinwart . Ingo . Christmann . Andreas . Estimating conditional quantiles with the help of the pinball loss . Bernoulli . 17 . 1 . 211–225 . 2011 . Bernoulli Society for Mathematical Statistics and Probability . 10.3150/10-BEJ267 . 1102.2101 .
  17. Petneházi . Gábor . QCNN: Quantile Convolutional Neural Network . 2019-08-21 . 1908.07978 . cs.LG .
  18. Rodrigues . Filipe . Pereira . Francisco C. . Beyond expectation: Deep joint mean and quantile regression for spatio-temporal problems . 2018-08-27 . 1808.08798 . stat .
  19. 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
  20. Meinshausen . Nicolai . Quantile Regression Forests . Journal of Machine Learning Research . 7 . 6 . 983–999 . 2006 .
  21. Portnoy . S. L. . 2003 . Censored Regression Quantiles . . 98 . 464 . 1001–1012 . 10.1198/016214503000000954 . 120674851 .
  22. Wang . H. . Huixia Judy Wang . Wang . L. . 2009 . Locally Weighted Censored Quantile Regression . . 104 . 487 . 1117–1128 . 10.1198/jasa.2009.tm08230 . 10.1.1.504.796 . 34494316 .
  23. James L. . Powell . 1986 . Censored Regression Quantiles . . 32 . 1 . 143–155 . 10.1016/0304-4076(86)90016-3 .
  24. Victor . Chernozhukov . Han . Hong . Three-Step Censored Quantile Regression and Extramarital Affairs . . 97 . 459 . 872–882 . 2002 . 10.1198/016214502388618663 . 1410755 .
  25. Efficient Quantile Regression for HeteroscedasticModels by, Yoonsuh Jung, Yoonkyung Lee, Steven N. MacEachern, https://www.tandfonline.com/doi/abs/10.1080/00949655.2014.967244?journalCode=gscs20
  26. Web site: quantreg(x,y,tau,order,Nboot) - File Exchange - MATLAB Central. www.mathworks.com. 2016-02-01.
  27. Web site: Gretl Command Reference. April 2017. 2017-04-22. 2018-12-15. https://web.archive.org/web/20181215121225/http://ricardo.ecn.wfu.edu/pub//gretl/manual/en/gretl-ref.pdf. dead.
  28. Web site: quantreg: Quantile Regression . R Project . 2018-12-18.
  29. Web site: gbm: Generalized Boosted Regression Models . R Project . 2019-01-14.
  30. Web site: quantregForest: Quantile Regression Forests . R Project . 2017-12-19.
  31. Web site: qrnn: Quantile Regression Neural Networks . R Project . 2018-06-26.
  32. Web site: qgam: Smooth Additive Quantile Regression Models . R Project . 2019-05-23.
  33. Web site: Quantile Regression Forests . Scikit-garden . 3 January 2019.
  34. Web site: Statsmodels: Quantile Regression . Statsmodels . 15 November 2019.
  35. Web site: An Introduction to Quantile Regression and the QUANTREG Procedure . SAS Support .
  36. Web site: The QUANTSELECT Procedure . SAS Support .
  37. Web site: qreg — Quantile regression . Stata Manual .
  38. Book: A. Colin . Cameron . Pravin K. . Trivedi . Microeconometrics Using Stata . College Station . Stata Press . Revised . 2010 . 978-1-59718-073-3 . Quantile Regression . 211–234 . https://books.google.com/books?id=UkKQRAAACAAJ&pg=PA211 .
  39. Web site: JohnLangford/vowpal_wabbit. GitHub. 2016-07-09.
  40. Web site: QuantileRegression.m . MathematicaForPrediction . 3 January 2019.
  41. Web site: QuantileRegression . Wolfram Function Repository . 14 September 2022.