Hi, I’m training a simple hierarchal model in Bambi.
My data generation process is
outcome ~ Possion(mu)
log(mu) = intercept_group + log(β)*slope_group
I know from the definition of the of problem that 0<=slope_group<=1
My bambi model looks like this:
Formula: outcome ~ 0 + group_id + log(β) + (0 + log(β)|group_id)
Family: poisson
Link: mu = log
Observations: 580
Priors:
target = mu
Common-level effects
group_id ~ Normal(mu: 0.0, sigma: 2.0)
log(β) ~ Beta(alpha: 1.0, beta: 1.0)
Group-level effects
log(β)|group_id ~ Normal(mu: 0.0, sigma: HalfNormal(sigma: 1.0))
It fits fine, but my problem that we I get individual group slopes as idata.posterior['log(β)'] + idata.posterior['log(β)|group_id']
i may end up with the values in the range of [0,1]
, what blows up some my post-processing steps.
I would like to have something slope_group = logit(slope_global + slope_correction|group)
to constrain the slope between 0 and 1. I wonder if that’s possible to do without going back to pure PyMC implementation.