Solution (source code)

= Solution

With both column totals fixed, each column is a three-category multinomial sample. Under the null the two columns share one probability vector, which has \b[two free parameters] because its three probabilities sum to one. Under the alternative each has its own vector, giving \b[four free parameters]. Their difference is two, the reference <degrees of freedom> for the association test.