pymc-experimental icon indicating copy to clipboard operation
pymc-experimental copied to clipboard

Feature: allow multiple PymcStateSpace instances via name parameter

Open opherdonchin opened this issue 1 month ago • 2 comments

Summary

Add a name: str parameter to PymcStateSpace so multiple independent state-space models can coexist in a single PyMC model without name collisions.

Motivation

  • Many real problems combine several latent processes (e.g., multiple subjects, multiple modalities, etc.).
  • Currently, internal RV/graph names collide; a name kwarg scopes internal variables and allows clean composition.

Proposed API

ssm = PymcStateSpace(
    ...,
    name="vision",   # optional, defaults to existing behavior if omitted
)
  • When name is provided, internal RVs/coordinates are prefixed/namespaced accordingly.
  • When omitted, behavior is 100% backward compatible.

Docs / Example

  • Docstring update for PymcStateSpace parameters.

Performance / Risks

  • Negligible performance impact (string prefixing only).
  • No breaking changes expected.

Reference implementation

  • Fork/branch: https://github.com/opherdonchin/pymc-extras
  • Happy to open a PR if maintainers approve the direction.

Questions for maintainers

  • Any preferred naming convention for namespacing (e.g., {name}::var vs {name}_var)?

opherdonchin avatar Oct 24 '25 21:10 opherdonchin

This is OK for me. The convention would be name_var. You will need something in the __init__ method of the different models (BayesianSARIMAX, VARMAX, ETS, DFM), but also in the build method of the Structural.

@Dekermanjian @AlexAndorra for visibility/more opinions.

jessegrabowski avatar Oct 27 '25 01:10 jessegrabowski

I like it. Good idea @opherdonchin ! I prefer {name}_var for the convention too. Let us know when we can review or help on the PR!

AlexAndorra avatar Oct 27 '25 14:10 AlexAndorra