Hi Pymc3 Comunity,
I have a custom distribution defined as a pm.DensityDist()
There are a number of intermediate calculation steps inside the logp of this custom dist
I’d love to have some of these intermediate values included in a) the trace, and b) posterior predictive checks.
Essentially I’d like to have a deterministic variable defined inside a logp.
The naive approach of defining it dirrectly fails with a “ValueError: Variable name trans_p already exists.” (regardless of the var name).
Here is a toy example of what im trying to do:
def logp(current_idx, next_idx):
alpha_t = alpha[current_idx, :]
trans_baserate_t = trans_baserate[current_idx, :]
trans_p = pm.Deterministic('trans_p', trans_baserate_t + alpha_t) #here
cat = pm.Categorical.dist(p=trans_p)
return cat.logp(next_idx)
Is this possible? or will I have to recreate this deterministic variable from the trace object?