Skip to main content
v2026.11,858 entries · CC-BY 4.0
LAC HealthMedical & Research SuppliesReagents, PPE & instruments — chain-of-custody documented.Fast, traceable sourcing built for regulated research environments, from bench consumables to instrumentation.Shop lac.us CodeCASRAIlac.us

Quantile Regression Analysis: Formula, Interpretation, and Example

Quantile regression analysis explained: the check-loss formula, a hand-computed median and 90th-percentile example, interpretation, APA reporting, R and Python.

Written and maintained by CASRAI Editorial Board

Last updated

Quantile regression analysis models a chosen quantile of the outcome (the median, the 10th percentile, the 90th percentile) as a function of predictors, instead of modelling only the mean. After reading this page you should be able to state what a quantile regression coefficient means, compute a tiny example by hand, run the model in R or Python, and report it.

Definition: quantile regression, regression quantiles and median regression

Quantile regression estimates how a predictor shifts a specific quantile of the outcome, where the quantile is set by τ (tau), a number between 0 and 1. Koenker and Bassett (1978) introduced regression quantiles in Econometrica by extending sample quantiles from the simple location model to the linear regression model. Median regression is the special case τ = 0.5: it is the least absolute deviations (LAD) estimator, and it models the conditional median rather than the conditional mean. Ordinary least squares answers “how does the average outcome change with x?”; quantile regression can answer “how does the lowest-scoring tenth, the median, or the top tenth change with x?”

What does a quantile represent?

A quantile is the value below which a stated proportion of the data fall. The 0.9 quantile (90th percentile) is the value that 90% of observations do not exceed. See the CASRAI guide to percentiles and quantiles for the terminology.

Formula and every symbol

For a chosen τ, the coefficients minimise the sum of the check loss:

minimise over β: Σ ρτ(yᵢ − xᵢβ), where ρτ(u) = u · (τ − I(u < 0))

  • yᵢ: the outcome for observation i; xᵢ: its row of predictors (including the intercept); β: the coefficients for quantile τ.
  • u = yᵢ − xᵢβ: the residual.
  • I(u < 0): equals 1 when the residual is negative and 0 otherwise.
  • ρτ(u): weights positive residuals by τ and negative residuals by 1 − τ. At τ = 0.5 both weights are 0.5, so the loss is half the sum of absolute residuals.

Because the loss has a kink at zero, there is no closed-form solution; it is typically solved by linear programming, and the statsmodels documentation describes its QuantReg fit as iterative weighted least squares.

Worked example with the arithmetic shown

Take five observations: x = 1, 2, 3, 4, 5 and y = 2, 3, 5, 8, 20. The 20 is deliberately extreme.

Step 1: the check loss with no predictors

Try c = 5 as the fitted value at τ = 0.5. Residuals y − 5 are −3, −2, 0, 3, 15. Loss = 0.5 × (3 + 2 + 0 + 3 + 15) = 11.5. Trying c = 3 gives 12.5 and c = 8 gives 13.0, so the minimum is at the sample median, 5. At τ = 0.9, try c = 8: residuals are −6, −5, −3, 0, 12; the negative ones carry weight 0.1 and the positive one 0.9, so loss = 0.1 × 14 + 0.9 × 12 = 12.2. At c = 20 the residuals are −18, −17, −15, −12, 0 and the loss is 0.1 × 62 = 6.2, the lowest of the values tried: with five points the 0.9 quantile is the largest observation.

Step 2: the fitted lines

Solving the same minimisation with x included gives (checked with statsmodels QuantReg):

  • Median line (τ = 0.5): ŷ = −2.0 + 2.5x. Residuals are 1.5, 0, −0.5, 0, 9.5, so the sum of absolute residuals is 11.5 and the check loss is 0.5 × 11.5 = 5.75.
  • 90th-percentile line (τ = 0.9): ŷ = −2.5 + 4.5x. It passes exactly through (1, 2) and (5, 20); the other residuals are −3.5, −6, −7.5, giving loss = 0.1 × 17 = 1.7. The median line scores 0.9 × 11 + 0.1 × 0.5 = 9.95 on this same loss, which is why it is not the τ = 0.9 solution.
  • Ordinary least squares: ŷ = −4.7 + 4.1x.

The OLS slope (4.1) is pulled upward by the single value of 20; the median slope (2.5) is not. Each fitted line here passes exactly through two of the five points.

Interpretation: reading the coefficients

The UCLA OARC Stata FAQ (read 2026-11-07) notes that quantile regression coefficients read almost like ordinary regression coefficients, with the chosen quantile replacing the mean. Its hsb2 example: a binary predictor gave a median difference of 5 points and a 75th-percentile difference of 3, and a continuous predictor had a median slope of 0.6333 against 0.4 at the 75th percentile.

Result How to read it
Intercept at τ Predicted τ-quantile of the outcome when all predictors are 0 (with no predictors it equals the sample τ-quantile).
Slope at τ = 0.5 Change in the conditional median per one-unit increase in x, other predictors held fixed (median regression).
Slope at τ = 0.1 or 0.9 Change in the low or high end of the outcome distribution per unit of x. In the worked example the slope rises from 2.5 (median) to 4.5 (τ = 0.9).
Slopes that differ across τ x changes the spread or shape of the outcome, not just its centre; OLS would report only the mean effect.
Extreme value changed Per the UCLA FAQ, changing the top score from 67 to 670 left the median and 75th-percentile coefficients unchanged; only changes that cross a quantile boundary matter.

Assumptions and common mistakes

  • Linear conditional quantile. The model assumes the τ-quantile of y is linear in the predictors you include; inspect residual plots as you would for simple regression.
  • No normality or equal-variance assumption is required for the point estimates, which is the main reason to use it with skewed outcomes or unequal spread. Treat that as a modelling advantage, not a licence to skip diagnostics.
  • Mistake: reading the slope as a change in the mean. It is a change in a quantile.
  • Mistake: treating a quantile fit as an outlier fix. The median line resists the value of 20 above, but extreme points still matter when they cross a quantile boundary; see outliers in R.
  • Mistake: extreme τ with small samples. With n = 5, τ = 0.9 simply tracks the largest observations, as the example shows.
  • Mistake: confusing it with other “quantile” methods. Weighted quantile sum (WQS) regression, described below, is a different technique.

How to report it (APA style)

State the quantile(s) estimated, the software and function, the coefficients with a confidence interval or standard error for each τ, and how uncertainty was obtained. A template sentence: “Quantile regression was used to estimate the 10th, 50th and 90th percentiles of [outcome] as a function of [predictor] (τ = .10, .50, .90). The conditional-median slope was b = [value], 95% CI [lower, upper]; at τ = .90 it was b = [value], 95% CI [lower, upper].” Report the n, the software and package version, and say whether intervals are bootstrap or asymptotic.

How to calculate it in Excel, R or Python

R

The quantreg package’s rq(formula, tau = .5, data, ...) fits the model; tau defaults to 0.5 (the conditional median), and a vector of values returns one fit per quantile (rdocumentation.org, quantreg 5.99, read 2026-11-07).

library(quantreg)
d <- data.frame(x = 1:5, y = c(2, 3, 5, 8, 20))
fit <- rq(y ~ x, tau = c(0.5, 0.9), data = d)
summary(fit)

Python

import numpy as np, statsmodels.api as sm
x = np.array([1, 2, 3, 4, 5.]); y = np.array([2, 3, 5, 8, 20.])
X = sm.add_constant(x)
for q in (0.5, 0.9):
    print(q, sm.QuantReg(y, X).fit(q=q).params)

This returns intercept and slope of −2.0 and 2.5 at q = 0.5, and −2.5 and 4.5 at q = 0.9, matching the hand arithmetic. The statsmodels documentation notes that the LAD estimator is the special case q = 0.5. For the library itself see the statsmodels API guide.

Excel

Excel has no built-in quantile regression function. You can compute the check loss in a column exactly as in the worked example and let Solver minimise its total by changing the intercept and slope cells. The kinked objective is the reason dedicated software is the safer route for real data.

Frequently asked questions

How do you explain regression in simple terms?

Regression describes how an outcome changes as a predictor changes. Ordinary regression describes the average outcome; quantile regression describes a chosen point in the outcome distribution, such as the median or the top 10%.

What are the three types of logistic regression?

Binary (two outcome categories), multinomial (three or more unordered categories) and ordinal (ordered categories). They model categorical outcomes, unlike quantile regression, which models quantiles of a continuous outcome. See logistic regression in R.

What is weighted quantile sum regression?

WQS regression analyses mixtures of correlated predictors, such as chemical exposures. The exposures are ranked into quantiles (deciles in the gWQS package vignette), combined into an empirically weighted index, and that index enters a regression model (CRAN gWQS vignette, read 2026-11-07). It uses quantiles of the predictors; quantile regression models quantiles of the outcome.

Is median regression the same as quantile regression?

Median regression is quantile regression at τ = 0.5.

Sources

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · free to try

Ask about Quantile Regression Analysis: Formula, Interpretation, and Example

Ask your first 2 questions free below. Subscribers get 150 a day for $29 a month.

An AI assistant specialized in research administration. It cites the sources behind every answer, labels web answers and says when it can't answer.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays free to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →