Friday, January 1, 2016

Matlab+Python: Theil–Sen estimator

Summary

In non-parametric statistics, there is a method for robust simple linear regression that chooses the median slope among all lines through pairs of two-dimensional sample points. It has been called the Theil–Sen estimator, Sen's slope estimator, slope selection, the single median method, the Kendall robust line-fit method, and the Kendall–Theil robust line. It is named after Henri Theil and Pranab K. Sen, who published papers on this method in 1950 and 1968 respectively.

Example

本例以Anscombe's Quartet为例,检验Theil–Sen estimator对趋势的估计效果。关于Anscombe's Quartet四组数据的特征请参考这里的描述。这里的代码整合Matlab+Python,Theil–Sen estimator计算调用Python Scipy。
Fig. 1
观察Fig. 1,蓝线是简单线性回归,红线是Theil–Sen estimator,两条灰虚线之间表示α=0.9水平下的置信区间。A与D,蓝线与红线基本重合,A的蓝线基本可以反映数据的趋势,但D的蓝线显然不能反映数据分布的趋势,此处的红线也还是不能很好的剔除异常值的影响。B组数据并非呈现线性趋势,所以红线并不会比蓝线更好。C组红线非常好地剔除一个异常值的影响,很好地诠释其他10个数据分布趋势。综上,Theil–Sen estimator的确比简单线性回归优秀,但是也同样存在着无效的情况。
以下Fig. 2~5是不同α水平下的置信区间范围,很显然,随着α增大区间范围增大,更多的数据进入置信区间。
Fig. 2
Fig. 3
Fig. 4
Fig. 5
Fig. 6

References

No comments:

Post a Comment