Improve xarray
display of structural components for multivariate time series
#555
+468
−36
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #545
Currently
extract_components_from_idata
returns square brackets notations for thestate
coord, making it hard to select components when working with multivariate series. Things like:This PR adds a
restructure
argument toextract_components_from_idata
(defaultFalse
for backwards compatibility). WhenTrue
, it will restructure thestate
coordinates as a multi-index for easier component selection, thus enabling selections likeidata.sel(component='level')
,idata.sel(observed='gdp')
, or evenidata.sel(component='level', observed='gdp')
.Again, this is especially useful for multivariate models with multiple observed states.
More precisely, the
state
dimension is broken down into two new ones,component
andobserved
, whose coordinates will be[('level', 'gdp'), ('trend', 'gdp'), ('ar', 'gdp')], [('level', 'unemployment'), ('trend', 'unemployment'), ('ar', 'unemployment')]
.This also allows each observed state to have arbitrary model structure inside, which the current multivariate setup allows.
NB: This PR is a first pass, and in no way exhaustive -- we probably need to expand to more complex cases, that users will surface up. But at least it gets the ball rolling and should be self-sufficient to already merge.