scipy.stats.mstats.theilslopes

scipy.stats.mstats.theilslopes(y, x=None, alpha=0.95, method='separate')[source]

Computes the Theil-Sen estimator for a set of points (x, y).

theilslopes implements a method for robust linear regression. It computes the slope as the median of all slopes between paired values.

Parameters
yarray_like

Dependent variable.

xarray_like or None, optional

Independent variable. If None, use arange(len(y)) instead.

alphafloat, optional

Confidence degree between 0 and 1. Default is 95% confidence. Note that alpha is symmetric around 0.5, i.e. both 0.1 and 0.9 are interpreted as “find the 90% confidence interval”.

method{‘joint’, ‘separate’}, optional

Method to be used for computing estimate for intercept. Following methods are supported,

  • ‘joint’: Uses np.median(y - medslope * x) as intercept.

  • ‘separate’: Uses np.median(y) - medslope * np.median(x)

    as intercept.

The default is ‘separate’.

New in version 1.8.0.

Returns
medslopefloat

Theil slope.

medinterceptfloat

Intercept of the Theil line, as median(y) - medslope*median(x).

lo_slopefloat

Lower bound of the confidence interval on medslope.

up_slopefloat

Upper bound of the confidence interval on medslope.

See also

siegelslopes

a similar technique with repeated medians

Notes

For more details on theilslopes, see stats.theilslopes.