You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add PiecewiseITS experiment for known interruption dates (#614)
* initial commit - MVP
* Expand Piecewise ITS notebook with new examples and explanations
Added detailed explanations comparing Piecewise ITS to Regression Discontinuity and Regression Kink designs. Introduced new real-world scenarios for level and slope changes, multiple interventions, and level-only models. Enhanced example code and output to illustrate these cases, improving clarity and practical guidance for users.
* Revise and clarify Piecewise ITS notebook explanations
Improved clarity and conciseness throughout the Piecewise Interrupted Time Series (ITS) notebook. Rewrote several sections for better readability, combined and streamlined example scenarios, and clarified distinctions between level and slope changes, as well as the relationship to regression discontinuity and regression kink designs.
* Refactor PiecewiseITS to use patsy step/ramp stateful transforms
Refactors the PiecewiseITS experiment to use flexible patsy formulas with new stateful step() and ramp() transforms for specifying level and slope changes at interventions. Adds the causalpy.transforms module with robust, datetime-aware step/ramp transforms, updates tests to cover new formula interface and transform behavior, and improves documentation and error handling. This enables more flexible modeling of multiple interventions and supports both numeric and datetime time columns.
* Expand PiecewiseITS notebook with formula API details
Added a new section describing the formula-based API for PiecewiseITS, including explanations of the custom step() and ramp() transforms, usage examples, and clarification on how the counterfactual is computed. This improves documentation clarity and helps users understand flexible model specification.
* Add effect_summary compatibility to PiecewiseITS
Implemented creation of post_impact, datapost, and post_pred attributes in PiecewiseITS for compatibility with effect_summary() from BaseExperiment. Added tests to verify effect_summary works for both OLS and PyMC models and that the new attributes are correctly created.
* Clarify usage of step and ramp transforms in docs
* Enhance piecewise ITS notebook with math and intro code
Added mathematical definitions for step and ramp functions using LaTeX for clarity, and moved import/setup code to the top of the notebook for better organization. Improved explanations of function arguments and removed duplicate import cell.
* Expand and clarify Piecewise ITS notebook introduction
The introductory markdown in the piecewise_its_pymc.ipynb notebook has been significantly expanded and reorganized. The new content provides clearer explanations of when to use Piecewise ITS, the distinction between level and slope changes, the mathematical model, and its relationship to regression discontinuity and regression kink designs. Redundant sections were removed and a more structured, didactic flow was introduced.
* Clarify level and slope change concepts in notebook
Expanded explanations of level and slope changes in piecewise ITS, referencing a new illustrative figure. Added a code cell to display the figure, and clarified the description of multiple interventions for improved instructional clarity.
* Add model formula table to piecewise ITS notebook
Inserted a markdown cell with a table summarizing model formulas for single and two intervention cases, covering level, slope, and combined effects. This provides clearer guidance on specifying models for each panel in the notebook.
* Revise and restructure piecewise ITS notebook intro
Condenses and reorganizes introductory explanations for piecewise interrupted time series (ITS), splitting out key concepts, model details, and comparisons to related methods into clearer, more focused sections. Adds collapsible dropdowns and card formatting for scenario examples, and improves clarity and flow for users learning the model and its API.
* Add extensive coverage tests for PiecewiseITS
Adds a comprehensive suite of tests for the PiecewiseITS class, including class and instance attribute checks, formula parsing, plotting, PyMC integration, counterfactuals, data generation, and error handling. Also updates the interrogate badge to reflect increased coverage.
* Add references and citations for piecewise ITS notebook
Added detailed references and in-text citations to the piecewise_its_pymc.ipynb notebook to support methodological explanations. Updated the references.bib file with key literature on segmented regression and interrupted time series analysis. Improved clarity on model parameterization and corrected the references section to use the Sphinx bibliography directive.
* run pre-commit checks
* Fail fast on PiecewiseITS threshold parsing.
Enforce a single step/ramp time variable and canonicalize interruption thresholds at initialization so invalid mixed-variable or malformed thresholds fail early with clear errors.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Implement effect_summary for PiecewiseITS.
Add PiecewiseITS effect_summary support for both OLS and PyMC paths using shared reporting helpers so PiecewiseITS no longer falls back to BaseExperiment's NotImplementedError.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Increase PiecewiseITS patch coverage for effect summary.
Add a focused test for unsupported period handling in PiecewiseITS effect_summary and simplify OLS array conversion logic to keep the new effect summary path fully exercised.
Co-authored-by: Cursor <cursoragent@cursor.com>
* Increase patch coverage for transforms and PiecewiseITS validation
Add tests for: datetime Series (non-Index) paths, chunked memorize_chunk
origin tracking, pd.Timestamp threshold parsing, step/ramp variable not
in data, and non-numeric/non-datetime time column validation.
Made-with: Cursor
* Add _default_model_class and minor plot fix for BaseExperiment compatibility
After rebase onto main, PiecewiseITS needs _default_model_class = LinearRegression
to comply with the enforced BaseExperiment abstract methods (#694). Also simplify
ax[1 + 1] to ax[2].
Made-with: Cursor
---------
Co-authored-by: Cursor <cursoragent@cursor.com>
0 commit comments