Categorical predictor variable, categorical response variable

Hi. Your question and auto-answer is very useful because, as you mention, there are really few examples about categorical predictor and outcome.

I’m new to both PyMC and this kind of analysis. I’m trying to replicate your code since I’m facing the same problem, but with multiple categorical regressors. However, I cannot figure out how do you went from your initial table, as shown here:

to the data that you use to run the model, using the command

Y, X = patsy.dmatrices('forestType ~ landUse', data=landUseForestType, return_type='dataframe')

because the table doesn’t have the column named “site” nor the variables “forestType” or “landUse”. Could you kindly help me about how to create the “Y” and “X” variables to reproduce your model, so I can adapt it to a multiple categorical multinomial?

In addition, I fail to figure out how did you define a reference category for the model.

Thanks, and all the best.
Mauricio.