Hello!
I hope you're doing well. First, thanks for such a great package! In my usage of the package, I noticed that the estimation of AIC for the loglm model does not use the same formula as stats::AIC(). I believe it is using the formula deviance - 2*df, which is outlined on pg. 356 of your book Discrete Data Analysis with R. Would it be possible to explicitly state this formula in the documentation--similar to what is done in the zero.test() documentation? This would be useful as there is disagreement between the AIC reported by LRstats() and modFit() as it appears that LRstats is using stats::AIC() whereas modFit() uses the aforementioned formula.
This would be very helpful for users to understand the disagreement between the two functions!
Thank you for your time!
Morgan N
Here is an example of the mismatch:
library(MASS)
library(vcdExtra)
#> Loading required package: vcd
#> Loading required package: grid
#> Loading required package: gnm
# load data
data("Titanic")
# fit model
titanic.mod1 <- MASS::loglm(~ (Class * Age * Sex) + Survived, data=Titanic)
# pull AIC
modFit(titanic.mod1, stats = "aic", digits = 6)
#> [1] " AIC=641.962215"
# disagreement between LRstats and modFit
LRstats(titanic.mod1)
#> Likelihood summary table:
#> AIC BIC LR Chisq Df Pr(>Chisq)
#> titanic.mod1 833.36 858.28 671.96 15 < 2.2e-16 ***
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## stats::AIC()
stats::AIC(titanic.mod1)
#> [1] 833.3644
# hand calculated AIC using the formula
titanic.mod1$deviance - (titanic.mod1$df*2)
#> [1] 641.9622
Created on 2026-05-11 with reprex v2.1.1
Hello!
I hope you're doing well. First, thanks for such a great package! In my usage of the package, I noticed that the estimation of AIC for the loglm model does not use the same formula as
stats::AIC(). I believe it is using the formuladeviance - 2*df, which is outlined on pg. 356 of your book Discrete Data Analysis with R. Would it be possible to explicitly state this formula in the documentation--similar to what is done in thezero.test()documentation? This would be useful as there is disagreement between the AIC reported byLRstats()andmodFit()as it appears thatLRstatsis usingstats::AIC()whereasmodFit()uses the aforementioned formula.This would be very helpful for users to understand the disagreement between the two functions!
Thank you for your time!
Morgan N
Here is an example of the mismatch:
Created on 2026-05-11 with reprex v2.1.1