Skip to main content

Quantile Regression: Who Pays More for a Home, the Cheap End or the Expensive End?

Quantile regression in R with quantreg::rq(), on a year of house sales in England and Wales from the HM Land Registry Price Paid Data: why the mean is not the whole story, the check (pinball) loss, fitting at several quantiles, standard error methods, coefficients across quantiles against OLS, testing equal slopes, quantile crossing, log outcomes, robustness to outliers and APA reporting.

The question: what a home costs depends on where you look in the market

A detached house costs more than a terraced house, and a home in London costs more than one elsewhere. Everybody knows that. The question for this page is: by how much, and is it the same amount for cheap homes and for expensive ones?

An ordinary regression (OLS) answers with one number per predictor: the difference in the mean price. But house prices are strongly skewed: most homes sell for a modest sum and a few sell for millions. A predictor can move the cheap end of the market by a little, the middle by more, and the expensive end by far more. The mean blends all of that into one figure that describes nobody in particular.

Quantile regression (Koenker & Bassett, 1978) fits a separate line for any quantile of the outcome: the 10th percentile (the cheapest tenth of homes), the median, the 90th percentile, and so on. The model is a family of regressions, one for each quantile \(\tau\) (the Greek letter tau):

Quantile \(\tau\) What the line describes In this example
0.1 the lower tail the price below which 10% of comparable homes sell
0.5 the median the middle price
0.9 the upper tail the price below which 90% of comparable homes sell

Where a predictor’s coefficient is the same at every \(\tau\), it only shifts the distribution. Where it changes with \(\tau\), the predictor changes the shape of the distribution: its spread, its skew.

Code
library(quantreg)   # rq(): quantile regression
library(ggplot2)

# the site's colors, in order
blue <- "#2a78d6"; orange <- "#eb6834"; green <- "#1baf7a"; yellow <- "#eda100"; pink <- "#e87ba4"

# number formats for the text
f0   <- function(x) formatC(x, format = "f", digits = 0, big.mark = ",")
f1   <- function(x) formatC(x, format = "f", digits = 1, big.mark = ",")
f2   <- function(x) formatC(x, format = "f", digits = 2, big.mark = ",")
nz   <- function(x, d = 2) sub("^(-?)0", "\\1", formatC(x, format = "f", digits = d))   # no leading zero
pval <- function(p) if (p < .001) "< .001" else paste("=", nz(p, 3))
pct  <- function(x, d = 0) paste0(formatC(100 * x, format = "f", digits = d), "%")
num  <- function(x) trimws(format(x, big.mark = ","))
k    <- function(x) paste0(ifelse(x < 0, "-", ""), "£", f0(abs(x)), "k")   # a price in thousands of pounds, for the text

1. The data

HM Land Registry, the government register of property ownership in England and Wales, publishes the Price Paid Data: one row for every residential sale registered since 1995, free, with no login, under the Open Government Licence v3.0. The yearly files are large (about 170 MB each), so this page uses the small monthly update file, the sales registered with the Land Registry in the latest month.

Code
url  <- "https://price-paid-data.publicdata.landregistry.gov.uk/pp-monthly-update-new-version.csv"
file <- tempfile(fileext = ".csv")
download_time <- system.time(download.file(url, file, mode = "wb", quiet = TRUE))[["elapsed"]]
file_mb <- file.size(file) / 1e6

The download is 17.1 MB and took 0.2 seconds. The file has no header row. The columns are documented on the Land Registry’s about the Price Paid Data page, and we read only the ones we need:

Column Meaning (from the documentation)
2 Price: the sale price stated on the transfer deed, in pounds
3 Date of transfer: when the sale was completed, as stated on the deed
5 Property type: D detached, S semi-detached, T terraced (including end-of-terrace), F flat or maisonette, O other. Bungalows are not separate
6 Old/new: Y a newly built property, N an established one
14 County
15 PPD category: A a standard sale of a single residential property; B additional transactions, such as repossessions, buy-to-lets identified by a mortgage and transfers to non-private individuals
16 Record status (monthly file only): A added, C changed, D deleted
Code
columns <- rep("NULL", 16)                      # "NULL" skips a column
columns[c(2, 3, 5, 6, 14, 15, 16)] <- "character"
raw <- read.csv(file, header = FALSE, colClasses = columns)
names(raw) <- c("price", "date", "type", "new", "county", "category", "status")
nrow(raw)
[1] 98103
Code
table(raw$status)

    A     C     D 
93495  3056  1552 

The file holds 98,103 rows. We keep what the question needs:

Code
raw$date <- as.Date(substr(raw$date, 1, 10))
homes <- subset(raw, status == "A" &                          # added records, not changes or deletions
                  category == "A" &                           # standard sales of a single home
                  type %in% c("T", "F", "S", "D") &           # the four named types of home
                  date > max(date) - 365)                     # sales completed in the last 12 months

homes$k      <- as.numeric(homes$price) / 1000                # price in £ thousand
homes$type   <- factor(homes$type, levels = c("T", "F", "S", "D"),
                       labels = c("Terraced", "Flat", "Semi-detached", "Detached"))
homes$new    <- factor(homes$new, levels = c("N", "Y"), labels = c("Established", "New build"))
homes$london <- factor(ifelse(homes$county == "GREATER LONDON", "London", "Elsewhere"),
                       levels = c("Elsewhere", "London"))
n <- nrow(homes)

That leaves 73,902 sales completed between 01 October 2025 and 30 September 2026 (61% of them in the last two months, because sales are registered some weeks after completion). The three predictors:

  • type: the type of home, with terraced as the reference, because it is the most common type;
  • new: newly built or established;
  • london: in Greater London, or elsewhere in England and Wales.
  • the outcome k is the price in thousands of pounds, so a coefficient of 50 means £50,000.
Code
table(homes$type, homes$london)
               
                Elsewhere London
  Terraced          17611   2258
  Flat               7637   3926
  Semi-detached     21311   1283
  Detached          19492    384

What these data cannot say. The Price Paid Data has no floor area, number of bedrooms, condition or street-level location. A detached house in the data is bigger than a terraced one, and the coefficient on type includes that. Nor does one monthly file cover all sales in England and Wales in a year: it holds the ones registered in one month, which is a large and mixed set, but not a random sample of the year. This page is a worked example of a method, not a house price index.


2. Look at the data

Code
mean_k   <- mean(homes$k)
median_k <- median(homes$k)

ggplot(homes, aes(k)) +
  geom_histogram(binwidth = 25, boundary = 0, fill = "grey80", colour = "grey50") +
  geom_vline(aes(xintercept = median_k, colour = "Median", linetype = "Median"), linewidth = 0.9) +
  geom_vline(aes(xintercept = mean_k, colour = "Mean", linetype = "Mean"), linewidth = 0.9) +
  scale_colour_manual(values = c(Median = blue, Mean = orange)) +
  scale_linetype_manual(values = c(Median = "solid", Mean = "dashed")) +
  coord_cartesian(xlim = c(0, 1500)) +
  labs(title = "Sale prices of homes, England and Wales",
       subtitle = "The chart stops at £1.5 million",
       x = "price (£ thousand)", y = "sales", colour = NULL, linetype = NULL) +
  theme_bw() +
  theme(legend.position = "bottom")

Look histogram – 2. Look at the data

Code
qs <- quantile(homes$k, c(.1, .5, .9, .99))
over <- mean(homes$k > 1500)

Prices pile up on the left and trail off to the right. The median is £300k, the mean £376k: a few very expensive sales pull the mean up. The cheapest tenth of homes sold for up to £145k, and the dearest tenth for £653k or more. The chart cuts off 1.1% of the sales, those above £1.5 million; the dearest sale in the data is £25,400k.

The skew matters because the London gap is not one number. The same quantiles in the two areas:

Code
taus <- seq(.05, .95, by = .05)
by_area <- do.call(rbind, lapply(levels(homes$london), function(a)
  data.frame(area = a, tau = taus, price = quantile(homes$k[homes$london == a], taus, names = FALSE))))
by_area$area <- factor(by_area$area, levels = c("Elsewhere", "London"))

ggplot(by_area, aes(tau, price, colour = area)) +
  geom_line(linewidth = 0.9) +
  geom_point(size = 1.6) +
  scale_colour_manual(values = c(Elsewhere = blue, London = orange)) +
  scale_x_continuous(breaks = seq(0, 1, 0.1)) +
  labs(title = "Sale price quantiles, London and elsewhere",
       x = expression("quantile " * tau), y = "price (£ thousand)", colour = NULL) +
  theme_bw() +
  theme(legend.position = "bottom")

Look gap – 2. Look at the data

Code
q_area <- tapply(homes$k, homes$london, quantile, probs = c(.1, .5, .9))

At the 10th percentile, a London home sells for £295k against £140k elsewhere, a difference of £155k. At the median the difference is £246k, and at the 90th percentile £670k. The London premium grows steadily from the bottom of the market to the top. An OLS coefficient would report one number, somewhere in the middle of those, and say nothing about this.

These are the raw differences. Quantile regression does the same thing while holding the type of home, and whether it is new, fixed.


3. The model step by step, with formulas

Step 1: one line per quantile

For a quantile \(\tau\) between 0 and 1, the model says that the \(\tau\)-th quantile of the price, given the predictors \(x_i\), is a linear function of them:

\[Q_\tau(y_i \mid x_i) = \beta_0(\tau) + \beta_1(\tau)\,x_{i1} + \dots + \beta_p(\tau)\,x_{ip}\]

The coefficients carry \((\tau)\) because each quantile has its own. The conditional quantile \(Q_\tau(y_i \mid x_i)\) is the price below which a fraction \(\tau\) of the homes with these characteristics sell. OLS models the conditional mean, \(E(y_i \mid x_i)\), in the same way, with one set of coefficients.

Step 2: the check (pinball) loss

OLS finds the coefficients that minimize the sum of squared residuals. Quantile regression minimizes a different sum, with the check loss (also called the pinball loss because of its shape). For a residual \(u = y - \hat y\):

\[\rho_\tau(u) = u\,\bigl(\tau - I(u < 0)\bigr) = \begin{cases} \tau\,u & \text{if } u \ge 0 \text{ (the price is above the line)}\\ (\tau - 1)\,u = (1-\tau)\,|u| & \text{if } u < 0 \text{ (the price is below the line)}\end{cases}\]

where \(I(u < 0)\) is 1 when the residual is negative and 0 otherwise. The coefficients are

\[\hat\beta(\tau) = \arg\min_{\beta} \sum_{i=1}^{n} \rho_\tau\bigl(y_i - x_i^\top \beta\bigr)\]

The loss is a pair of straight lines: a point above the fitted line costs \(\tau\) per unit of distance, a point below it costs \(1-\tau\). Three cases:

  • \(\tau = 0.5\): both sides cost 0.5, so the loss is half the absolute residual, \(\tfrac12|u|\). This is median regression, or least absolute deviations (LAD): the line that minimizes the sum of the absolute residuals.
  • \(\tau = 0.9\): a point above the line costs 0.9, a point below costs only 0.1. The line is pushed up until 90% of the points are below it.
  • \(\tau = 0.1\): the reverse: the line is pushed down until 10% of the points are below it.

Step 3: why minimizing it gives the quantile

Start with no predictors, only a single number \(c\) as the fit. The expected loss is

\[E\,\rho_\tau(y - c) = (\tau - 1)\int_{-\infty}^{c} (y - c)\,dF(y) + \tau \int_{c}^{\infty} (y - c)\,dF(y)\]

where \(F\) is the distribution function of \(y\). Differentiating with respect to \(c\) gives

\[\frac{d}{dc}\,E\,\rho_\tau(y - c) = (1 - \tau)\,F(c) - \tau\,\bigl(1 - F(c)\bigr) = F(c) - \tau\]

which is zero when \(F(c) = \tau\): the value \(c\) below which a fraction \(\tau\) of the data lies, which is the \(\tau\)-th quantile. In the same way, squared loss gives the mean, and absolute loss gives the median. A small numeric check with 11 real sales, drawn at random from the data:

Code
rho <- function(u, tau) u * (tau - (u < 0))     # the check loss

set.seed(2026)
few    <- sort(sample(homes$k, 11))
cand   <- seq(0, max(few) * 1.05, length.out = 1500)
tau_set <- c(0.1, 0.5, 0.9)

loss <- do.call(rbind, lapply(tau_set, function(t)
  data.frame(tau = t, c = cand, loss = sapply(cand, function(cc) mean(rho(few - cc, t))))))
best <- do.call(rbind, lapply(tau_set, function(t)
  data.frame(tau = t, c = loss$c[loss$tau == t][which.min(loss$loss[loss$tau == t])],
             loss = min(loss$loss[loss$tau == t]))))
best$quantile <- sapply(tau_set, function(t) quantile(few, t, type = 1, names = FALSE))
best
  tau        c      loss quantile
1 0.1 206.4977  9.904112    206.5
2 0.5 240.0150 38.089319    240.0
3 0.9 390.2652 23.584683    390.0
Code
loss$panel <- factor(paste("τ =", loss$tau), levels = paste("τ =", tau_set))
best$panel <- factor(paste("τ =", best$tau), levels = paste("τ =", tau_set))
pts <- do.call(rbind, lapply(tau_set, function(t)
  data.frame(panel = paste("τ =", t), x = few)))
pts$panel <- factor(pts$panel, levels = paste("τ =", tau_set))

ggplot(loss, aes(c, loss)) +
  geom_line(colour = blue, linewidth = 0.9) +
  geom_point(data = best, colour = orange, size = 3) +
  geom_rug(data = pts, aes(x = x, y = NULL), colour = "grey35", sides = "b") +
  facet_wrap(~ panel, scales = "free_y") +
  labs(title = "Average check loss for a single fitted value c",
       subtitle = "Orange: the lowest point. Grey ticks: the 11 sale prices.",
       x = "c, the fitted price (£ thousand)", y = "average check loss") +
  scale_x_continuous(expand = expansion(mult = c(0.03, 0.08))) +
  theme_bw() +
  theme(panel.spacing.x = unit(1, "lines"))

Pinball chart – Step 3: why minimizing it gives the quantile

The loss curve is made of straight pieces that bend at the data points, and its lowest point (orange) sits on a data value: £206k for \(\tau\) = 0.1, £240k for the median and £390k for \(\tau\) = 0.9. Those are the 10th, 50th and 90th percentiles of the 11 prices (£206k, £240k and £390k). The same check on all 73,902 sales, by trying every candidate price on a fine grid:

Code
grid <- seq(0, 1500, by = 0.5)
by_search <- sapply(tau_set, function(t) grid[which.min(sapply(grid, function(cc) mean(rho(homes$k - cc, t))))])
rbind(`minimising the loss` = by_search,
      `quantile()` = quantile(homes$k, tau_set, type = 1, names = FALSE))
                    [,1] [,2] [,3]
minimising the loss  145  300  653
quantile()           145  300  653

Step 4: how the line is found

The check loss has a corner at zero, so there is no formula like the normal equations of OLS. rq() solves the problem as a linear program (the Barrodale and Roberts simplex algorithm, method = "br", the default), which is fast for samples up to a few thousand rows; for very large data method = "fn" (an interior point method) is quicker. When the minimum is a flat stretch rather than a single point, as happens when many prices are the same round number, R warns “Solution may be nonunique”. The warning is harmless here: any value on the flat stretch fits equally well.

Step 5: what the coefficients mean

\(\beta_j(\tau)\) is the change in the \(\tau\)-th conditional quantile of the price when \(x_j\) goes up by one unit, with the other predictors fixed. With a categorical predictor, it is the difference between the \(\tau\)-th quantiles of the two groups, adjusting for the other predictors. Section 7 spells out what this does and does not mean.


4. Fitting the model and reading the output

The model is k ~ type + new + london. rq() takes a formula, the data and the quantile or quantiles in tau:

Code
f <- k ~ type + new + london

fit_ols <- lm(f, data = homes)
fit10   <- rq(f, tau = 0.1, data = homes)
fit50   <- rq(f, tau = 0.5, data = homes)
fit90   <- rq(f, tau = 0.9, data = homes)
summary(fit50, se = "nid")

Call: rq(formula = f, tau = 0.5, data = homes)

tau: [1] 0.5

Coefficients:
                  Value     Std. Error t value   Pr(>|t|) 
(Intercept)       229.50000   1.21415  189.02077   0.00000
typeFlat          -59.50000   1.91511  -31.06868   0.00000
typeSemi-detached  40.49900   1.58774   25.50729   0.00000
typeDetached      190.50000   1.95280   97.55209   0.00000
newNew build       29.20400   2.23098   13.09024   0.00000
londonLondon      310.50000   3.80080   81.69333   0.00000

The output looks like lm(): Value is the coefficient, then its standard error, t and p. The intercept is the median price of the reference home: an established terraced house elsewhere in England and Wales (the £230k, which is also the median of that group). The other lines are the differences from it:

Code
coefs <- cbind(`τ = 0.1` = coef(fit10), `τ = 0.5` = coef(fit50), `τ = 0.9` = coef(fit90), OLS = coef(fit_ols))
round(coefs, 1)
                  τ = 0.1 τ = 0.5 τ = 0.9    OLS
(Intercept)           120   229.5   415.0  260.9
typeFlat              -42   -59.5   -89.6 -101.7
typeSemi-detached      40    40.5    65.0   45.1
typeDetached          130   190.5   410.0  247.1
newNew build           50    29.2    -1.8    8.5
londonLondon          205   310.5   799.6  475.9
Code
b10 <- coef(fit10); b50 <- coef(fit50); b90 <- coef(fit90); bo <- coef(fit_ols)
\(\tau\) = 0.1 Median \(\tau\) = 0.9 OLS (mean)
Detached (against terraced) £130k £190k £410k £247k
Flat (against terraced) -£42k -£60k -£90k -£102k
London (against elsewhere) £205k £310k £800k £476k
New build (against established) £50k £29k -£2k £8k
  • London. The London difference is £205k in the cheap end of the market, £310k at the median and £800k in the expensive end: about 3.9 times bigger at the top than at the bottom. OLS reports £476k, a number that is not the London difference for any group of homes: it is above the median difference because the mean follows the long right tail.
  • Detached. A detached house costs £130k more than a terraced one at \(\tau\) = 0.1, £190k more at the median and £410k more at \(\tau\) = 0.9.
  • New build. This is where the mean misleads the most. The new-build difference is £50k in the cheap end, £29k at the median, and -£2k at \(\tau\) = 0.9: new homes sell for more than established ones at the bottom of the market, and for a little less at the top. OLS says £8k, which hides the sign change. The data cannot say why: they have no information on size or exact location, which may differ between new and established homes.
  • Flat. Flats are cheaper than terraced houses, by £42k at \(\tau\) = 0.1 and £90k at \(\tau\) = 0.9.

All the models here have categorical predictors only. The fitted lines are then the quantiles of price within each combination of type, new and London, tied together by the model’s additive form (no interactions). With a continuous predictor, such as floor area, each \(\tau\) would give a slope instead of a gap: the reading is the same.

Three ways to calculate the standard errors

summary.rq() offers several methods for the standard errors, set with se =:

se = The idea When it fits
"iid" Assumes the errors have the same distribution for every observation: one common density at the quantile Only if the spread of the outcome is the same for all values of the predictors. Not here
"nid" A sandwich estimator (Hendricks & Koenker, 1992) that allows the density at the quantile to differ from one observation to the next. The default for samples above 1,000 The usual choice with heteroscedastic data
"ker" A sandwich estimator that estimates the density with a kernel (Powell, 1991) An alternative to "nid"
"boot" Bootstrap: resample the rows with replacement (the default bsmethod = "xy" resamples (x, y) pairs), refit, and take the standard deviation of the estimates Needs no density at all, but slow: each bootstrap sample is a new fit

The standard error of a quantile depends on how thinly the data are spread around that quantile, since a coefficient is more uncertain where observations are sparse. The sandwich methods estimate this density, and "iid" takes it to be the same everywhere, which is wrong when the spread of price differs between London and elsewhere. A comparison on a random subsample of 5,000 sales (a bootstrap of the full 73,902 sales would be much slower), at \(\tau\) = 0.9:

Code
set.seed(2026)
sub   <- homes[sample(n, 5000), ]
fit_s <- rq(f, tau = 0.9, data = sub)
se_methods <- sapply(c("iid", "nid", "ker", "boot"), function(m) {
  s <- if (m == "boot") summary(fit_s, se = m, R = 200) else summary(fit_s, se = m)
  s$coefficients[, "Std. Error"]
})
round(se_methods, 1)
                   iid  nid  ker boot
(Intercept)       15.5  8.8  9.5  9.5
typeFlat          25.9 19.0 15.5 18.3
typeSemi-detached 21.1 16.8 17.2 16.3
typeDetached      22.3 21.6 21.6 24.6
newNew build      34.0 36.3 23.0 33.9
londonLondon      27.3 77.5 70.0 80.9

For the London coefficient the standard error is 27.3 with "iid" and 77.5 with "nid", 70.0 with "ker" and 80.9 with the bootstrap. "iid" is 2.8 times too small: London prices are much more spread out than prices elsewhere, which the "iid" method does not allow. The three methods that allow unequal spread are in the same range for London, but they do not agree exactly: for the new-build coefficient the standard errors run from 23.0 to 36.3. The bootstrap makes the fewest assumptions. A quick rule: use "nid" for large samples (it is the default) and "boot" for the final results of a smaller study, with a larger R (1,000 or more).

The rest of the page uses "nid" on the full data.


5. The classic chart: coefficients across the quantiles

Three quantiles tell the story in a table. The whole story is a chart: fit the model at 19 quantiles from \(\tau\) = 0.05 to 0.95, and draw each coefficient against \(\tau\), with its 95% confidence band. The OLS estimate, with its interval, is a single horizontal line: if the quantile coefficients stay near the OLS line, the mean tells the story; if they drift away from it, it does not.

Code
fits_path <- rq(f, tau = taus, data = homes)
sums_path <- summary(fits_path, se = "nid")

names_short <- c(typeFlat = "Flat (vs terraced)", `typeSemi-detached` = "Semi-detached (vs terraced)",
                 typeDetached = "Detached (vs terraced)", `newNew build` = "New build (vs established)",
                 londonLondon = "London (vs elsewhere)")
terms <- names(names_short)

path <- do.call(rbind, lapply(seq_along(taus), function(i) {
  cm <- sums_path[[i]]$coefficients[terms, , drop = FALSE]
  data.frame(tau = taus[i], term = terms, est = cm[, "Value"],
             lo = cm[, "Value"] - qnorm(.975) * cm[, "Std. Error"],
             hi = cm[, "Value"] + qnorm(.975) * cm[, "Std. Error"])
}))
path$term <- factor(names_short[path$term], levels = names_short)

ols_ci  <- confint(fit_ols)
ols_ref <- data.frame(term = factor(names_short, levels = names_short),
                      est = coef(fit_ols)[terms], lo = ols_ci[terms, 1], hi = ols_ci[terms, 2])

ggplot(path, aes(tau)) +
  geom_rect(data = ols_ref, aes(xmin = -Inf, xmax = Inf, ymin = lo, ymax = hi, fill = "OLS (mean)"),
            alpha = 0.18, inherit.aes = FALSE) +
  geom_hline(data = ols_ref, aes(yintercept = est, colour = "OLS (mean)"), linetype = "dashed", linewidth = 0.8) +
  geom_ribbon(aes(ymin = lo, ymax = hi, fill = "Quantile regression"), alpha = 0.25) +
  geom_line(aes(y = est, colour = "Quantile regression"), linewidth = 0.9) +
  geom_point(aes(y = est, colour = "Quantile regression"), size = 1.4) +
  facet_wrap(~ term, scales = "free_y", ncol = 3) +
  scale_colour_manual(values = c(`Quantile regression` = blue, `OLS (mean)` = orange)) +
  scale_fill_manual(values = c(`Quantile regression` = blue, `OLS (mean)` = orange)) +
  scale_x_continuous(breaks = c(0.1, 0.5, 0.9)) +
  labs(title = "How each coefficient changes along the price distribution",
       subtitle = "Bands: 95% confidence intervals (standard errors by nid)",
       x = expression("quantile " * tau), y = "difference in price (£ thousand)",
       colour = NULL, fill = NULL) +
  theme_bw() +
  theme(legend.position = "bottom")

Coef path – 5. The classic chart: coefficients across the quantiles

(The base R version is plot(summary(rq(f, tau = taus, data = homes))), which draws the same panels, with the OLS line in red.) Reading the panels:

Code
p <- function(term, t) path$est[path$term == names_short[[term]] & abs(path$tau - t) < 1e-9]
inside <- tapply(seq_len(nrow(path)), path$term, function(i) {
  o <- ols_ref[ols_ref$term == path$term[i[1]], ]
  mean(path$est[i] >= o$lo & path$est[i] <= o$hi)
})
  • London and Detached: the coefficient climbs steadily with \(\tau\), from £170k and £121k at \(\tau\) = 0.05 to £1,105k and £545k at \(\tau\) = 0.95. The OLS line cuts across the middle and describes none of the ends.
  • New build: the coefficient falls from £55k at \(\tau\) = 0.05 to -£10k at \(\tau\) = 0.95, and first drops below zero at \(\tau\) = .90. OLS is a small positive number, £8k, for all.
  • Flat: the gap against terraced homes widens from £32k to £90k. The OLS gap, £102k, is bigger than the quantile gap at 19 of the 19 quantiles: here the mean gap is larger than the gap at the quantiles, because the few very dear sales pull the mean.
  • Semi-detached: changes least. It is £40k at \(\tau\) = 0.05 and £40k at the median, and rises only in the top tail, to £95k at \(\tau\) = 0.95. For most of the market, OLS (£45k) is not misleading for this predictor.

The confidence bands widen at the extremes: there are fewer observations near the 5th and 95th percentiles to pin the line down. Remember that the bands are for each \(\tau\) separately; they are not a simultaneous band for the whole curve.


6. Do the slopes differ across quantiles?

The chart suggests that they do. anova() on rq fits at several quantiles tests it (Koenker & Bassett, 1982): the null hypothesis is that the coefficients of the predictors are the same at every \(\tau\) in the set, which is the pure location-shift model in which the predictors move the whole distribution up or down by the same amount and leave its shape alone.

Code
test_joint <- anova(fit10, fit50, fit90)
test_joint
Quantile Regression Analysis of Deviance Table

Model: k ~ type + new + london
Joint Test of Equality of Slopes: tau in {  0.1 0.5 0.9  }

  Df Resid Df F value    Pr(>F)    
1 10   221696   419.3 < 2.2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
test_terms <- anova(fit10, fit50, fit90, joint = FALSE)
test_terms
Quantile Regression Analysis of Deviance Table

Model: k ~ type + new + london
Tests of Equality of Distinct Slopes: tau in {  0.1 0.5 0.9  }

                  Df Resid Df  F value    Pr(>F)    
typeFlat           2   221704   77.187 < 2.2e-16 ***
typeSemi-detached  2   221704   25.654 7.239e-12 ***
typeDetached       2   221704 1160.060 < 2.2e-16 ***
newNew build       2   221704   41.665 < 2.2e-16 ***
londonLondon       2   221704  658.493 < 2.2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

The first test is a joint test of all five predictors at the three quantiles (10 restrictions: each predictor’s coefficient at \(\tau\) = 0.1 and at 0.9 equal to the median’s): F(10, 221,696) = 419.3, p < .001. The slopes are not the same at the three quantiles. The second test takes one predictor at a time: all five are significant, with the largest statistics for Detached (vs terraced) (1,160.1) and London (vs elsewhere) (658.5), and the smallest for Semi-detached (vs terraced) (25.7).

Two cautions. With 73,902 sales, even a small difference is “significant”, so the size of the differences (the chart) matters more than the p value. And the test compares only the quantiles you give it: a set of \(\tau\) values such as 0.1, 0.5 and 0.9 can miss differences elsewhere.


7. Interpretation: a conditional quantile effect

A coefficient at \(\tau\) = 0.9 is easy to misread. It is not “the effect of being in London on the people at the top of the market”. Two ideas separate:

  • A conditional quantile is a quantile of price among homes that share the same values of the predictors. \(\beta_{\text{London}}(0.9)\) is the gap between the 90th percentile of London homes and the 90th percentile of the other homes of the same type and age. A 90th-percentile London flat is not the same home as a 90th-percentile detached house elsewhere: “the top” is defined within each group of comparable homes.
  • An unconditional quantile is a quantile of the whole market: the dearest 10% of all sales in the country, whatever their type or location. A coefficient at \(\tau\) = 0.9 does not say what would happen to the dearest 10% of the whole market if the predictor changed. That is a different question, with a different method (Firpo et al., 2009).

In plain words: the median regression tells you how the typical London home compares with the typical home elsewhere, and the 90th percentile regression tells you how an expensive London home compares with an expensive home elsewhere. Nothing is said about individual homes: a person who buys at the 90th percentile of a cheap area does not move to the 90th percentile of London by moving there.

The numbers are also differences between groups, not changes in a home: the Price Paid Data holds one sale per home, so the coefficients describe how the groups differ, not what would happen to a given house if it were in London.

A chart of the model’s predictions for six typical homes, all established, makes the point concrete: the middle 80% of the predicted prices (from \(\tau\) = 0.1 to 0.9) with the median and, for contrast, the OLS mean.

Code
cases <- expand.grid(type = c("Terraced", "Flat", "Detached"), london = c("Elsewhere", "London"),
                     stringsAsFactors = FALSE)
cases$new    <- "Established"
cases$type   <- factor(cases$type, levels = levels(homes$type))
cases$new    <- factor(cases$new, levels = levels(homes$new))
cases$london <- factor(cases$london, levels = levels(homes$london))
cases$label  <- paste0(cases$type, ", ", ifelse(cases$london == "London", "London", "elsewhere"))
cases <- cases[order(cases$london, match(cases$type, c("Flat", "Terraced", "Detached"))), ]

pred <- data.frame(label = cases$label,
                   q10 = predict(fit10, cases), q50 = predict(fit50, cases), q90 = predict(fit90, cases),
                   mean = predict(fit_ols, cases))
pred$label <- factor(pred$label, levels = rev(pred$label))
round(pred[, -1], 0)
  q10 q50  q90 mean
2  78 170  325  159
1 120 230  415  261
3 250 420  825  508
5 283 480 1125  635
4 325 540 1215  737
6 455 730 1625  984
Code
ggplot(pred, aes(y = label)) +
  geom_linerange(aes(xmin = q10, xmax = q90), colour = "grey55", linewidth = 2.2, alpha = 0.6) +
  geom_point(aes(x = q50, colour = "Median"), size = 3.2) +
  geom_point(aes(x = mean, colour = "Mean (OLS)"), size = 3.2, shape = 18) +
  scale_colour_manual(values = c(Median = blue, `Mean (OLS)` = orange)) +
  labs(title = "Predicted prices of six typical homes",
       subtitle = "Grey bar: the 10th to the 90th percentile of the quantile regression",
       x = "price (£ thousand)", y = NULL, colour = NULL) +
  theme_bw() +
  theme(legend.position = "bottom")

Predict – 7. Interpretation: a conditional quantile effect

The gray bars say what OLS cannot: the range of prices to expect. A detached home in London has a predicted median of £730k, and the middle 80% of its predicted prices runs from £455k to £1,625k; a flat elsewhere is far tighter, from £78k to £325k. The OLS mean for the detached home in London, £984k, is above the median: the mean is pulled up by the right tail.

How well do the fitted lines do their job? By definition, a fraction \(\tau\) of the sales should lie below the line at \(\tau\). The check:

Code
below <- sapply(list(fit10, fit50, fit90), function(m) mean(homes$k < fitted(m)))
setNames(round(below, 3), c("τ = 0.1", "τ = 0.5", "τ = 0.9"))
τ = 0.1 τ = 0.5 τ = 0.9 
  0.097   0.499   0.899 

The shares below the lines are 9.7%, 49.9% and 89.9%, close to 10%, 50% and 90% (not exactly so because many prices are round numbers, such as £250,000, and tie with the fitted values).


8. Practical points

Quantile crossing

The quantile of 0.9 must never be below the quantile of 0.8, but separate fits do not know that. With a continuous predictor, the fitted lines can cross, usually at extreme values of the predictor, and then give an impossible prediction: a 90th percentile lower than the 80th. Crossing signals that the linear model is wrong for that part of the data, or that the extrapolation goes too far.

Code
fit_ends <- rq(f, tau = c(0.01, 0.99), data = homes)
all_taus <- c(0.01, taus, 0.99)
B <- cbind(coef(fit_ends)[, 1], coef(fits_path), coef(fit_ends)[, 2])
all_cells <- expand.grid(type = levels(homes$type), new = levels(homes$new), london = levels(homes$london))
pred_all  <- model.matrix(~ type + new + london, all_cells) %*% B      # one row per kind of home, one column per tau
crossings <- sum(apply(pred_all, 1, function(x) any(diff(x) < 0)))

I checked all 16 combinations of type, new and London at 21 quantiles from 0.01 to 0.99: 0 of them have crossing quantiles. Crossing here is unlikely, because the predictors are categorical and every combination has many sales. If it does happen, the usual remedies are to fit a simpler model, to restrict predictions to the range of the data, or to rearrange: sort the predicted quantiles of each case into increasing order, which can only improve the estimates (Chernozhukov et al., 2010). In R, sort() on the row of predictions does it.

A log outcome, and back-transformation

Prices are often analyzed on the log scale: then the coefficients are percentages and the skew is much smaller. For quantiles the log scale has a special property. Quantiles commute with monotone transformations; means do not:

\[Q_\tau\bigl(\log y\bigr) = \log Q_\tau(y) \qquad\text{but}\qquad E\bigl(\log y\bigr) \ne \log E(y)\]

The median of the logs is the log of the median. The mean of the logs is the log of the geometric mean, which is smaller than the mean. So a quantile regression of \(\log y\) can be back-transformed with exp() and gives a quantile of the price itself, whereas back-transforming an OLS of \(\log y\) gives the geometric mean (or, with a “smearing” correction, an estimate of the mean that depends on the distribution of the errors).

Code
c(`log of the median` = log(median(homes$k)), `median of the logs` = median(log(homes$k)),
  `log of the mean` = log(mean(homes$k)), `mean of the logs` = mean(log(homes$k)))
 log of the median median of the logs    log of the mean   mean of the logs 
          5.703782           5.703782           5.930437           5.720243 
Code
f_log   <- log(k) ~ type + new + london
log_fit <- rq(f_log, tau = taus, data = homes)
log_ols <- lm(f_log, data = homes)

# the median regression on the log scale, back-transformed, against the median regression on the price
log50   <- rq(f_log, tau = 0.5, data = homes)
back    <- exp(predict(log50, cases))
rbind(`median regression of price` = pred$q50[match(cases$label, pred$label)],
      `median regression of log price, exp()` = back) |> round(0) |> `colnames<-`(cases$label)
                                      Flat, elsewhere Terraced, elsewhere Detached, elsewhere Flat, London Terraced, London Detached, London
median regression of price                        170                 230                 420          480              540              730
median regression of log price, exp()             179                 227                 415          437              555             1014

The two models estimate the same quantile, but one is additive in pounds and the other additive in logs, so they only agree where an additive model is a good description: for a terraced home elsewhere they give £230k and £179k, but for a detached home in London £730k and £1,014k. Back-transforming a quantile is exact for one variable; it is no reason to expect two different models to agree. exp(coef) on the log scale is a ratio: a London home has a median price 2.44 times that elsewhere, that is 144% more. The question changes with the scale: on the pound scale the London premium grows from the bottom to the top of the market; as a percentage it does not, as the chart shows:

Code
lb <- coef(log_fit)[terms, , drop = FALSE]
log_path <- data.frame(tau = rep(taus, each = length(terms)),
                       term = factor(rep(names_short, times = length(taus)), levels = names_short),
                       pc = 100 * (exp(as.vector(lb)) - 1))
log_ols_pc <- data.frame(term = factor(names_short, levels = names_short),
                         pc = 100 * (exp(coef(log_ols)[terms]) - 1))

ggplot(log_path, aes(tau, pc)) +
  geom_hline(data = log_ols_pc, aes(yintercept = pc, colour = "OLS (geometric mean)"), linetype = "dashed", linewidth = 0.8) +
  geom_line(aes(colour = "Quantile regression"), linewidth = 0.9) +
  geom_point(aes(colour = "Quantile regression"), size = 1.4) +
  facet_wrap(~ term, scales = "free_y", ncol = 3) +
  scale_colour_manual(values = c(`Quantile regression` = blue, `OLS (geometric mean)` = orange)) +
  scale_x_continuous(breaks = c(0.1, 0.5, 0.9)) +
  labs(title = "The same model on the log scale, as percentage differences",
       x = expression("quantile " * tau), y = "difference in price (%)", colour = NULL) +
  theme_bw() +
  theme(legend.position = "bottom")

A log outcome, and back-transformation

Code
lp <- function(term, t) 100 * (exp(coef(log_fit)[term, which.min(abs(taus - t))]) - 1)
test_log <- anova(rq(f_log, tau = 0.1, data = homes), log50, rq(f_log, tau = 0.9, data = homes))

On the percentage scale the London premium is 185% at \(\tau\) = 0.1, 144% at the median and 193% at \(\tau\) = 0.9. It is lowest near the middle (144%) and rises towards both ends, so across the middle 80% of the market it varies much less than the £205k to £800k in pounds. Prices in London are higher by a multiple rather than by a fixed sum, and part of the “growing” effect in pounds is just proportions on a skewed outcome. The shape of the curve depends on the scale: a steady rise in pounds becomes a U in percentages. A test of equal slopes on the log scale is still significant (F(10, 221,696) = 106.3, p < .001) but the differences are smaller. A report should say which scale it uses: the pound scale answers “how many pounds more?”, the log scale “how many times more?”.

Median regression resists outliers in y

OLS minimizes squared residuals, so a single huge price pulls the line towards it. The median regression minimizes absolute residuals: an extreme price costs a little more than a moderate one, but not squared. Only the ordering of the prices around the line matters, not how far away they are, which is why the median regression is a robust method, in the same spirit as robust regression (which also handles outliers in the predictors, which median regression does not). To see it, simulate a data-entry error: 100 random sales are entered with two extra zeros (£250,000 becomes £25,000,000).

Code
set.seed(2026)
dirty <- homes
bad   <- sample(n, 100)
dirty$k[bad] <- dirty$k[bad] * 100

effect <- rbind(
  OLS_clean    = coef(lm(f, homes)),
  OLS_dirty    = coef(lm(f, dirty)),
  median_clean = coef(rq(f, tau = 0.5, data = homes)),
  median_dirty = coef(suppressWarnings(rq(f, tau = 0.5, data = dirty))))
round(effect[, c("typeDetached", "londonLondon")], 1)
             typeDetached londonLondon
OLS_clean           247.1        475.9
OLS_dirty           289.7        543.4
median_clean        190.5        310.5
median_dirty        190.2        310.2

With 100 wrong prices out of 73,902 (0.14%), the OLS coefficient for London goes from £476k to £543k, and the one for detached homes from £247k to £290k. The median regression moves from £310k to £310k for London and from £190k to £190k for detached homes. A fully robust method would also resist bad predictors, and quantile regression does not, but for outliers in the outcome it is hard to beat. The same data contain real outliers too (the dearest sale is £25,400k): median regression is not disturbed by them.

Other points

  • Sample size. The extreme quantiles (\(\tau\) = 0.01 or 0.99) need many observations, since the line is fitted to a few points in the tail. As a rule of thumb, you want at least 10 or so observations in the tail for each parameter.
  • Dependence. Sales in the same street or town are alike, and the standard errors assume independent rows. With clustered data use a cluster bootstrap (boot.rq()) or see the multilevel page.
  • Weights and heteroscedasticity. Quantile regression does not need constant variance: unequal spread is the thing it describes. If the aim is a better mean line instead, see weighted least squares and generalized least squares.
  • Trees instead of lines. The random forest page shows quantile regression forests: the same idea with a flexible, non-linear model in place of a straight one.
  • Not causal. A London coefficient is a difference between groups of homes that differ in many other ways.

9. Reporting the results in APA style

A report (APA 7th edition) states the data, the quantiles, the standard error method, the coefficients at the quantiles that matter, the comparison with OLS and the test of equal slopes.

Code
ci_of <- function(model, tau) {
  s <- summary(model, se = "nid")$coefficients
  cbind(est = s[, "Value"], lo = s[, "Value"] - qnorm(.975) * s[, "Std. Error"],
        hi = s[, "Value"] + qnorm(.975) * s[, "Std. Error"])
}
c10 <- ci_of(fit10); c50 <- ci_of(fit50); c90 <- ci_of(fit90)
co  <- cbind(est = coef(fit_ols), confint(fit_ols))
cell <- function(m, term) paste0(f0(m[term, 1]), " [", f0(m[term, 2]), ", ", f0(m[term, 3]), "]")

apa_table <- data.frame(
  Predictor = c("Flat (vs terraced)", "Semi-detached (vs terraced)", "Detached (vs terraced)",
                "New build (vs established)", "London (vs elsewhere)"),
  `τ = .10` = sapply(terms, function(t) cell(c10, t)),
  `τ = .50` = sapply(terms, function(t) cell(c50, t)),
  `τ = .90` = sapply(terms, function(t) cell(c90, t)),
  OLS       = sapply(terms, function(t) cell(co, t)),
  check.names = FALSE, row.names = NULL)

Method (data analysis):

We analyzed 73,902 sales of homes in England and Wales completed between October 2025 and September 2026, from the HM Land Registry Price Paid Data (standard sales of detached, semi-detached, terraced and flat properties; Open Government Licence v3.0). The outcome was the sale price in thousands of pounds. The predictors were the type of home (reference: terraced), whether it was newly built and whether it was in Greater London. Price was strongly right-skewed (median = £300k, mean = £376k), so we estimated linear quantile regressions at τ = .10, .50 and .90, and on a grid from .05 to .95, with the quantreg package (Version 6.1; Koenker, 2005), and compared them with ordinary least squares. Standard errors for the quantile regressions were of the nid (sandwich) type (Hendricks & Koenker, 1992). Equality of the coefficients across τ = .10, .50 and .90 was tested with the Wald-type test of Koenker and Bassett (1982). Analyses were conducted in R (Version 4.6.2; R Core Team, 2026).

Results:

The effects of the predictors differed across the price distribution (Table 1). The London difference was £205k at the 10th percentile, 95% CI [200, 210], £310k at the median, 95% CI [303, 318], and £800k at the 90th percentile, 95% CI [762, 837]; the OLS estimate for the mean was £476k, 95% CI [468, 484]. Detached homes cost £130k, £190k and £410k more than terraced homes at the three quantiles. New builds were £50k dearer than established homes at the 10th percentile, but at the 90th the difference was -£2k, 95% CI [-22, 18]. The coefficients were not equal across the three quantiles, F(10, 221,696) = 419.3, p < .001. On the log scale the percentage London premium varied less (185% at τ = .10, 144% at τ = .50 and 193% at τ = .90), though the slopes still differed, F(10, 221,696) = 106.3, p < .001.

Table 1

Differences in Sale Price (£ Thousand) by Quantile of the Price Distribution, With 95% Confidence Intervals

Predictor τ = .10 τ = .50 τ = .90 OLS
Flat (vs terraced) -42 [-45, -39] -60 [-63, -56] -90 [-98, -81] -102 [-109, -94]
Semi-detached (vs terraced) 40 [38, 42] 40 [37, 44] 65 [58, 72] 45 [39, 51]
Detached (vs terraced) 130 [127, 133] 190 [187, 194] 410 [398, 422] 247 [241, 254]
New build (vs established) 50 [46, 54] 29 [25, 34] -2 [-22, 18] 8 [-2, 19]
London (vs elsewhere) 205 [200, 210] 310 [303, 318] 800 [762, 837] 476 [468, 484]

Note. N = 73,902 sales. The intercept (the price of an established terraced home outside London) was £120k, £230k and £415k at τ = .10, .50 and .90, and £261k in OLS. Quantile regression intervals use nid standard errors.

Points to remember:

  • Say which quantiles you fitted, and why those.
  • Say that coefficients are conditional quantile differences, and name the units.
  • Say which standard error method you used (nid, boot, …) and the number of bootstrap samples.
  • Report the test of equal slopes, but base the conclusion on the size of the differences.
  • Say whether the outcome is on the original or the log scale.
  • Show the coefficients against τ: a table of three quantiles cannot show the shape.

10. Summary

When The effect of a predictor may differ between the low and high ends of the outcome: skewed outcomes (prices, wages, incomes), or interest in the tails (risk, growth charts)
The model \(Q_\tau(y \mid x) = x^\top \beta(\tau)\): one linear regression for each quantile \(\tau\)
The loss Check loss \(\rho_\tau(u) = u(\tau - I(u < 0))\). Median: \(\tau = 0.5\), least absolute deviations
How (R) quantreg::rq(y ~ x, tau = c(.1, .5, .9), data = d); summary(fit, se = "nid") or se = "boot"
Standard errors "nid" for large samples; "boot" when in doubt; not "iid" with unequal spread
Equal slopes? anova(fit10, fit50, fit90) (joint test), joint = FALSE (one predictor at a time)
Reading it A difference in a conditional quantile, not an effect on the people at the top
Advantages No normality or constant variance needed; robust to outliers in \(y\); quantiles commute with log and other monotone transformations
Dangers Crossing quantiles; extreme \(\tau\) with small samples; dependent data; not robust to outliers in \(x\)
Alternatives Robust regression, WLS and GLS for the mean; quantile forests for non-linear quantiles; unconditional quantile regression (RIF) for effects on the whole market

References

Chernozhukov, V., Fernández-Val, I., & Galichon, A. (2010). Quantile and probability curves without crossing. Econometrica, 78(3), 1093–1125. https://doi.org/10.3982/ECTA7880

Firpo, S., Fortin, N. M., & Lemieux, T. (2009). Unconditional quantile regressions. Econometrica, 77(3), 953–973. https://doi.org/10.3982/ECTA6822

Hendricks, W., & Koenker, R. (1992). Hierarchical spline models for conditional quantiles and the demand for electricity. Journal of the American Statistical Association, 87(417), 58–68. https://doi.org/10.1080/01621459.1992.10475175

HM Land Registry. (2026). Price Paid Data [Data set]. Open Government Licence v3.0. https://www.gov.uk/government/statistical-data-sets/price-paid-data-downloads. Contains HM Land Registry data © Crown copyright and database right 2021. This data is licensed under the Open Government Licence v3.0.

Koenker, R. (2005). Quantile regression. Cambridge University Press. https://doi.org/10.1017/CBO9780511754098

Koenker, R., & Bassett, G., Jr. (1978). Regression quantiles. Econometrica, 46(1), 33–50. https://doi.org/10.2307/1913643

Koenker, R., & Bassett, G., Jr. (1982). Robust tests for heteroscedasticity based on regression quantiles. Econometrica, 50(1), 43–61. https://doi.org/10.2307/1912528

Koenker, R., & Hallock, K. F. (2001). Quantile regression. Journal of Economic Perspectives, 15(4), 143–156. https://doi.org/10.1257/jep.15.4.143

Powell, J. L. (1991). Estimation of monotonic regression models under quantile restrictions. In W. A. Barnett, J. Powell, & G. Tauchen (Eds.), Nonparametric and semiparametric methods in econometrics and statistics (pp. 357–384). Cambridge University Press.