-
-
Notifications
You must be signed in to change notification settings - Fork 67
Multivariate Structural Statespace Components #529
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
base: main
Are you sure you want to change the base?
Multivariate Structural Statespace Components #529
Conversation
This is cool! I will review ASAP. Note that #450 is currently blocked by what I think is a pytensor bug |
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.
This is 🔥 @jessegrabowski 🤯
I just left a suggestion for what I think was a typo in the docstring. I'll merge once this is resolved, and then test all of this for our PyData tutorial -- probably this weekend.
Just a quick question: IIUC, now users can also have batched RegressionComponent
s, correct?
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.
This is 🔥 @jessegrabowski 🤯
I just left a suggestion for what I think was a typo in the docstring.
Still missing this feature are:
-
Cycle
(currently worked on by @AlexAndorra) -
Seasonal
-
Regression
(currently worked on by @Dekermanjian)
We also need to:
- Make sure that there are tests that combined LevelTrend + AR + error for two observed variables with no interaction model matches two separate models for each, given the same parameters.
- Make sure that pytensor ops are used everywhere for building the SS matrices (no numpy/scipy)
I think I'm done for a first review from you on the |
This PR lifts the requirement that models built with the structural sub-module of PyMC be univariate. It's a chonky PR, so I split it into commits. Most of the files changes are changed by the first commit, which is just reorganization of files. It is safe to ignore that one.
Here are the steps I followed:
Reorganize structural model modlue commit
Allow combination of component with different numbers of observed states
PR. I am confident this code can be improved.For now, we assume all states in a component follow the same parameterization. It's now also valid to add together the same component twice with different states to work around this (e.g.
AutoRegressive(order=1, observed_state_names=['data_1']) + Autoregressive(order=5, observed_state_names=['data_2'])
) would be a valid model with 2 observed states, but each has it's own autoregressive dynamics.When you pass a batch of observed_state_names, e.g.
LevelTrend(order=2, observed_state_names=['data_1', 'data_2'])
, the parameters will all be given a batch dimension, but will otherwise be the same as the base case.More docs coming, but I tried obsessively document what in there so far.
The logic for extending the components is pretty straight-forward -- mostly copying + block_diag or concat, but there are some corner cases that need attention.
This PR should be seen as a companion to #450. Instead of vectorizing across the computation of a model, we're concatenating models. There will be cases where this is superior -- for example when you want to explicitly model latent interactions between components. But in other cases, this approach will be worse. I am interested in having both.