- Introduced by
- Henri Theil (1950); P. K. Sen (1968)
- Year
- 1968
- Type
- Robust linear regression
What does it do?
The Theil-Sen estimator is a robust linear regression method that estimates the slope as the median of the slopes computed over all pairs of data points with distinct x-values.
Henri Theil's 1950 rank-invariant approach is usually cited as its origin, and P. K. Sen's 1968 paper studied the median-of-pairwise-slopes estimator, linking it to Kendall's tau. The method is commonly given a breakdown point of about 29% against outliers in the response.
The intuition behind the method
For every pair of points you could draw a straight line and read off its slope. Instead of picking one line or averaging the slopes (which a single outlier could pull badly), Theil-Sen simply takes the median of all those pairwise slopes. Because the median ignores extreme values, a handful of wild points barely moves the fitted line, so the estimate stays close to the bulk of the data.
History
Henri Theil's 1950 work on rank-invariant linear and polynomial regression is usually cited as the origin of the approach. P. K. Sen's 1968 paper in the Journal of the American Statistical Association studied a robust estimator of the regression coefficient defined as the median of pairwise slopes, based on Kendall's tau, and compared it with least squares and other nonparametric estimators.
When to use it
Choose Theil-Sen when the outcome is continuous, there is one predictor (or very few), the relationship is approximately linear, and you want a slope that is not distorted by outliers in the response or by non-normal errors. Because the slope is a median of pairwise slopes, it does not depend on normally distributed residuals in the way least-squares intervals do, and it is a reasonable alternative to ordinary least squares when some response values may be contaminated. Avoid it when the sample is very small, when the predictor contains influential high-leverage values, or when you need to model many predictors at once, since its pairwise-slope construction does not extend cleanly to multiple regression.
Limitations and considerations
- Designed for a single (or very few) predictors, so it does not scale to high-dimensional multiple regression the way ordinary least squares does.
- In very small samples the median of pairwise slopes is unstable, and inference based on it is unreliable.
- High-leverage values in the predictor can exceed what the response-based breakdown point protects against and distort the fit.
- Pairs with equal predictor values are dropped, so a predictor with many repeated x-values leaves fewer usable slopes.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Robust to outliers in the response, with a commonly cited breakdown point of about 29%; a few extreme values cannot move a median of many pairwise slopes far.
- The slope is a median rather than a least-squares fit, so extreme responses have limited influence. Sen (1968) notes that least-squares confidence intervals are sensitive to non-normality, whereas the Theil-Sen interval is built from order statistics of the same slope set.
- Linked to Kendall's rank correlation tau by Sen (1968), which gives the estimator a clear nonparametric background.
Applications
- Trend estimation in environmental and hydrological series where occasional extreme readings should not dominate the slope.
- Robust fitting of a single-predictor relationship when a few outliers contaminate the response.
- Any setting needing a distribution-free, outlier-resistant alternative to a simple least-squares line.
How it works
How it works
The outcome y is modelled as a straight line in one predictor x, with intercept β₀, slope β₁ and an error term ε. The method is built for a single predictor, or very few, and assumes the underlying relationship is linear.
Formula
y = \beta_0 + \beta_1 x + \varepsilon
The slope β̂₁ is the median of the slopes (yⱼ − yᵢ)/(xⱼ − xᵢ) over all pairs i < j. Pairs with equal x values are excluded because their slope is undefined; Sen's 1968 definition uses only pairs with distinct x. Because the estimate is a median rather than a sum, a minority of extreme responses cannot move it far; the commonly cited breakdown point of about 29% against contamination in the response reflects this. The slope is read as the estimated change in y for a one-unit change in x. The intercept is then obtained from the data; the usual choice is the median of yᵢ minus β̂₁ times xᵢ. Sen (1968) builds the confidence interval from two order statistics of the same set of pairwise slopes, so the interval is computed separately from the point estimate.
Formula
\hat{\beta}_1 = \operatorname{median}_{i<j}\left(\frac{y_j - y_i}{x_j - x_i}\right)Common pitfalls
- Reading too much into the slope from very small samples. With few observations the median of pairwise slopes is unstable, so the slope and any interval should be interpreted cautiously.
- Assuming robustness to response outliers also protects against leverage points. Influential x-values can break the ≈29% figure, so predictor leverage should be checked and alternatives such as least trimmed squares considered.
- Applying it to many predictors, where the pairwise-slope logic no longer applies cleanly.
- Forgetting the linearity assumption: the method resists outliers, not curvature.
- Treating the interval as exact when its assumptions are violated. The interval rests on the linear model and on standard assumptions such as independent errors; departures from them can affect its validity.
Frequently asked questions
What is the breakdown point of Theil-Sen?
The commonly cited figure is about 29%, meaning that a substantial fraction of the response values can be arbitrarily corrupted before the slope estimate breaks down. Ordinary least squares, by contrast, has a breakdown point effectively at zero, so a single gross outlier can distort it.
How does Theil-Sen relate to Kendall's tau?
Sen's 1968 formulation is based on Kendall's rank correlation tau. Sen describes the confidence interval as robust: it is determined by order statistics of the pairwise slopes, whereas least-squares intervals are sensitive to non-normality of the parent distribution.
Can I use Theil-Sen with several predictors?
It is designed for a single or very few predictors. Its pairwise-slope construction does not extend cleanly to high-dimensional multiple regression, so for many predictors a different robust or penalised method is more appropriate.
When should I prefer another method?
For very small samples the slope is unstable and inference is unreliable, so results from such data should be read with caution. When high-leverage predictor values are present, a method designed for leverage, such as least trimmed squares, may be preferable.
Related methods
Sources
Sen, P. K. (1968). Estimates of the Regression Coefficient Based on Kendall's Tau. Journal of the American Statistical Association, 63(324), 1379-1389.
Open DOI referenceTheil, H. (1950). A Rank-Invariant Method of Linear and Polynomial Regression Analysis. Proceedings of the Royal Netherlands Academy of Sciences, 53, 386-392, 521-525, 1397-1412.
Open publication reference