16 Least Median of Squares and Robust Regression
Least squares gives every observation a weight proportional to the square of its residual, so a single gross error can pull the fitted line far from the bulk of the data. The influence diagnostics of Chapter 9 detect such points one at a time, but several outliers together can mask one another: deleting one does not reveal its effect because the others still distort the fit. Robust regression methods are designed to give a fit that is not unduly affected by a minority of unusual observations, and then to reveal those observations clearly through their large residuals (Rousseeuw and Leroy 1987; Montgomery, Peck, and Vining 2021).
16.1 The breakdown point
The breakdown point of an estimator is the smallest fraction of the data that, if replaced by arbitrary values, can make the estimate arbitrarily large.
- The sample mean, and least squares regression, have breakdown point \(1/n\to0\): one bad observation suffices.
- The sample median has breakdown point 50%, the highest possible.
Robust regression seeks estimators with high breakdown point that are also reasonably efficient when the errors are normal.
16.2 Least absolute deviations (\(L_1\)) regression
Minimizing \(\sum|y_i-\mathbf x_i'\boldsymbol\beta|\) instead of \(\sum(y_i-\mathbf x_i'\boldsymbol\beta)^2\) gives the least absolute deviations (LAD) estimator, the regression analogue of the median. It is solved by linear programming. LAD resists outliers in \(y\), but not leverage points in \(x\): its breakdown point is still \(1/n\).
16.3 M-estimators
M-estimators (maximum likelihood type) minimize \(\sum\rho\left(e_i/s\right)\) for a function \(\rho\) that grows more slowly than the square for large residuals, where \(s\) is a robust scale estimate. The most common is Huber’s function
\[\rho(u)=\begin{cases}u^2/2,&|u|\le c\\c|u|-c^2/2,&|u|>c\end{cases}\]
with \(c\approx1.345\), which is quadratic for small residuals (like least squares) and linear for large ones (like LAD). The estimating equations \(\sum\psi(e_i/s)\mathbf x_i=\mathbf 0\) (with \(\psi=\rho'\)) are solved by iteratively reweighted least squares (IRLS): weighted least squares with weights \(w_i=\psi(u_i)/u_i\), recomputed at each iteration. Observations with large residuals get small weights. M-estimators are efficient and resistant to outliers in \(y\), but like LAD they can still break down because of leverage points.
16.4 Least median of squares
Rousseeuw (Rousseeuw 1984) proposed replacing the sum of squared residuals by their median:
\[\hat{\boldsymbol\beta}_{LMS}=\arg\min_{\boldsymbol\beta}\ \underset{i}{\operatorname{med}}\ \left(y_i-\mathbf x_i'\boldsymbol\beta\right)^2. \tag{16.1}\]
Concept
Least squares minimizes the mean squared residual, and is controlled by the largest residuals. LMS asks only that half of the residuals be small; the other half can be as large as they like without affecting the fit. Hence LMS has the maximal breakdown point of (nearly) 50%: up to half of the observations can be contaminated, in \(y\) or in \(x\), without the estimate breaking down.
Geometric interpretation
In simple regression, the LMS line lies at the centre of the narrowest strip (measured vertically) that covers half of the observations. It fits the majority of the data and ignores the rest.
Computation
The objective Equation 16.1 is not smooth and has many local minima, so it is not solved by calculus. The usual algorithm uses elemental subsets:
- Draw a subset of \(p\) observations at random and compute the exact fit \(\boldsymbol\beta_J\) through them (for simple regression, the line through two points).
- Compute the residuals of all \(n\) observations from this fit and their median squared residual \(m_J\).
- Repeat for many subsets (all of them if \(n\) is small) and keep the fit with the smallest \(m_J\).
- Optionally adjust the intercept so that it is optimal for the chosen slope.
Robust scale and reweighted least squares
A preliminary scale estimate is
\[s^0=1.4826\left(1+\frac5{n-p}\right)\sqrt{\underset{i}{\operatorname{med}}\ e_i^2}, \tag{16.2}\]
where 1.4826 makes \(s^0\) consistent for \(\sigma\) under normal errors and \(\left(1+\frac5{n-p}\right)\) is a small-sample correction. Standardized residuals \(e_i/s^0\) larger than 2.5 in absolute value flag outliers. Because LMS has low statistical efficiency (its convergence is slow), the final step is reweighted least squares (RLS): give weight \(w_i=1\) to observations with \(|e_i/s^0|\le2.5\) and \(w_i=0\) to the others, and fit ordinary least squares to the retained observations. This combines the high breakdown point of LMS with the efficiency and familiar inference of least squares.
Least trimmed squares
A closely related estimator, least trimmed squares (LTS), minimizes the sum of the \(h\) smallest squared residuals (\(h\approx n/2\)). It has the same breakdown point as LMS and better efficiency, and is now generally preferred.
Example 16.1 Germination percentage of a rice variety was recorded in pots at 15 levels of soil salinity (EC, dS/m) (csv/salinity.csv). Three seed lots at the highest salinity levels were later found to have been mislabelled. Compare the least squares and LMS fits.
Solution
Least squares gives
\[\widehat{\text{germ}}=88.29-0.568\,\text{EC},\]
an almost flat line with \(R^2=0.007\), suggesting that salinity has hardly any effect. The three mislabelled lots (observations 13–15) lie at the highest EC values with high germination, so they are leverage points that pull the line up at the right end. The LS residual plot does not reveal them clearly because they have masked one another.
LMS gives
\[\widehat{\text{germ}}=98.95-7.273\,\text{EC},\]
with robust scale \(s^0=0.437\). The standardized LMS residuals of observations 13, 14 and 15 are 64.4, 67.1, 76.6, far beyond 2.5, while all others are small. Reweighted least squares on the remaining 12 observations gives \(\widehat{\text{germ}}=99.01-7.225\,\text{EC}\): germination falls by about 7.2 percentage points per dS/m. The Huber M-estimate (-0.555) is pulled towards the least squares slope because the bad points are leverage points.
Robust methods are diagnostic tools as much as estimators. Large robust residuals identify observations that deserve investigation; they do not by themselves justify discarding data. Compare the least squares and robust fits: if they agree, report least squares; if they differ, find out why.
16.5 R practical
library(MASS)
sl <- read.csv("csv/salinity.csv")
ols <- lm(germ ~ EC, data = sl)
set.seed(1)
lms <- lqs(germ ~ EC, data = sl, method = "lms") # least median of squares
lts <- lqs(germ ~ EC, data = sl, method = "lts") # least trimmed squares
hub <- rlm(germ ~ EC, data = sl) # Huber M-estimator (IRLS)
rbind(OLS = coef(ols), LMS = coef(lms), LTS = coef(lts), Huber = coef(hub))#> (Intercept) EC
#> OLS 88.29351 -0.5677106
#> LMS 98.95455 -7.2727273
#> LTS 98.56250 -7.0000000
#> Huber 88.27853 -0.5545730
lms$scale # robust scale estimates#> [1] 0.4371150 0.4406982
# Flag outliers and refit (reweighted least squares)
r <- resid(lms) / lms$scale[1]
which(abs(r) > 2.5)#> 13 14 15
#> 13 14 15
coef(lm(germ ~ EC, data = sl, subset = abs(r) <= 2.5))#> (Intercept) EC
#> 99.014243 -7.224634
# LMS for simple regression by exhaustive elemental subsets
best <- Inf
for (i in 1:14) for (j in (i + 1):15) {
b1 <- (sl$germ[j] - sl$germ[i]) / (sl$EC[j] - sl$EC[i]); b0 <- sl$germ[i] - b1 * sl$EC[i]
m <- median((sl$germ - b0 - b1 * sl$EC)^2)
if (m < best) { best <- m; bb <- c(b0, b1) }
}
bb; best#> [1] 99.533333 -7.333333
#> [1] 0.16
Huber, Hampel and Rousseeuw
The modern theory of robust statistics began with Peter Huber’s 1964 paper on robust estimation of a location parameter, which introduced M-estimators. Frank Hampel defined the breakdown point and the influence function in 1968–71. Peter Rousseeuw, a student of Hampel, introduced least median of squares in 1984 (Rousseeuw 1984), the first regression estimator with a 50% breakdown point that could be computed in practice; his book with Annick Leroy (Rousseeuw and Leroy 1987) made high-breakdown regression accessible to applied scientists.
“An outlier is an observation which deviates so much from other observations as to arouse suspicions that it was generated by a different mechanism.”
- Douglas Hawkins
16.6 Practical exercises
16.6.1 Practical 16.1: Least median of squares by hand
The leaf chlorophyll meter reading (\(x\)) and leaf N content (%) (\(y\)) of seven rice leaves are given below. The last reading is suspected to be a recording error. Compare the least squares line with the LMS line found by searching all elemental subsets (pairs of points).
| Leaf | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
|---|---|---|---|---|---|---|---|
| Meter reading (\(x\)) | 30 | 32 | 34 | 36 | 38 | 40 | 42 |
| Leaf N (\(y\)) | 2.10 | 2.31 | 2.48 | 2.72 | 2.90 | 3.12 | 1.60 |
Solution
Least squares gives \(\hat y=2.114+0.0096x\): the single bad point at \(x=42\) pulls the slope from about 0.10 (the trend of the other six leaves) down to almost nothing. There are \(\binom72=21\) elemental subsets. For each, the line through the two points is computed and the median of the seven squared residuals recorded. The smallest median, \(0.00006\), is given by the line through leaves 2 and 6:
\[\hat y_{LMS}=-0.930+0.1013x.\]
The robust scale by Equation 16.2 is \(s^0=1.4826(1+5/5)\sqrt{0.00006}=0.0222\), and the standardized residual of leaf 7 is \(-1.723/0.0222=-77.5\), far beyond 2.5: leaf 7 is an outlier and its record should be checked.
Doing it in R
spad <- data.frame(x = seq(30, 42, 2), y = c(2.10, 2.31, 2.48, 2.72, 2.90, 3.12, 1.60))
best <- Inf
for (i in 1:6) for (j in (i + 1):7) {
b1 <- (spad$y[j] - spad$y[i]) / (spad$x[j] - spad$x[i]); b0 <- spad$y[i] - b1 * spad$x[i]
m <- median((spad$y - b0 - b1 * spad$x)^2)
if (m < best) { best <- m; lmsfit <- c(b0 = b0, b1 = b1) }
}
rbind(OLS = coef(lm(y ~ x, data = spad)), LMS_elemental = lmsfit,
lqs = coef(MASS::lqs(y ~ x, data = spad, method = "lms")))#> (Intercept) x
#> OLS 2.114286 0.009642857
#> LMS_elemental -0.930000 0.101250000
#> lqs -0.956000 0.102000000
16.7 Chapter Summary
Fill in the blanks
Answers are given at the end of the chapter.
The smallest fraction of contaminated data that can make an estimator arbitrarily bad is its __________.
The breakdown point of least squares is __________.
LAD regression minimizes the sum of __________ residuals.
Huber’s \(\rho\) function is quadratic for small residuals and __________ for large residuals.
M-estimators are computed by iteratively __________ least squares.
LMS minimizes the __________ of the squared residuals.
The breakdown point of LMS is about __________.
In simple regression, the LMS line is the centre of the narrowest strip covering __________ of the data.
In reweighted least squares after LMS, observations with \(|e_i/s^0|>\) __________ receive zero weight.
LTS minimizes the sum of the __________ squared residuals.
Short-answer questions
What is the breakdown point? Compare the mean and the median.
Why is least squares sensitive to outliers?
Explain LAD regression and its limitation.
Explain M-estimation and Huber’s function.
Define least median of squares and explain its concept.
Describe the elemental subset algorithm for LMS.
How is the robust scale estimate computed?
Explain reweighted least squares after LMS.
What is masking? How does robust regression overcome it?
Distinguish between LMS and LTS.
Numerical and conceptual questions
Answers are given at the end of the chapter.
For the data \(y=(3,4,5,6,50)\), find the mean and median and explain the effect of the last value.
The median squared residual of an LMS fit is 4.0 with \(n=20\), \(p=2\). Compute \(s^0\).
For Question 2, which residuals would be flagged as outliers?
How many elemental subsets are there for simple regression with \(n=10\)?
Residuals 1, −2, 3, −10, 0.5 are obtained from a candidate line. Compute the median squared residual.
Why does the Huber M-estimator fail in Example 16.1?
Important formulae
LMS estimator:
\[ \hat{\boldsymbol\beta}_{LMS}=\arg\min_{\boldsymbol\beta}\ \operatorname{med}_i\ (y_i-\mathbf x_i'\boldsymbol\beta)^2 \]
Robust scale:
\[ s^0=1.4826\left(1+\frac5{n-p}\right)\sqrt{\operatorname{med}_ie_i^2} \]
Huber’s function:
\[ \rho(u)=\begin{cases}u^2/2,&|u|\le c\\c|u|-c^2/2,&|u|>c\end{cases} \]
Quick revision
- LS → breakdown point 0; one bad point can ruin it.
- LAD and M-estimators → resist outliers in \(y\), not leverage points.
- LMS → minimize median squared residual; 50% breakdown; fits the majority.
- Elemental subsets → exact fits through \(p\) points; keep smallest median.
- \(s^0\) and \(|e/s^0|>2.5\) → flag outliers; then reweighted LS.
- Robust fit ≠ licence to delete; investigate flagged points.
Answers to fill in the blanks
1. Breakdown point 2. \(1/n\) (zero asymptotically) 3. Absolute 4. Linear 5. Reweighted 6. Median 7. 50% 8. Half 9. 2.5 10. \(h\) smallest
Solutions to numerical and conceptual questions
Mean \(=13.6\), median \(=5\). One extreme value moves the mean far from the bulk of the data but leaves the median unchanged.
By Equation 16.2, \(s^0=1.4826(1+5/18)(2)=3.789\).
Those with \(|e_i|>2.5\times3.789=9.47\).
\(\binom{10}2=45\).
Squared residuals: 1, 4, 9, 100, 0.25; median \(=4\).
The mislabelled lots are at the extreme EC values (high leverage); the M-estimator downweights large residuals, but leverage points do not have large LS residuals, so they are not downweighted enough.