# Can $G^2$ statistic in log-linear model for contingency tables be negative?

Can $$G^2$$ statistic of log-linear (unsaturated) model in contingency tables be negative? Since saturated model with perfect fit has $$G^2=0$$ I don't think the unsaturated models can get negative $$G^2$$. In need of insight, since I might have run into some miscalculations.

• Depending on the order I’ve entered models in some R functions, I’ve run issues like this.
– Dave
Commented May 4, 2020 at 13:36

Note from Wikipedia that the $$G^2$$-statistic has the form of (twice) a Kullback-Leibler divergence, see Why is Kullback Leibler Divergence always positive?. More precisely $$\DeclareMathOperator{\KL}{KL} G^2 = 2\sum_i O_i \log\frac{O_i}{E_i}=2N\KL\left(\frac{O_i}{N} || \frac{E_i}{N} \right)$$ where $$N$$ is the total count. It is also related to the deviance in generalized linear models, and is in fact the Deviance (in R terminology, Null deviance - Residual deviance) in a logistic regression model for the contingency table.