Skip to content

Commit 8a28509

Browse files
committed
fix test failure and doc anomalies
1 parent 8cc283e commit 8a28509

File tree

2 files changed

+22
-17
lines changed

2 files changed

+22
-17
lines changed

causalpy/pymc_experiments.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ class PrePostFit(ExperimentalDesign):
128128
... formula="actual ~ 0 + a + b + c + d + e + f + g",
129129
... model=cp.pymc_models.WeightedSumFitter(
130130
... sample_kwargs={
131+
... "draws": 2000,
131132
... "target_accept": 0.95,
132133
... "random_seed": seed,
133134
... "progressbar": False
@@ -138,12 +139,12 @@ class PrePostFit(ExperimentalDesign):
138139
==================================Pre-Post Fit==================================
139140
Formula: actual ~ 0 + a + b + c + d + e + f + g
140141
Model coefficients:
141-
a 0.33, 94% HDI [0.30, 0.38]
142+
a 0.34, 94% HDI [0.30, 0.38]
142143
b 0.05, 94% HDI [0.01, 0.09]
143144
c 0.31, 94% HDI [0.26, 0.35]
144145
d 0.06, 94% HDI [0.01, 0.10]
145146
e 0.02, 94% HDI [0.00, 0.06]
146-
f 0.20, 94% HDI [0.12, 0.26]
147+
f 0.19, 94% HDI [0.11, 0.26]
147148
g 0.04, 94% HDI [0.00, 0.08]
148149
sigma 0.26, 94% HDI [0.22, 0.30]
149150
"""
@@ -773,6 +774,7 @@ class RegressionDiscontinuity(ExperimentalDesign):
773774
... formula="y ~ 1 + x + treated + x:treated",
774775
... model=cp.pymc_models.LinearRegression(
775776
... sample_kwargs={
777+
... "draws": 2000,
776778
... "target_accept": 0.95,
777779
... "random_seed": seed,
778780
... "progressbar": False,
@@ -790,9 +792,9 @@ class RegressionDiscontinuity(ExperimentalDesign):
790792
Discontinuity at threshold = 0.91
791793
Model coefficients:
792794
Intercept 0.09, 94% HDI [-0.00, 0.17]
793-
treated[T.True] 2.45, 94% HDI [1.66, 3.28]
795+
treated[T.True] 2.45, 94% HDI [1.64, 3.28]
794796
x 1.32, 94% HDI [1.14, 1.50]
795-
x:treated[T.True] -3.08, 94% HDI [-4.17, -2.05]
797+
x:treated[T.True] -3.09, 94% HDI [-4.16, -2.03]
796798
sigma 0.36, 94% HDI [0.31, 0.41]
797799
"""
798800

@@ -1224,12 +1226,13 @@ class InstrumentalVariable(ExperimentalDesign):
12241226
>>> instruments_data = test_data[["X", "Z"]]
12251227
>>> data = test_data[["y", "X"]]
12261228
>>> iv = InstrumentalVariable(
1227-
... instruments_data=instruments_data,
1228-
... data=data,
1229-
... instruments_formula=instruments_formula,
1230-
... formula=formula,
1231-
... model=InstrumentalVariableRegression(sample_kwargs=sample_kwargs),
1229+
... instruments_data=instruments_data,
1230+
... data=data,
1231+
... instruments_formula=instruments_formula,
1232+
... formula=formula,
1233+
... model=InstrumentalVariableRegression(sample_kwargs=sample_kwargs),
12321234
... )
1235+
12331236
"""
12341237

12351238
def __init__(

causalpy/pymc_models.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ class ModelBuilder(pm.Model):
6464
>>> model.predict(X_new)
6565
Inference...
6666
>>> model.score(X, y) # doctest: +NUMBER
67-
r2 0.38
68-
r2_std 0.08
67+
r2 0.3
68+
r2_std 0.0
6969
dtype: float64
7070
"""
7171

@@ -144,8 +144,9 @@ class WeightedSumFitter(ModelBuilder):
144144
"""
145145
Used for synthetic control experiments
146146
147-
.. note: Generally, the `.fit()` method should be used rather than calling
148-
`.build_model()` directly.
147+
.. note::
148+
Generally, the `.fit()` method should be used rather than
149+
calling `.build_model()` directly.
149150
150151
Defines the PyMC model:
151152
@@ -196,8 +197,9 @@ class LinearRegression(ModelBuilder):
196197
"""
197198
Custom PyMC model for linear regression
198199
199-
.. note: Generally, the `.fit()` method should be used rather than calling
200-
`.build_model()` directly.
200+
.. note:
201+
Generally, the `.fit()` method should be used rather than
202+
calling `.build_model()` directly.
201203
202204
Defines the PyMC model
203205
@@ -291,8 +293,8 @@ def build_model(self, X, Z, y, t, coords, priors):
291293
instruments and covariates
292294
:param priors: An optional dictionary of priors for the mus and
293295
sigmas of both regressions
294-
295-
:code:`priors = {"mus": [0, 0], "sigmas": [1, 1], "eta": 2, "lkj_sd": 2}`
296+
:code:`priors = {"mus": [0, 0], "sigmas": [1, 1],
297+
"eta": 2, "lkj_sd": 2}`
296298
297299
"""
298300

0 commit comments

Comments
 (0)