I can't get linear regression in python StatsModels to fit a data series with a negative slope - neither RLM nor OLS are working for me. Take a very simple case where I'd expect a slope of -1:
In [706]: ts12 = pandas.TimeSeries(data=[5,4,3,2,1],index=[1,2,3,4,5])
In [707]: ts12_h = sm.RLM(ts12.values, ts12.index, M=sm.robust.norms.HuberT())
In [708]: ts12_fit = ts12_h.fit()
In [710]: ts12_fit.fittedvalues
Out[710]: array([ 0.62321739, 1.24643478, 1.86965217, 2.49286956, 3.11608696])
In [729]: ts12_fit.params
Out[729]: array([ 0.62321739])
In [733]: ts12_ols = sm.OLS(ts12.values, ts12.index)
In [734]: ts12_ols_fit = ts12_ols.fit()
In [736]: ts12_ols_fit.fittedvalues
Out[736]: array([ 0.63636364, 1.27272727, 1.90909091, 2.54545455, 3.18181818])
The fitted params for both RLM and OLS give a slope of 0.6... and the fitted values reflect that with an upward trend. Ordinary least squares regression from scipy gives the expected result with a slope of -1:
In [737]: from scipy import stats
In [738]: stats.linregress([1,2,3,4,5], [5,4,3,2,1])
Out[738]: (-1.0, 6.0, -1.0, 1.2004217548761408e-30, 0.0)
I must be missing something obvious but the usual means are not turning up anything.