Skip to main content

Module regression

Module regression 

Source
Expand description

Straight-line fits: least squares with its standard errors and test (SciPy’s linregress), and the robust median-of-slopes estimators of Theil and Sen (theilslopes) and Siegel (siegelslopes).

See the book entry More descriptive statistics and robust regression.

Structs§

LinregressResult
The result of linregress.
RobustLine
The result of theilslopes and siegelslopes (the latter has no confidence interval).

Functions§

linregress
The least-squares line y ≈ slope · x + intercept (SciPy’s linregress), from the centred sums Sxx, Sxy, Syy: slope = Sxy/Sxx, r = Sxy/√(Sxx Syy), and the slope’s standard error √((1 − r²) Syy / ((n − 2) Sxx)).
siegelslopes
Siegel’s repeated-medians line (SciPy’s siegelslopes with method='hierarchical'): for each point the median slope to every other point with a different x, the slope is the median of those, and the intercept the median of yᵢ − slope · xᵢ. Breakdown point 50 %.
theilslopes
The Theil-Sen line (SciPy’s theilslopes with method='separate'): the slope is the median of the pairwise slopes (yⱼ − yᵢ)/(xⱼ − xᵢ) over pairs with xⱼ > xᵢ, the intercept median(y) − slope · median(x). The confidence interval at level alpha (SciPy’s default 0.95) is Sen’s: order statistics of the sorted slopes at ranks (N ± z σ)/2, where σ² is the variance of Kendall’s statistic corrected for ties. Breakdown point 29 %.