-
Notifications
You must be signed in to change notification settings - Fork 69
Allow exogenous regressors in BayesianVARMAX
#567
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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
andk_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.
There was a problem hiding this 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.
There was a problem hiding this 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.
There was a problem hiding this 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.
There was a problem hiding this 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 🤩
* 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
* Added new file DFM.py for GSOC 2025 Dynamical Factor Models * Add initial notebook on custom DFM implementation * Update of DFM draft implementation In the notebook a comparison between the custom DFM and the implemented DFM (which has an hardcoded version of make_symbolic_graph, that work just in this case) * Aligning the order of vector state with statsmodel and updating the test * Added test_DFM_update_matches_statsmodels and small corrections to DFM.py * Updating test following test_ETS.py and small adjustment for exog variables in DFM.py * Added support for joint VAR modelling (error_var=True) * Adding a first implemntation of exogeneous variable support based on pymc_extras/statespace/models/structural/components/regression.py * Completing the implementation of exogeneous varibales support * Small adjustments and improvements in DFM.py * Small adjustments and improvements in DFM.py * Adjustments after Jesse review * Adjustments following Jesse suggestions and added tests for exog support * Added new DFM example notebook and deleted an old version of custom DFM example * Add tests for names/dims/coords * De-duplicate exogenous dim between DFM and SARIMAX * Small adjustments and refactoring after code review * Allow exogenous regressors in `BayesianVARMAX` (#567) * 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 * Small adjustments in the tests after review * Harmonizing names for EXOG dimension between DFM and VARMAX * Corrections in the notebook and add a small comment in DFM.py * Add deterministic advi (#564) * Add first version of deterministic ADVI * Update API * Add a notebook example * Add to API and add a docstring * Change import in notebook * Add jax to dependencies * Add pytensor version * Fix handling of pymc model * Add (probably suboptimal) handling of the two backends * Add transformation * Follow Ricardo's advice to simplify the transformation step * Fix naming bug * Document and clean up * Fix example * Update pymc_extras/inference/deterministic_advi/dadvi.py Co-authored-by: Ricardo Vieira <[email protected]> * Respond to comments * Fix with pre commit checks * Update pymc_extras/inference/deterministic_advi/dadvi.py Co-authored-by: Jesse Grabowski <[email protected]> * Implement suggestions * Rename parameter because it's duplicated otherwise * Rename to be consistent in use of dadvi * Rename to `optimizer_method` and drop jac=True * Add jac=True back in since trust-ncg complained * Make hessp and jac optional * Harmonize naming with existing code * Fix example * Switch to `better_optimize` * Replace with pt.split --------- Co-authored-by: Martin Ingram <[email protected]> Co-authored-by: Ricardo Vieira <[email protected]> Co-authored-by: Jesse Grabowski <[email protected]> * Small adjustments in the notebook --------- Co-authored-by: jessegrabowski <[email protected]> Co-authored-by: Jesse Grabowski <[email protected]> Co-authored-by: Martin Ingram <[email protected]> Co-authored-by: Martin Ingram <[email protected]> Co-authored-by: Ricardo Vieira <[email protected]>
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
Example 2: Everyone shares data, data names are provided
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.