The running example
The data are the line observed at 60 points with Gaussian noise of standard deviation , the same generator as in the EM section. The model is the straight line with , so is the intercept and the slope. Least squares minimizes the sum-of-squares error which is Bishop’s Eq. 3.12. Here is the residual of point . The minimizer solves the normal equations, (Eq. 3.15). It is also the maximum likelihood estimate when the noise is Gaussian, as the conditional maximum likelihood section shows.One bad point and leverage
Add a 61st point to the clean data and move its target away from the line by an amount . Each target enters the least squares solution linearly, because is a fixed matrix times . The estimate therefore moves in proportion to , with no limit, so a single bad point among 61 can move the slope by any amount. In the language of robust statistics, the breakdown point of least squares, the smallest fraction of bad points that can carry the estimate arbitrarily far, is , which goes to zero as grows. How far it moves depends on where the point sits. The fitted values are with the hat matrix . Its diagonal element is the leverage of point : the amount by which the fitted value at moves when moves by one unit. Points near the mean of the have low leverage. Points at the ends of the range, or beyond it, have high leverage. The code places the bad point at , near the middle of the data, and at , beyond its end, and fits for a range of .Robust losses and iteratively reweighted least squares
A robust loss replaces the square with a function that grows more slowly for large residuals: where is a scale for the residuals, close to for the inliers. Two common choices are the Huber loss, which is quadratic up to a threshold and linear beyond it, and the Cauchy loss, which grows only logarithmically: Setting the gradient of to zero gives . Write , with the weight function . The condition becomes with , which is the normal equation of a weighted least squares problem: This has the form of Bishop’s Eq. 14.42. The weights depend on the residuals, which depend on , so the solution is found by iteration: compute the residuals, compute the weights, solve the weighted problem, repeat. This is iteratively reweighted least squares (IRLS). The weight functions are Huber weights fall off as , so a point’s influence on the fit, , stops growing beyond but never shrinks. Cauchy weights fall off as , so the influence of a far point goes back toward zero. The scan registration section uses the same Huber weights inside ICP. The code estimates the scale at every iteration from the median absolute deviation of the residuals, , which equals for Gaussian residuals and ignores up to half the points. The constants and are the usual ones: with Gaussian noise and no outliers they lose only 5% of the efficiency of least squares.The Student’s t view
Robust losses can also be read as likelihoods. Bishop’s Section 2.3.7 introduces the Student’s t distribution (Eq. 2.159) and shows in Figure 2.16 that a maximum likelihood fit under it is much less affected by a few outliers than a Gaussian fit. The reason is its form as a scale mixture of Gaussians (Eq. 2.160): Each observation has its own precision scale , drawn from a gamma distribution, so some points are allowed to be far noisier than others. Take the t distribution as the noise model of the regression, . Its negative log likelihood, as a function of the residual, is plus a constant. For the t distribution is the Cauchy distribution and this is the Cauchy loss above, up to a constant factor, with . The scale mixture also explains the weights. Treat as a latent variable. Its posterior given the residual is again a gamma distribution, with mean An EM algorithm for the t regression computes these expectations in the E step and solves a weighted least squares problem with weights in the M step. Bishop notes that the t fit can be found by EM (Section 2.3.7). The expectations are exactly the Cauchy weights for , so IRLS with Cauchy weights is EM for regression with Cauchy noise.Comparison on contaminated data
The EM section modeled the same contamination differently: each target comes either from the line with Gaussian noise, with probability , or from a uniform outlier distribution : The E step computes the responsibility of the inlier component for each point, and the M step is a weighted least squares problem with weights , followed by updates of and , which has the same form as IRLS. The weight falls toward zero much faster than a Cauchy weight: once a residual is a few from the line, the Gaussian density is negligible next to the uniform one. The mixture also returns two things a robust loss does not, an estimate of the inlier fraction and a probability for each point that it is an inlier. The code fits all four methods to the 60-point data set of the EM section, in which 18 targets were replaced by gross errors.How much contamination each method tolerates
One data set says little about where each method fails. The code repeats the comparison on 50 random data sets for each outlier fraction from 0 to 0.7 and records the median absolute error of the slope. Each robust method starts from the least squares fit, which is what you would do without other information.Grid load in Winter Storm Uri
ERCOT operates the electricity grid that serves most of Texas. In mid-February 2021, Winter Storm Uri brought temperatures far below anything in the preceding winter, demand rose, and generation failed. From the early hours of 15 February, ERCOT shed load: it cut power to customers to keep the grid from collapsing. The load it reports for those hours is what it served, well below what customers would have drawn. A model of normal demand fitted to a window that includes those hours faces exactly the contamination of this section. The data are hourly ERCOT system load and a statewide temperature, from 1 December 2020 to 20 February 2021 (Central time). The load is the hourly native load from the ERCOT load archive. The temperature is the mean of the hourly readings at eight airports, one in each of ERCOT’s weather zones, from NOAA’s Integrated Surface Database. The table is published as the ercot-uri-load-temperature dataset, with the scripts that build it.Leverage and the starting point
Least squares fitted with the storm moves the mean residual of 15 and 16 February from GW to GW: the fit has bent to meet the shed hours. On 14 February, the cold day before shedding, the bent model now predicts 9.7 GW less than the real demand. Huber and Cauchy IRLS do not undo the bend. Their mean residuals on 15 and 16 February are and GW, because of leverage. The coldest hour of the ordinary winter was 28.4 F, and 126 hours of the storm week were colder. Those hours sit at the far end of the temperature axis, where the cubic and the per-hour quadratic terms are constrained by little else, and their mean leverage is 0.289 against 0.031 for the ordinary winter. The fit can pass close to them, and once it does their residuals are small and no weight function reduces their weight. It is the same effect as the single high-leverage point of the first experiment, produced here by a group of hours that agree with each other. The Huber loss is convex, so a different start would not change its answer. EM started from the least squares fit stops in the same place, a local maximum of the likelihood in which the storm hours are inliers. Started from the fit to the ordinary winter, EM keeps the shape of normal demand: its residual on 14 February is GW, and its residuals on 15 and 16 February stay large and negative. Its inlier responsibilities flag 20 of the 24 hours of 15 February, when shedding began in the early morning, and every hour of 16 and 17 February. Most hours of 18 and 19 February stay flagged as well (21 and 19 of 24). They also flag 7 hours of the cold days of 12 and 13 February. On all of these days the temperature fell below the range of the ordinary winter, where the model is extrapolating. The two EM runs use the same data and the same model and differ only in where they start. A robust method downweights points that disagree with its current fit. It cannot recover once the fit already agrees with the bad points, so it needs a start that is not already contaminated. Here that start came from knowing which window was ordinary. For models with few parameters, the next section, RANSAC, finds such a start with no prior knowledge, by fitting many small random subsets of the data. It also explains why that does not work for an 82-parameter model like this one. The example has three limits. The temperature is an unweighted mean over eight airports, so it does not weight the weather by where the load is. The load during shedding is what ERCOT served, so the size of the negative residuals estimates the unserved demand only as far as the model can be trusted at temperatures it was never fitted to. The results also come from a single storm. Key references: (Bishop, n.d.; Dempster et al., n.d.)References
- Dempster, A., Laird, N., Rdin, D. (n.d.). Maximum Likelihood from Incomplete Data via the EM Algorithm.
- Bishop (n.d.). Pattern Recognition and Machine Learning.
Found an error on this page? Report an issue.

