Modelling Categorial Variable

Hi! Here are some thoughts, but I’m not sure I understood your model specification, so take them with a grain of salt:

  • ValueError: you seem to have a shape problem somewhere. You can check the shape of any PyMC variable with print("p: ", p.tag.test_value.shape) for instance. This will print the shape during compilation of the model and I usually find that useful!

  • I think your priors are too wide, which could explain NUTS having a hard time sampling when your data are in multinomial shape. In multinomial regressions, priors on the parameter scale are completely distorted on the probability space (mainly because of floor/ceiling effects). I’d try much more regularizing priors, combined to prior predictive checks

  • I don’t know if it’s on purpose, but I only see 10 slots here, with p_1 = 0.1 and p_{10} = 1. Maybe that is causing your shape problem?

  • I’m actually working on a case that looks a little like yours. I’m still fighting with how to implement the model in PyMC, but maybe you’ll find something useful - maybe we’ll even help each other out!

  • If I can give a personal opinion, your model specification can be hard to read because of the pm_ suffixes, as they look a lot like the PyMC calls. If you could trim them - and maybe even comment the important steps - I think that would make it easier to read and understand :slight_smile:

Hope all of that helps you!