-
Notifications
You must be signed in to change notification settings - Fork 69
Dynamical Factor Models (DFM) Implementation (GSOC 2025) #446
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?
Conversation
Looks interesting! Just say when you think it's ready for review |
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
Thanks for the feedback! I'm still exploring the best approach for implementing Dynamic Factor Models. |
21560db
to
a459a1a
Compare
Some tests are failing due to missing constants. You might have lost some changes in the reset/rebasing process |
1c04f65
to
bc3fcf2
Compare
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.
Left some comments. I didn't look over the tests because they still seem like WIP, but seem to be on the right track!
7846f15
to
e15cdd3
Compare
e15cdd3
to
3b8bfe4
Compare
6496f38
to
615960b
Compare
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.
I did a deeper pass on everything except the build_symbolic_graph
method. I need to spend more time on that because it's gotten quite complex.
I'll finish ASAP.
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)
…pymc_extras/statespace/models/structural/components/regression.py
8a03197
to
ca1a86e
Compare
pymc_extras/statespace/models/DFM.py
Outdated
pt.zeros((self.k_endog, self.k_endog * (self.error_order - 1)), dtype=floatX) | ||
) | ||
if len(matrix_parts) == 1: | ||
design_matrix = factor_loadings * 1.0 |
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.
What does this line do?
self.ssm["state_cov", :, :] = factor_cov | ||
|
||
# Observation covariance matrix (H) | ||
if self.error_order > 0: |
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 seems backwards? The first case looks like it assumes error_order == 0.
This comment is based on error_sigma
appearing in the else branch
sigma_obs = self.make_and_register_variable( | ||
"sigma_obs", shape=(self.k_endog,), dtype=floatX | ||
) | ||
total_obs_var = error_sigma**2 + sigma_obs**2 |
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.
Are you sure error_sigma
should appear here? It's already appearing in Q, so is this double-counting?
* 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
Dynamical Factor Models (DFM) Implementation
This PR provides a first draft implementation of Dynamical Factor Models as part of my application proposal for the PyMC GSoC 2025 project. A draft of my application report can be found at this link.
Overview
DFM.py
with initial functionalityCurrent Status
This implementation is a work in progress and I welcome any feedback
Next Steps