For the sm.OLS() models, there is a provided Ftest and a p value inside the .summary() function.

for Robust Linear Regression sm.RLM() there is no such value in the .summary() function yet there is a .f_test() function in the methods, so following the .Example on OLS, i performed an F test, to tests that each coefficient is jointly statistically significantly different from zero for my RLM:

import statsmodels.api as sm
from sklearn.preprocessing import PolynomialFeatures

feat_d # my feature data of shape (N Samples,1)
#constructed polynimial features with sklearn
polynomial_features= PolynomialFeatures(degree=4) # varying degrees are tryed out
feat_for_fit = polynomial_features.fit_transform(feat_d)
est = sm.RLM(y, feat_for_fit).fit()
A = np.identity(len(est.params))
A = A[1:,:]
Ftest = est.f_test(A)
>>> overflow encountered in multiply
>>> covariance of constraints does not have full rank. The number of constraints is 5, but rank is 3

>>> <F test: F=array([[4549.62604321]]), p=0.0, df_denom=1.52e+04, df_num=8>

The F test Values are all very large(positive and negative) and the p values are all either 0.0 or 1 depending on polynomial degree. I am very skeptical if this is even the right test. But from my understanding of multiple linear regression and This Site's, it is correct to use this test.

This is the example from statsmodels, just with RLM instead of OLS. It does not display the messages while performing the F test. This might be the cause.

import numpy as np
import statsmodels.api as sm
data = sm.datasets.longley.load(as_pandas=False)
data.exog = sm.add_constant(data.exog)
results = sm.RLM(data.endog, data.exog).fit()
A = np.identity(len(results.params))
A = A[1:,:]
>>> <F test: F=array([[354.23793113]]), p=3.6439243341019165e-10, df_denom=9, df_num=6>

additional information: I have a dataset with 21 k Samples and Fit models with 16k, the rest is for validation.

Some Plots:

R2 Positive, negative F-test, p = 1 R2 Positive, positive F-test, p = 0.0000000


1 Answer 1


The occurring error of p-value = 1 and ´>>> overflow encountered in multiply´ was evadable by studentizing the feature and target Data as suggestetby this answer


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.