Skip to content

Commit

Permalink
Merge pull request #190 from pymc-labs/small-did-notebook-fix
Browse files Browse the repository at this point in the history
fix small error in DiD notebook
  • Loading branch information
drbenvincent authored May 26, 2023
2 parents ed61617 + d934d9e commit 39714f2
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 112 deletions.
9 changes: 7 additions & 2 deletions causalpy/pymc_experiments.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ def _input_validation(self, data, treatment_time):
)

def plot(self):

"""Plot the results"""
fig, ax = plt.subplots(3, 1, sharex=True, figsize=(7, 8))

Expand Down Expand Up @@ -488,7 +487,13 @@ def _plot_causal_impact_arrow(self, ax):
self.y_pred_counterfactual["posterior_predictive"].mu.mean().data
)
# Calculate the x position to plot at
diff = np.ptp(self.x_pred_treatment[self.time_variable_name].values)
# Note that we force to be float to avoid a type error using np.ptp with boolean
# values
diff = np.ptp(
np.array(self.x_pred_treatment[self.time_variable_name].values).astype(
float
)
)
x = np.max(self.x_pred_treatment[self.time_variable_name].values) + 0.1 * diff
# Plot the arrow
ax.annotate(
Expand Down
137 changes: 27 additions & 110 deletions docs/source/notebooks/did_pymc_banks.ipynb

Large diffs are not rendered by default.

0 comments on commit 39714f2

Please sign in to comment.