Skip to content

feat!: graduate StateSpaceTimeSeries, deprecate BayesianBasisExpansionTimeSeries - #1113

Draft
anevolbap wants to merge 3 commits into
issue-758-ssts-variable-selectionfrom
issue-758-ssts-graduate
Draft

feat!: graduate StateSpaceTimeSeries, deprecate BayesianBasisExpansionTimeSeries#1113
anevolbap wants to merge 3 commits into
issue-758-ssts-variable-selectionfrom
issue-758-ssts-graduate

Conversation

@anevolbap

@anevolbap anevolbap commented Jul 30, 2026

Copy link
Copy Markdown
Collaborator

Part of #982 and of #758 (P0). Closes #696. Stacked on #1112, review that one first. Targets pymc6_and_pymcmarketing1_migration.

  • Remove the FutureWarning from StateSpaceTimeSeries.
  • Flip BayesianBasisExpansionTimeSeries to a DeprecationWarning pointing at StateSpaceTimeSeries, with removal one minor release out. Note the visibility change: the old FutureWarning showed by default, while Python hides DeprecationWarning outside __main__. DeprecationWarning is what the rest of the codebase uses (experiments/base.py, the design-alias deprecations), so this follows house style, but users who ignored the experimental warning will now see nothing until removal.
  • Edge-case guards and tests: short series, seasonal_length below 2, missing values in y (the Kalman filter imputes them natively, which covers the P2 item of Feature parity with Google's CausalImpact #758 for this model), integer-index error path, and a warning when out-of-sample dates do not continue the training frequency.
  • New notebook interrupted-time-series-bsts.ipynb: trend and seasonality, then covariates, then spike-and-slab with inclusion probabilities. Added to gallery.yaml.
  • Document the smoothed-posterior R2 caveat on score().

Open question before this leaves draft: #758 and #982 both ask whether BayesianBasisExpansionTimeSeries should be deprecated at all. If you would rather keep both models, I can drop the deprecation commit and still graduate StateSpaceTimeSeries.

Three items from #982 are deliberately not here, since each is a separate behavior change worth its own review: making StateSpaceTimeSeries the default model for InterruptedTimeSeries, exporting it at top level, and adding a cp.InterruptedTimeSeries(data, treatment_time) convenience entry point. The first depends on data-scaled priors (#935). The np.ndarray signature item listed in #982 is already stale: both time-series models take xr.DataArray today, and InterruptedTimeSeries.algorithm() dispatches on PyMCModel against RegressorMixin, not on the model class.

Note for reviewers: score() is computed on smoothed in-sample predictions, so it reads optimistic relative to other models. Documented, not changed here.

Verified locally with pymc 6.2.0, arviz 1.2.0, pymc-extras 0.14.0: 1412 passed, 17 skipped, and 100% patch coverage against the base branch. The notebook was re-executed end to end on that stack (runner.py --full, no mocks): the covariate model estimates the effect at 1.81 against a true 2.0 and recovers beta_exog at 2.0 and -1.5. The az.summary call now passes ci_kind="hdi", ci_prob=0.94 explicitly, since arviz 1.x defaults to 0.89 ETI and the notebook was silently reporting a different interval from the rest of the docs. Sampling now uses 4 chains, tune=1000 and target_accept=0.95: the trend-only and covariate models are clean apart from 3 divergences, down from 15 in the pymc 5 run. The selection model still reports rhat above 1.01, which is inherent to a spike-and-slab posterior rather than a sampling setup problem, so the notebook says so and points the reader at the inclusion probabilities.

@review-notebook-app

Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@read-the-docs-community

read-the-docs-community Bot commented Jul 30, 2026

Copy link
Copy Markdown

Documentation build overview

📚 causalpy | 🛠️ Build #33906261 | 📁 Comparing d598dd7 against latest (7e23946)

  🔍 Preview build  

245 files changed · + 30 added · ± 194 modified · - 21 deleted

+ Added

± Modified

- Deleted

@codecov

codecov Bot commented Jul 31, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.20%. Comparing base (e855435) to head (d598dd7).

Additional details and impacted files
@@                        Coverage Diff                         @@
##           issue-758-ssts-variable-selection    #1113   +/-   ##
==================================================================
  Coverage                              97.19%   97.20%           
==================================================================
  Files                                    120      120           
  Lines                                  21100    21143   +43     
  Branches                                1140     1142    +2     
==================================================================
+ Hits                                   20508    20551   +43     
  Misses                                   396      396           
  Partials                                 196      196           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@anevolbap
anevolbap force-pushed the issue-758-ssts-graduate branch 2 times, most recently from 7b0298e to f82cde5 Compare July 31, 2026 03:49
@anevolbap
anevolbap force-pushed the issue-758-ssts-graduate branch 2 times, most recently from 29a1d0c to d1c2cec Compare July 31, 2026 17:28
@anevolbap
anevolbap force-pushed the issue-758-ssts-graduate branch from d1c2cec to 27c2dce Compare August 3, 2026 20:19
@anevolbap
anevolbap force-pushed the issue-758-ssts-graduate branch from 27c2dce to 29c2147 Compare August 4, 2026 02:36
Reject seasonal_length below 2 (previously an obscure ZeroDivisionError
inside pymc-extras) and warn when out-of-sample dates do not continue the
training frequency (forecast values map onto X's dates by position). Lock
missing-value support with a test: the Kalman filter handles NaN in y
natively and predictions stay finite, which covers the P2 item of #758
for this model.
…nTimeSeries

Remove the experimental FutureWarning from StateSpaceTimeSeries: the
API is now aligned with the other PyMCModel subclasses, covariates and
variable selection are supported, and edge cases are guarded and
tested. Flip BayesianBasisExpansionTimeSeries to DeprecationWarning
pointing at StateSpaceTimeSeries, removal one minor release out.

Completes the P0 graduation decision for #758.
New its_bsts.ipynb covers the graduated StateSpaceTimeSeries with
InterruptedTimeSeries: trend and seasonality only, exogenous control
covariates, and spike-and-slab covariate selection with inclusion
probabilities. Executed end to end. Adds the Brodersen et al. (2015)
reference, updates the ITS toctree and the ARCHITECTURE.md model list,
documents the smoothed-posterior R2 caveat on score(), and drops a
stale BSTS comment in the ITS experiment.

Closes #696 and the documentation item of #758 P0.
@anevolbap
anevolbap force-pushed the issue-758-ssts-graduate branch from 29c2147 to d598dd7 Compare August 4, 2026 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant