
a robust linear regression method, first proposed by Theil (1950). The slope of the regression line is estimated as the median of all pairwise slopes between each pair of points in the data set. Because this number of pairs increases quadratically with the number of data points, we have implemented a somewhat less computationally intensive procedure, the incomplete theil regression. In the incomplete method we first split the data set of N data points (x_{i}, y_{i}), i = 1..N, in two equal sets of size N/2 and then calculate N/2 slopes as
m_{i} = (y_{N/2+i}  y_{i}) / (x_{N/2+i}  x_{i}), for i = 1..N/2. 
The regression slope m is calculated as the median of these N/2 values m_{i}.
Given the slope m, the offset b is calculated as the median of the N values b_{i}= y_{i}  m·x_{i}.
The theil regression has a breakdown point of 29.3%, which means that it can tolerate arbitrary corruption of up to 29.3 of the input datapoints without degradation of its accuracy
© djmw, July 10, 2013