Reputation: 31
I've started trying out pymc3 and need to implement a multinomial logistic regression model. I've studied twiecki's tutorials and I understand his implementations of hierarchical regression models (see https://twiecki.github.io/blog/2014/03/17/bayesian-glms-3/), as well as some basic examples of binary logistic regression in pymc3. I have yet to see any extensions of this to multinomial logistic regressions. Is there support for this using pymc3's GLM? Or how would one implement this without using GLM? Here is a link to an iPython notebook where I attempt to solve the problem, though I know I am missing something significant here: http://nbviewer.ipython.org/github/mvictor212/pymc-multinom-logit/blob/master/MultinomialLogisticRegression%20-%20Radon%20Level.ipynb
Upvotes: 3
Views: 2651
Reputation: 4203
A categorical is parameterized by a vector of probabilities, one for each class, which add up to one (PyMC expects k-1 probabilities, and calculates the last one by subtraction). In this example, it looks like you end up with only one probability for each observation, if I am reading your code correctly. (Also, this is what your error suggests -- it has received an index of 1 when the parameter vector is of size 1).
For example, lets say I had data that represented three classes:
[0, 2, 2, 1, 0, 2, 1, 0, 1, 1]
Then I should have a vector of values for p of length 2, for example:
p = [0.4, 0.3]
Upvotes: 1