# Is there a GLM likelihood for tables of counts conditioned on row and column sums?

Multinomial logistic regression corresponds to the setting where each data point has a vector of counts whose total we condition on. The logistic/softmax link + multinomial likelihood is appropriate here.

However, I have a setting where every data point corresponds to a table of counts $y_{ij}$. Is there a likelihood which conditions on the row sums $y_{.j}$ and column sums $y_{i.}$? (i.e. the assumption made by Fisher's exact test for example).

I know one way to approach this would be to consider every individual count as a data point and include a fixed effect for every row & column, but this isn't appealing since I have >1e5 data points.

• Are you looking for the hypergeometric distribution? (Which is what Fisher's exact test is based on.) Feb 23, 2017 at 5:13
• @GordonSmyth Thanks yes, I think in the 2x2 case that's what I want. However a) I want to connect this to covariates so need to somehow link the hypergeometric param (K in the wikipedia notation, n and N being fixed) to my covariates, but $K \in \{0,...,N\}$. b) I want to be able to handle the NxM case. Looks like the multivariate hypergeometric might let me handle the 2xM which would actually be nice in itself. Feb 23, 2017 at 23:19
• Ok so thinking about this a bit more I want one of the noncentral hypergeometric distributions (probably Wallenius' since the total count is fixed). The noncentrality parameter is what I would link to covariates. Unfortunately these distributions look like a massive pain to work with numerically. Feb 23, 2017 at 23:45