Skip to content

Conversation

jessegrabowski
Copy link
Member

This PR adds support for exogenous variables in BayesianVARMAX via the observation intercept. Same deal as SARIMAX -- it's implemented in a way that minimizes the number of states in the system.

Unlike Statsmodels, we have support for each observed state to have its own regressors by passing a dictionary. If you just pass a list, everyone shares the same data.

Example 1: Everyone shares data, data names are auto-assigned

mod = BayesianVARMAX(
        endog_names=["y1", "y2", "y3"],
        order=(1, 0),
        k_exog=2,
    )

Example 2: Everyone shares data, data names are provided

mod = BayesianVARMAX(
        endog_names=["y1", "y2", "y3"],
        order=(1, 0),
        exog_state_names=['x1', 'x2']
    )

Example 3: Each observes state (endogenous state) has its own exogenous regressors. y3 has no exogenous regressors at all, so it is omitted from the dictionary. It just so happens that each observed has its own regressors, but they could also share all or a subset.

mod = BayesianVARMAX(
        endog_names=["y1", "y2", "y3"],
        order=(1, 0),
        exog_state_names={'y1':['x1', 'x2'], 'y2':['x3']}
    )

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for exogenous regressors to the BayesianVARMAX model via observation intercepts. The implementation allows for flexible configuration where exogenous variables can be shared across all endogenous states or specified individually for each state.

Key changes include:

  • Added exog_state_names and k_exog parameters to support different exogenous variable configurations
  • Implemented data handling and parameter creation for exogenous regression coefficients
  • Added comprehensive validation logic for parameter combinations
  • Extended test coverage for all exogenous variable configuration scenarios

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
pymc_extras/statespace/models/VARMAX.py Core implementation adding exogenous regressor support with parameter validation, data handling, and symbolic graph construction
tests/statespace/models/test_VARMAX.py Comprehensive test suite covering all exogenous variable configuration cases and error conditions

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@jessegrabowski jessegrabowski requested a review from Copilot August 25, 2025 15:06
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@jessegrabowski jessegrabowski requested a review from Copilot August 25, 2025 16:51
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Contributor

@AlexAndorra AlexAndorra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quite the monster review! Thanks @jessegrabowski 🤩

@AlexAndorra AlexAndorra merged commit d5f8f76 into pymc-devs:main Aug 26, 2025
17 checks passed
andreacate pushed a commit to andreacate/pymc-extras that referenced this pull request Aug 27, 2025
* First pass on exogenous variables in VARMA

* Adjust state names for API consistency

* Allow exogenous variables in BayesianVARMAX

* Eagerly simplify model where possible

* Typo fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancements New feature or request statespace
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants