statsmodels icon indicating copy to clipboard operation
statsmodels copied to clipboard

Breusch-Godfrey test dimensions mismatch

Open ikuzmin404 opened this issue 2 years ago • 2 comments

I'm trying to use Breusch-Godfrey test for ARDL(0, q) residuals, and I get a "ValueError: all the input array dimensions except for the concatenation axis must match exactly". It is due to the fact that list of residuals is shorter than list of exogenous variables by 2. Is it possible to omit the first q rows of exog_old before calling np.column_stack, or there is some econometric background for them staying there? изображение

Here is some example code: data = pd.DataFrame(np.random.rand(100, 2), columns=['x', 'y'])

model_ardl = ARDL(endog=data.y, lags=0, exog=data[['x']], order=2, causal=False).fit()

acorr_breusch_godfrey(model_ardl)

ikuzmin404 avatar Dec 12 '23 22:12 ikuzmin404

Thanks for reporting. I will need to take a look at this, and possibly some other tests for ARDL compatability.

bashtage avatar Dec 14 '23 07:12 bashtage

In case of Breuch-Godfrey, the whole fix was just as follows (I added it right after setting these variables and it worked):

if nobs < len(exog_old):
    exog_old = exog_old[-nobs:]

I guess the same thing will be with other tests - just take last n_obs exogenous and that's it. I tested it against similar code in R, and it returned pretty much the same results (on my data I got chi2 test statistic of 22.621 in R and 22.619 in Statsmodels).

ikuzmin404 avatar Dec 17 '23 12:12 ikuzmin404