0
$\begingroup$

I'm working on a machine learning algorithm and trying to evaluate the model based on a guide online. No matter how I change the features of the model, the results of both tests are always 0. Is there a problem with calculation or the model? I'm having a hard time understanding why this is happening from reading online, so anything helps! I'll place relevant code below

# Applying model to be used with the statsmodel package (needs a constant) 
X2 = sm.add_constant(X)

# create a OLS model
model = sm.OLS(Y, X2)

# fit the data
est = model.fit()

_, pval, __, f_pval = diag.het_white(est.resid, est.model.exog, retres = False)
print(pval, f_pval)

_, pval, __, f_pval = diag.het_breuschpagan(est.resid, est.model.exog)
print(pval, f_pval)

and the output

0.0 0.0
----------------------------------------------------------------------------------------------------
0.0 0.0

$\endgroup$
0
$\begingroup$

Not an answer, but an extended comment because there isn't enough information.

It might be you running an old version, I am on 0.11.1 and according to the the vignette, there isn't an argument for "retres=":

statsmodels.stats.diagnostic.het_white(resid, exog)

And it returns:

lmfloat
The lagrange multiplier statistic.

lm_pvalue :float
The p-value of lagrange multiplier test.

fvaluefloat
The f-statistic of the hypothesis that the error variance does not depend on x. This is an alternative test variant not the original LM test.

f_pvaluefloat
The p-value for the f-statistic.

If I run it on an example dataset it works, so you need to show some examples of your dataset..

import numpy as np
import statsmodels.api as sm
from statsmodels.stats import diagnostic

np.random.seed(100)
X = np.random.normal(0,1,(50,5))
X2 = sm.add_constant(X)
Y = np.random.normal(0,1,50)

model = sm.OLS(Y, X2)
est = model.fit()

_, pval, __, f_pval = diagnostic.het_white(est.resid, est.model.exog)
print(pval, f_pval)
#0.42367606624805376 0.47817512202760115

_, pval, __, f_pval = diagnostic.het_breuschpagan(est.resid, est.model.exog)
print(pval, f_pval)
#0.6693669871020579 0.6990024119539573
| cite | improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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