Statistical Methods
Audit a Theil–Sen Slope and Its Intercept Convention
Define the task
A Theil–Sen estimate summarizes a linear relationship using the median of slopes between observations with different x coordinates. Use it when a robust descriptive slope matches the question, while retaining a plot and checking whether a straight line is meaningful. Record both measurement units and the order of paired x and y values. Robustness does not remove confounding, dependence or measurement-error bias. The accompanying browser tool estimates a slope and one specified intercept without a confidence interval.
Carry out the check
Compute (y[j]−y[i])/(x[j]−x[i]) for each eligible pair and take their median. Pairs with equal x have no finite slope and are excluded, not treated as zero slopes. The tool uses the separate-median intercept, median(y)−slope×median(x), matching the documented separate convention. A median of residual intercepts is another convention and can differ. Report the number of usable pairs and check the influence of duplicated coordinates. The pairwise slopes are dependent, so their ordinary standard error is not a slope confidence interval.
Worked hypothetical example
For fictional x=(0,1,2) and y=(1,3,9), the slopes are 2,4,6, giving median slope 4 y-units per x-unit. The separate-median intercept is 3−4×1=−1. The residual-intercept median instead uses (1,−1,1) and equals 1. This difference is a convention issue, not a rounding error. Preserve the raw coordinate pairs and named intercept method so another analyst can reproduce the fitted line.
Method checked 18 November 2026 against Primary method documentation: theilslopes.