Skip to content

Commit

Permalink
Merge pull request #296 from pymc-labs/pre-post-imact-bug
Browse files Browse the repository at this point in the history
Fix causal impact calculation error in synthetic control and interrupted time series
  • Loading branch information
drbenvincent authored Mar 4, 2024
2 parents d5e493c + 7541516 commit 7c621cc
Show file tree
Hide file tree
Showing 6 changed files with 270 additions and 241 deletions.
4 changes: 2 additions & 2 deletions causalpy/pymc_experiments.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,13 @@ def __init__(
# causal impact pre (ie the residuals of the model fit to observed)
pre_data = xr.DataArray(self.pre_y[:, 0], dims=["obs_ind"])
self.pre_impact = (
pre_data - self.pre_pred["posterior_predictive"].mu
pre_data - self.pre_pred["posterior_predictive"]["y_hat"]
).transpose(..., "obs_ind")

# causal impact post (ie the residuals of the model fit to observed)
post_data = xr.DataArray(self.post_y[:, 0], dims=["obs_ind"])
self.post_impact = (
post_data - self.post_pred["posterior_predictive"].mu
post_data - self.post_pred["posterior_predictive"]["y_hat"]
).transpose(..., "obs_ind")

# cumulative impact post
Expand Down
44 changes: 26 additions & 18 deletions docs/source/notebooks/geolift1.ipynb

Large diffs are not rendered by default.

57 changes: 35 additions & 22 deletions docs/source/notebooks/its_covid.ipynb

Large diffs are not rendered by default.

68 changes: 34 additions & 34 deletions docs/source/notebooks/its_pymc.ipynb

Large diffs are not rendered by default.

58 changes: 29 additions & 29 deletions docs/source/notebooks/sc_pymc.ipynb

Large diffs are not rendered by default.

280 changes: 144 additions & 136 deletions docs/source/notebooks/sc_pymc_brexit.ipynb

Large diffs are not rendered by default.

0 comments on commit 7c621cc

Please # to comment.