Skip to content

Commit 7c621cc

Browse files
authored
Merge pull request #296 from pymc-labs/pre-post-imact-bug
Fix causal impact calculation error in synthetic control and interrupted time series
2 parents d5e493c + 7541516 commit 7c621cc

File tree

6 files changed

+270
-241
lines changed

6 files changed

+270
-241
lines changed

causalpy/pymc_experiments.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,13 +204,13 @@ def __init__(
204204
# causal impact pre (ie the residuals of the model fit to observed)
205205
pre_data = xr.DataArray(self.pre_y[:, 0], dims=["obs_ind"])
206206
self.pre_impact = (
207-
pre_data - self.pre_pred["posterior_predictive"].mu
207+
pre_data - self.pre_pred["posterior_predictive"]["y_hat"]
208208
).transpose(..., "obs_ind")
209209

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

216216
# cumulative impact post

docs/source/notebooks/geolift1.ipynb

Lines changed: 26 additions & 18 deletions
Large diffs are not rendered by default.

docs/source/notebooks/its_covid.ipynb

Lines changed: 35 additions & 22 deletions
Large diffs are not rendered by default.

docs/source/notebooks/its_pymc.ipynb

Lines changed: 34 additions & 34 deletions
Large diffs are not rendered by default.

docs/source/notebooks/sc_pymc.ipynb

Lines changed: 29 additions & 29 deletions
Large diffs are not rendered by default.

docs/source/notebooks/sc_pymc_brexit.ipynb

Lines changed: 144 additions & 136 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)