If a data set contains one high point far from the rest, how much will a fitted line tilt toward it? Siegel repeated medians regression estimates the slope with two layers of medians: first let each point act as an anchor and summarize the slopes of the lines joining it to every other point; then summarize the results across anchors. It answers a question similar to that of the Theil–Sen estimator, which pools all pairwise slopes and takes a single median, but it uses a different summary structure. [1][2]
Summarize by Anchor First, Then Summarize the Anchors
Let the observations be (xᵢ, yᵢ), with all x-coordinates distinct. Taking the i-th point as the anchor, the slope of the line joining it to another point j is sᵢⱼ = (yⱼ − yᵢ)/(xⱼ − xᵢ). First take mᵢ = median over j ≠ i of sᵢⱼ, then take b = median over i of mᵢ, which gives the Siegel slope. With the hierarchical intercept, compute a = median over i of (yᵢ − bxᵢ), and the fitted line is ŷ = a + bx. [1]
The Theil–Sen slope, by contrast, is a single median of the slopes of all unordered pairs of points. [2] For a set of distinct x values, each unordered-pair slope appears exactly twice in the ordered list, so pooling all ordered slopes and taking the median is still a single-level summary; it does not turn into repeated medians. Siegel's second layer receives only one median per anchor, so each anchor occupies exactly one position in that layer, and the effect of the pairwise slopes on the final result first passes through the ordering within each anchor.
Seven Points, Two Slopes
Construct seven observation points with x equal to 0, 1, 2, 3, 4, 5, 6 and y equal to 1, 3.2, 4.8, 7.1, 9, 11.2, 27. The first six points lie roughly along a rising straight line, and the last point is clearly too high. Each anchor is joined to the other six points, so each has six slopes.
Take (0, 1) as the anchor. Its six slopes are 2.2, 1.9, 2.0333, 2, 2.04, and 4.3333. After sorting, the middle two values are 2.0333 and 2.04, and their average gives this anchor's median of about 2.0367. Treating the other anchors the same way, the seven values mᵢ are about 2.0367, 1.9750, 2.1167, 2.0417, 2.0500, 2.0917, and 6.0917.
After sorting the seven anchor medians, the fourth is 2.05, and this is the repeated medians slope. Taking the median of the seven values yᵢ − 2.05xᵢ then gives an intercept of 0.95, so the fitted line is ŷ = 0.95 + 2.05x. For comparison, the single median of the 21 unordered pairwise slopes is 2.10, and the ordinary least squares line is about ŷ = −1.4786 + 3.5071x.

The regression calculations actually carried out on the seven constructed points. The left panel compares the Siegel repeated medians line with the least squares line; the right panel first takes the median of the six slopes at each anchor, then the median of the seven anchor medians, and compares it with the single median of the 21 pairwise slopes.
The slopes between this high point and the other six are all large, and its own anchor median also rises to about 6.09; but it contributes only one of the seven anchor medians, so the second-layer median still lands at 2.05. Each of the other anchors has one slope connecting it to the high point, but its median also depends on how the other five slopes are ordered. Theil–Sen, a single-level summary, also uses a median but sorts directly among all 21 pairwise slopes, so this example gives 2.10. The two can also happen to coincide on other data.
Least squares chooses the line that minimizes the sum of squared residuals. A point far from the others produces a residual that is amplified by squaring, so the fitted line can shift noticeably toward it; in this example the high point also sits at the end of the x range, which makes its influence on the slope especially strong. This does not mean the high point must be wrong: it may reflect a data-entry problem, a special condition, or something genuinely present in the subject being studied, and it should be understood in light of where the data came from.
Recomputing in Python
The code below computes each anchor's median, the single pairwise median, and the least squares result, and checks the two robust slopes against SciPy. The points in the code match the ones above; the output is displayed rounded to a few decimal places.
import numpy as np
from scipy import stats
x = np.array([0, 1, 2, 3, 4, 5, 6], dtype=float)
y = np.array([1, 3.2, 4.8, 7.1, 9, 11.2, 27], dtype=float)
anchor_medians = []
for i in range(len(x)):
other = np.arange(len(x)) != i
slopes = (y[other] - y[i]) / (x[other] - x[i])
anchor_medians.append(np.median(slopes))
b = np.median(anchor_medians)
a = np.median(y - b * x)
pair_slopes = [(y[j] - y[i]) / (x[j] - x[i])
for i in range(len(x))
for j in range(i + 1, len(x))]
siegel = stats.siegelslopes(y, x, method='hierarchical')
theil = stats.theilslopes(y, x)
ols = stats.linregress(x, y)
print('Anchor medians:', np.round(anchor_medians, 4))
print('Hand-computed Siegel:', round(b, 4), round(a, 4))
print('SciPy Siegel:', round(siegel.slope, 4), round(siegel.intercept, 4))
print('Pairwise median and SciPy Theil slope:',
round(np.median(pair_slopes), 4), round(theil.slope, 4))
print('Least squares slope and intercept:', round(ols.slope, 4), round(ols.intercept, 4))
Output:
Anchor medians: [2.0367 1.975 2.1167 2.0417 2.05 2.0917 6.0917]
Hand-computed Siegel: 2.05 0.95
SciPy Siegel: 2.05 0.95
Pairwise median and SciPy Theil slope: 2.1 2.1
Least squares slope and intercept: 3.5071 -1.4786
How to Understand the Robustness
The 50% that the SciPy documentation gives for the repeated medians estimator is an asymptotic breakdown point, which describes how well the estimator resists breakdown under contamination as the sample grows. [1] It does not mean that the true line can still be recovered when exactly half of the observations in a finite sample are changed arbitrarily, and it is not a confidence level or a percentage of allowable error. The seven-point calculation above shows how the estimator behaves with one specific high point; it cannot prove accuracy under every kind of contamination.
When using it, first judge whether a straight line is a reasonable description of the relationship, then interpret the result in light of how the observations were obtained: repeated measurements or clustered observations require attention to their dependence structure, and if the x-coordinate has important measurement error, an analysis method suited to that error is also needed. Repeated medians provides a robust fitted line; the slope itself does not establish causation.
References
-
[1] SciPy. scipy.stats.siegelslopes. SciPy Manual. https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.siegelslopes.html
-
[2] SciPy. scipy.stats.theilslopes. SciPy Manual. https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.theilslopes.html