The AIC calculation in Binomial GLM seems to be wrong when there are weights. The result is different from that in R.
The current implementation is:
Suggest changing this to
The following is an example to illustrate the problem.
This calculation shows the AIC is 14.189026847171382. To verify whether this is correct, I run the same analysis in R but got AIC = 11.66092, -2 * LogLik = 5.660918.
Now, I check whether the proposed change is correct. The following calculates -2 * LogLik manually and get 5.6609177228379055, the same as that in R.