Skip to content

extract_components_from_idata doesn't handle multivariate time series #544

@AlexAndorra

Description

@AlexAndorra

There is a bug in extract_components_from_idata when working with multivariate time series. The following model will show it:

ll = pmss.structural.LevelTrendComponent(
    name="trend", order=2, innovations_order=[0, 1], observed_state_names=presidents # list of 5 names for 5 multivar TS
)
ar = pmss.structural.AutoregressiveComponent(name="ar", order=1, observed_state_names=presidents)
noise = pmss.structural.MeasurementError(name="noise", observed_state_names=presidents)
structural_mod = (ll + ar + noise).build()

Once fitted, post_pred = structural_mod.sample_conditional_posterior(idata) returns 15 hidden states, as it should:

array(['level[chirac2]', 'trend[chirac2]', 'level[sarkozy]', 'trend[sarkozy]',
       'level[hollande]', 'trend[hollande]', 'level[macron]', 'trend[macron]',
       'level[macron2]', 'trend[macron2]', 'L1[chirac2]', 'L1[sarkozy]',
       'L1[hollande]', 'L1[macron]', 'L1[macron2]'], dtype='<U15')

but then, structural_mod.extract_components_from_idata(post_pred) only returns one AR instead of 5:

array(['trend[level[chirac2]]', 'trend[trend[chirac2]]',
       'trend[level[sarkozy]]', 'trend[trend[sarkozy]]',
       'trend[level[hollande]]', 'trend[trend[hollande]]',
       'trend[level[macron]]', 'trend[trend[macron]]', 'trend[level[macron2]]',
       'trend[trend[macron2]]', 'ar'], dtype='<U22')

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions