The LeastTrimmedSquares command computes least trimmed squares regression for some data.
In this example, we have 1000 data points. There is a single independent variable, x, with values uniformly distributed between 0 and 10. The dependent variable is a linear function of the independent variable plus some additive noise, y=5 x + 10 + noise, where the noise is from a probability distribution known to have severe outliers - the Cauchy distribution, with location parameter 0 and scale parameter 5.
Here we see all data points:
Linear least squares regression will be severely affected by the outliers.
Least trimmed squares regression gets much closer to the true line without noise.
The result is even better if we include 900 out of the 1000 points, instead of the default of a little over 500.
The other robust regression method, implemented in the RepeatedMedianEstimator procedure, also gets a good result.
In order to visualize these results, we show the same point plot as before, including the four regression lines. The three regression lines from robust methods cannot be distinguished, but the least squares method is clearly off. We zoom in on the vertical range that includes most points.