Skip to content

Fix hidden state extraction where there are multiple observed states #548

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

Merged
merged 1 commit into from
Jul 21, 2025

Conversation

jessegrabowski
Copy link
Member

@jessegrabowski jessegrabowski commented Jul 21, 2025

Closes #544

Hidden state extraction is currently bugged when there are multiple observed. This patches the bug by correctly summing each observed state's subset of states, then returning one new state per observed.

The linked issue pointed out that Autoregressive was broken, but actually so is any component with combined_hidden_states=True. This PR fixes all such components.

@jessegrabowski jessegrabowski added bug Something isn't working statespace labels Jul 21, 2025
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 fixes a bug in hidden state extraction when there are multiple observed states in the state space model. The issue was that the extraction logic wasn't properly handling the combination of hidden states across multiple observed series.

  • Fixes the hidden state extraction algorithm to correctly sum subsets of states for each observed state
  • Corrects a typo in the component info dictionary key from "k_enodg" to "k_endog"
  • Updates the subcomponent naming logic to handle multiple observed states properly

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
pymc_extras/statespace/models/structural/core.py Core bug fix for hidden state extraction and typo correction
tests/statespace/models/structural/test_core.py Enhanced test with autoregressive component to verify the fix

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.

Looks good, thanks for the quick fix @jessegrabowski ! Note that the linked issue was wrong in the description of the PR: this fixes #544 , not 546 (I fixed the description). I will push the fix for the latter in a few mins

@AlexAndorra AlexAndorra merged commit 0bbf0d6 into pymc-devs:main Jul 21, 2025
17 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.

extract_components_from_idata doesn't handle multivariate time series
2 participants