Hi all!
I was wondering if it’s possible to include a conditional statement within a pymc3 model. Let’s say I’m building a model based on 3 coefficients, that looks like the following:
with pm.Model as model:
x = pm.Data("x", x_obs, dims="obs_id")
a = pm.Normal("a", mu=0.0, sigma=1.0)
b = pm.Normal("b", mu = 0.0, sigma = 1.0)
c = pm.Normal("c", mu = 18.0, sigma = 1.0)
mu = a + b * (x - c)
sigma = pm.Exponential("sigma", 1.0)
y = pm.Normal("y", mu, sigma=sigma, observed=y_obs, dims="obs_id")
I would be interested in adding a conditional statement, when evaluating the (x-c) bit, so that the value included in the model will be (x-c) if (x-c) is positive, otherwise it will be 0. In python syntax, I think it would be something like:
np.where(x-c > 0, x-c, 0)
Would it be possible to include such a statement in my probabilistic model?
Thanks in advance for your help!