yatsm.regression.robust_fit module

Perform an iteratively re-weighted least squares ‘robust regression’. Basically a clone of statsmodels.robust.robust_linear_model.RLM without all the lovely, but costly, creature comforts.

Reference:
http://statsmodels.sourceforge.net/stable/rlm.html http://cran.r-project.org/web/packages/robustreg/index.html http://cran.r-project.org/doc/contrib/Fox-Companion/appendix-robust-regression.pdf

Run this file to test performance gains. Implementation is ~3x faster than statsmodels and can reach ~4x faster if Numba is available to accelerate.

yatsm.regression.robust_fit.bisquare(resid, c=4.685)[source]

Returns weighting for each residual using bisquare weight function

Parameters:
  • resid – residuals to be weighted
  • c – tuning constant for Tukey’s Biweight (default: 4.685)
Returns:

weights for residuals

Return type:

weight (ndarray)

Reference:
http://statsmodels.sourceforge.net/stable/generated/statsmodels.robust.norms.TukeyBiweight.html
yatsm.regression.robust_fit.mad(resid, c=0.6745)[source]

Returns Median-Absolute-Deviation (MAD) for residuals

Parameters:
  • resid – residuals
  • c – scale factor to get to ~standard normal (default: 0.6745) (i.e. 1 / 0.75iCDF ~= 1.4826 = 1 / 0.6745)
Returns:

MAD ‘robust’ variance estimate

Return type:

float

Reference:
http://en.wikipedia.org/wiki/Median_absolute_deviation