Skip to content
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

Check model coords for unknown shapes when building predictive models #413

Merged

Conversation

jessegrabowski
Copy link
Member

Closes #412

When a user defines a time-varying parameter, he has to give it shape None when building the symbolic graph. This is because the time dimension, unlike all other dimensions, has to remain flexible.

A consequence of this is that the .type.shape information will have a None. This was assumed to always be known by the PyMCStateSpace model class, and was used when making pm.Flat RVs in predictive models (sample_conditional, sample_unconditional, impulse_response_function, and forecast). PyMC evidently doesn't let you pass None as a shape to an RV.

Since PyMCStateSpace stores the coords used to fit the model, we can just check those as a fallback to get the expected shapes of RVs. This PR does that. Tasks that require changing the shape of the time dimension will still fail (e.g. forecast), but that is always going to be true with exogenous time-varying parameters.

@jessegrabowski jessegrabowski added bug Something isn't working statespace labels Jan 12, 2025
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.

Nice touch @jessegrabowski
LGTM if tests pass

@jessegrabowski jessegrabowski merged commit 9c7a6fb into pymc-devs:main Jan 12, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working statespace
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error in sample_conditional_posterior with PyMCStateSpace model
2 participants