Hierarchical modeling categorical variable interactions in PyMC3 -
i'm attempting use pymc3 implement hierarchical model categorical variables , interactions. in r, formula take form of like:
y ~ x1 + x2 + x1:x2
however, on tutorial https://pymc-devs.github.io/pymc3/glm-hierarchical/#partial-pooling-hierarchical-regression-aka-the-best-of-both-worlds explicitly glm doesn't play nice hierarchical modeling yet.
so how go adding x1:x2 term? categorical variable 2 categorical parents (x1 , x2)?
you can manually add interaction term linear model. have add 3 regression coefficients (betas) , 1 intercept. can estimate y likelihood follows:
y = pm.normal('regression', mu=intercept + beta_x1 * data_x1 + beta_x2 * data_x2 + beta_interaction * data_x1 * data_x2, sd=sigma, observed=data_y)
the parameters can have hyperpriors build hierarchical model.
Comments
Post a Comment