Skip to content

Commit 00b8729

Browse files
committed
#58 add shaded causal impact to plot
1 parent 14b1fb7 commit 00b8729

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

causalpy/pymc_experiments.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,25 @@ def plot(self):
111111
plot_xY(self.datapost.index, self.post_impact_cumulative, ax=ax[2])
112112
ax[2].axhline(y=0, c="k")
113113

114+
# Shaded causal effect
115+
ax[0].fill_between(
116+
self.datapost.index,
117+
y1=az.extract(
118+
self.post_pred, group="posterior_predictive", var_names="y_hat"
119+
).mean("sample"),
120+
y2=np.squeeze(self.post_y),
121+
color="C0",
122+
alpha=0.25,
123+
label="Causal impact",
124+
)
125+
ax[1].fill_between(
126+
self.datapost.index,
127+
y1=self.post_impact.mean(["chain", "draw"]),
128+
color="C0",
129+
alpha=0.25,
130+
label="Causal impact",
131+
)
132+
114133
# Intervention line
115134
for i in [0, 1, 2]:
116135
ax[i].axvline(

causalpy/skl_experiments.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,14 @@ def plot(self):
9999
y2=np.squeeze(self.post_y),
100100
color="C0",
101101
alpha=0.25,
102-
label="causal impact",
102+
label="Causal impact",
103103
)
104104
ax[1].fill_between(
105105
self.datapost.index,
106106
y1=np.squeeze(self.post_impact),
107107
color="C0",
108108
alpha=0.25,
109-
label="causal impact",
109+
label="Causal impact",
110110
)
111111

112112
# Intervention line

0 commit comments

Comments
 (0)