I'm trying to look at the significance of a covariate through a drop in deviance test of two Poisson models. For example, mod1 might have 4 covariates, mod2 would have the same 4 covariates plus one more of particular interest. I've calculated the model deviance and df for each model with:
# vector of individual deviance residuals
dev.i<-(sign(observed-expected)*sqrt(2*(observed*log(observed/expected)-(observed-expected))))
#sum of squared deviance residuals = model deviance
dev.i.sq<-dev.i^2
sumsqdev<-sum(dev.i.sq,na.rm=T)
And the df for each model I calculated as the number of observations minus the number of parameters.
I'm sure there are commands for this in R, however I'm using a program that won't let me use the normal regression-based packages, so I have to do things long-hand. Any corrections, affirmations, or advice would be much appreciated!