Modeling uncertainty about the probabilities of categories themselves.
General Principles
To model the relationship between a vector outcome variable in which each element of the vector is a frequency from a set of more than two categories and one or more independent variables, we can use a Dirichlet model.
We can model a vector of frequencies using a Dirichlet distribution. For an outcome variable Y_i with 𝐾 categories, the Dirichlet likelihood function is:
\kappa is the concentration parameter, it controls the prior weight on each category.
\theta_i is a vector unique to each observation, i, which gives the probability of observing i in category k.
\phi_i give the linear model for each of the k categories. Note that we use the softmax function to ensure that that the probabilities \theta_i form a simplex 🛈.
Each element of \phi_i is obtained by applying a linear regression model with its own respective intercept \alpha_k and slope coefficient \beta_k. To ensure the model is identifiable, one category, K, is arbitrarily chosen as a reference or baseline category. The linear predictor for this reference category is set to zero. The coefficients for the other categories then represent the change in the log-odds of being in that category versus the reference category.
Model validation tests
Comparison with Stan: 14.Dirichlet.py fits the same model with BayesForge and Stan and compares the posterior distributions (KL divergence) and parameter recovery.
Data generative model and inference model pipeline: 14.Dirichlet.py simulates data from the model with known parameters (data generative model), fits the inference model to each simulated dataset and checks that the parameters are recovered.