You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems that there is a bug in the robust linear model
Using statsmodels '0.6.1', the following code freezes the python console.
This snippet is simply trying to fit a very simple linear dataset y = 10.x
from statsmodels.robust.robust_linear_model import RLM as sm_RLM
from statsmodels.tools.tools import add_constant as sm_add_constant
x = np.arange(0,10,1)
y = np.range(0,100,10)
model = sm_RLM(y,sm_add_constant(x))
result = model.fit()
Am I wrong ?
The text was updated successfully, but these errors were encountered:
My guess is that, if the interpreter becomes frozen and works full cpu time, then the linear algebra library BLAS/Lapack cannot handle nans or infs. Something similar happened to me in the past with ATLAS on Windows. Other libraries like MKL raise an exception for invalid values.
The main point is that RLM has problems handling perfect prediction. If there is no noise, then the variance is zero, and we end up with a 0/0 nan or x/0 infs that might be used in some linalg operations (pinv/svd).
Short term solution is to add a little bit of noise if it's a perfect prediction case, y = y + 1e-6 * np.random.randn(y.shape[0])
or something like this.
There is a branch/PR waiting that tries to make the zero variance case more robust, but I don't know if I will get back to it very soon.
Hello,
It seems that there is a bug in the robust linear model
Using statsmodels '0.6.1', the following code freezes the python console.
This snippet is simply trying to fit a very simple linear dataset y = 10.x
Am I wrong ?
The text was updated successfully, but these errors were encountered: