Skip to content

Breusch-Godfrey test dimensions mismatch #9090

Closed

Description

@ikuzmin404

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)

Activity

  1. bashtage commented on Dec 14, 2023

    @bashtage
    Member

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

  2. ikuzmin404 commented on Dec 17, 2023

    @ikuzmin404
    Author

    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).

  3. added a commit that references this issue on Oct 4, 2026
    708b1ee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions