# Calculating the 'deviance' in an Analysis of Deviance table for generalized linear models

The issue concerns question 3(b) of this paper.

Specifically, I am trying to fill in the missing values for the 'Deviance' column of the ANOVA table. Using R, I find the missing corresponding to 'Day' to be 0.2733. However, when I try to verify this by direct calculation with $$2[\ell_{\mathrm{proposed}}-\ell_{\mathrm{null}}]=2\left[\sum_{i,j,k}n_{ijk}Y_{ijk}\alpha_{i}+n_{ijk}\log\left(\frac{1+\exp(\mu)}{1+\exp(\mu+\alpha_i)}\right)\right]$$ Note that here I've assumed the model $$n_{ijk}Y_{ijk}\sim B(n_{ijk},p_{ijk})$$ where $$\mathrm{logit} p_{ijk} = \mu + \alpha_i$$ for day $$i=1,2,3$$, species $$j = 1,2,3$$ and observation $$k = 1,\ldots, K_{ij}$$. I cannot seem to obtain the correct answer when observations from the table are plugged into the above (also, here $$n_{ijk}$$ denotes values from the 'total' columns). Could someone please give a model solution to this question?

I don't know if this is considered an acceptable answer or not, but the lazy way to solve this exam question is to note this line in the summary() output:

Null deviance: 33.631 on 22 degrees of freedom


and these lines in the deviance table:

      Df Deviance Resid. Df Resid. Dev P(>|Chi|)
NULL
Day   xx xx       20        33.358     0.8723


Since the null deviance is 33.631 and the residual deviance (Resid Dev) is 33.358, the difference in deviance between the null model and the model with Day only (which is what's listed in the Deviance column) is 33.631-33.358 = 0.273.

You can get the difference in degrees of freedom (Df) similarly (null [22] - residual [20] = 2), or by explaining that Day is a categorical predictor with 3 levels and thus requires 3-1 = 2 additional parameters over the null (intercept-only) model.

• Thank you! I had a feeling I was overthinking it. I'd worked out everything else in a similar fashion to this and completely overlooked the null deviance! – Will Jul 22 '19 at 19:57