I run quasi-Poisson glm models in R and I want to compute AIC criterion. I run the code below but I am not sure if it is correct. Also, I find weird the fact that the AIC decreases while degrees of freedom increase.
fqaic <- function(model) {
loglik <- sum(dpois(model$y, model$fitted.values, log = TRUE))
phi <- summary(model)$dispersion
qaic <- -2*loglik + 2*summary(model)$df[3]*phi
return(qaic)
}
I would be grateful for any advice.