1

I am using the below code to perform a TukeyBiweight(Bisquare) Robust linear Model Regression of data X and y.

from sklearn import datasets, linear_model
from sklearn.metrics import mean_squared_error, r2_score
import statsmodels.api as sm
X = sm.add_constant(X)
rlm_model = sm.RLM(y, X, m=sm.robust.norms.TukeyBiweight())
rlm_results = rlm_model.fit()

Although the code runs without issue, the summary is what worries me. After running the below:

rlm_results.summary()

The following is outputted.

                   Robust linear Model Regression Results                    
==============================================================================
Dep. Variable:                      y   No. Observations:               106721
Model:                            RLM   Df Residuals:                   106719
Method:                          IRLS   Df Model:                            1
Norm:                          HuberT                                         
Scale Est.:                       mad                                         
Cov Type:                          H1                                         
Date:                Wed, 08 Jun 2022                                         
Time:                        19:44:34                                         
No. Iterations:                    50                                         
==============================================================================
                 coef    std err          z      P>|z|      [0.025      0.975]
------------------------------------------------------------------------------
const          0.0377   9.14e-06   4117.608      0.000       0.038       0.038
x1            -0.0076   1.58e-05   -478.404      0.000      -0.008      -0.008
==============================================================================

If the model instance has been used for another fit with different fit
parameters, then the fit options might not be the correct ones anymore .

The model and method are correct, but the Norm it says was not the norm that I fed to the M estimator field. Does anyone know why this occurs?

  • wrong keyword name. The norm keyword is capital `M` https://www.statsmodels.org/dev/generated/statsmodels.robust.robust_linear_model.RLM.html That's not a good choice of name :( – Josef Jun 08 '22 at 20:29
  • I added RLM to https://github.com/statsmodels/statsmodels/issues/7741 Hopefully RLM warns about invalid keywords in the next release . – Josef Jun 08 '22 at 20:33

0 Answers0