Log-linear models applied to contingency tables where the cells are modeled as independent Poisson variables has a brief mention in Ch16 p428-431 BDA3, but I haven’t been able to find a Stan model anywhere illustrating the core ideas: especially featuring hierarchical models with interactions and main effects. Does anyone know of any examples?

@martinmodrak, since it’s widely used, if there isn’t any examples, would the Stan team be interested in one for the documentation section?

I am unfortunately completely unfamiliar with these types of model as well as with their applications (but I guess I understand what you mean). So it is hard for me to judge the importance/wide use.

I think a general rule about examples is that we love ourselves a good example :-). Now, aiming directly for the Stan docs might not always be the best course of action, especially since the devs may take a while to react (although AFAIK @Bob_Carpenter tends to respond quickly there and knows way more details about the process of inclusion in the docs than I do). I would personally recommend people to just write an example (possibly in a similar style as the Stan docs are written), put it somewhere on the Interwebs and advertise here on Discourse (or even post the whole example directly as a Discourse topic). This way people can use it immediately. Inclusion in Stan docs can then happen on its own pace.

@emiruz have you made any progress on this? I’m starting a problem that is essentially a hierarchical contingency table problem (think of it as the 8-schools problem, but where we get a 2x2 (or larger) contingency table from each school, and I think a Bayesian log-linear model would be useful. I haven’t seen any good documentation on appropriate priors for this type of problem, although the actual model itself in Stan shouldn’t be hard to implement.

The really interesting part of Overstall’s work comes when you assume that a contingency table has interaction terms but you don’t know what they are. He and others worked out an elegant prior on the space of possible designs and an efficient Gibbs sampler for it. That part would be difficult to do in Stan since it’d have to be discrete.