Skip to content

Commit 548d723

Browse files
committed
allow priors on propensity score parameters
Signed-off-by: Nathaniel <[email protected]>
1 parent 2da3007 commit 548d723

File tree

2 files changed

+833
-768
lines changed

2 files changed

+833
-768
lines changed

causalpy/pymc_models.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,12 @@ def fit_outcome_model(
611611
X_outcome,
612612
y,
613613
coords,
614-
priors={"b_outcome": [0, 1], "a_outcome": [0, 1], "sigma": 1},
614+
priors={
615+
"b_outcome": [0, 1],
616+
"a_outcome": [0, 1],
617+
"sigma": 1,
618+
"beta_ps": [0, 1],
619+
},
615620
noncentred=True,
616621
normal_outcome=True,
617622
spline_component=False,
@@ -702,7 +707,7 @@ class initialisation.
702707
dims="outcome_coeffs",
703708
)
704709

705-
beta_ps = pm.Normal("beta_ps", 0, 1)
710+
beta_ps = pm.Normal("beta_ps", priors["beta_ps"][0], priors["beta_ps"][1])
706711

707712
chosen = np.random.choice(range(propensity_scores.shape[1]))
708713
p = propensity_scores[:, chosen].values
@@ -714,7 +719,12 @@ class initialisation.
714719
mu_outcome = alpha_outcome + pm.math.dot(X_data_outcome, beta) + beta_ps * p
715720

716721
if spline_component:
717-
beta_ps_spline = pm.Normal("beta_ps_spline", 0, 1, size=34)
722+
beta_ps_spline = pm.Normal(
723+
"beta_ps_spline",
724+
priors["beta_ps"][0],
725+
priors["beta_ps"][1],
726+
size=34,
727+
)
718728
B = dmatrix(
719729
"bs(ps, knots=knots, degree=3, include_intercept=True, lower_bound=0, upper_bound=1) - 1",
720730
{"ps": p, "knots": np.linspace(0, 1, 30)},

0 commit comments

Comments
 (0)