There are some problems and inconsistencies with AICc current implementation:
The method with "logLik" signature includes a "## FIXME: should second "2" also be k?". The method with "mle2" signature seems to have substituted 2 with k. I am currently unable to verify that this is the correct formula, but I believe both methods should return the same answer. Moreover, it seems to me that the calculations for the "mle2 list" is missing a "k*df" term: https://github.com/bbolker/bbmle/blob/6d29d20af786eaae724c912e1a56b46243c83589/R/IC.R#L119
The method with "logLik" signature only works for a single model, where the "mle2" method is able to "sapply" over all given models. However, this doesn't seem to be a problem with bbmle, as stats::AIC has a similar behavior:
> stats::AIC(logLik(fit), logLik(fit1))
[1] 85.2572 # notice the second parameter is simply ignored
> stats::AIC(fit, fit1)
df AIC
fit 2 61.20811
fit1 2 85.25720 # here it works... weird.
Maybe this should throw a warning at least?
AICc methods do not check if all objects are of class mle2, whereas AIC checks this (but it seems that this should not be checked after all, see #11).
The handling of the "nobs" argument in the mle2 object is done inside the "if (length(L))"... This causes the very weird behavior that if there is no nobs method for a given fit, AICc(fit) will return "numeric(0)", while AICc(fit, fit) will fail with "Error in nobs.default(X[[i]], ...) : no 'nobs' method is available"
Finally, if "nobs" is missing, the "logLik" method will attempt to use attr(object, "nobs"), but the "mle2" method will try to use a nobs(object)method. Is there a reason for this, or the "nobs" attribute should be attempted in the "mle2" method as well? Shouldn't the "nobs" attribute in the mle2 class be declared as a "slot"?
I'm working on a pull request to hopefully fix all of those
There are some problems and inconsistencies with AICc current implementation:
The method with "logLik" signature includes a "## FIXME: should second "2" also be k?". The method with "mle2" signature seems to have substituted 2 with k. I am currently unable to verify that this is the correct formula, but I believe both methods should return the same answer. Moreover, it seems to me that the calculations for the "mle2 list" is missing a "k*df" term: https://github.com/bbolker/bbmle/blob/6d29d20af786eaae724c912e1a56b46243c83589/R/IC.R#L119
The method with "logLik" signature only works for a single model, where the "mle2" method is able to "sapply" over all given models. However, this doesn't seem to be a problem with bbmle, as
stats::AIC
has a similar behavior:Maybe this should throw a warning at least?
AICc methods do not check if all objects are of class mle2, whereas AIC checks this (but it seems that this should not be checked after all, see #11).
The handling of the "nobs" argument in the mle2 object is done inside the "if (length(L))"... This causes the very weird behavior that if there is no
nobs
method for a given fit,AICc(fit)
will return "numeric(0)", whileAICc(fit, fit)
will fail with "Error in nobs.default(X[[i]], ...) : no 'nobs' method is available"Finally, if "nobs" is missing, the "logLik" method will attempt to use
attr(object, "nobs")
, but the "mle2" method will try to use anobs(object)
method. Is there a reason for this, or the "nobs" attribute should be attempted in the "mle2" method as well? Shouldn't the "nobs" attribute in the mle2 class be declared as a "slot"?I'm working on a pull request to hopefully fix all of those