perfect fit (in rlm)

Author: wesmCreated Aug 25, 2011Updated Sep 28, 2026
Labelsdesigncomp-robustcorner-casetype-possible-bug

Original Launchpad bug 790770: https://bugs.launchpad.net/statsmodels/+bug/790770 Reported by: josef-pktd (joep).

look at what happens in the models, model results when we have a perfect fit, and decide what to do in this cases example for rlm, but there might be similar problems in other cases

mailinglist 2011-05-31 for rlm having a zero residual doesn't cause an exception anymore, but having a perfect fit can produce nans in some results (scale=0 and 0/0 division)

import numpy as np
import scikits.statsmodels.api as sm
x = np.array([0, 0.96, 2.18])
levels = np.array([2.8, 2.8, 2.8])
res1 = sm.RLM(endog=levels,exog=sm.add_constant(x),M=sm.robust.norms.HuberT()).fit()
print res1.params
print res1.sresid
print res1.scale

>>> print res1.params
[  2.77555756e-17   2.80000000e+00]
>>> print res1.sresid
[ nan  nan  nan]
>>> print res1.scale
0.0