[R] Calculation of AIC BIC from mle
Rainer M KRug
RMK at krugs.de
Mon Jun 5 10:22:02 CEST 2006
R 2.3.0, all packages up to date
Linux, SuSE 10.0
Hi
I want to calculate AIC or BIC from several results from mle calculation.
I found the AIC function, but it does not seem to work with objects of
class mle -
If I execute the following:
ml1 <- mle(...)
AIC(ml1)
I get the following error messale:
Error in logLik(object) : no applicable method for "logLik"
Therefore I am using the following to calculate the AIC:
#AICmle calculate AIC from mle object
AICmle <- function( m, k=2)
{
lL <- logLik(m)
edf <- attr(lL, "df")
LL <- lL[1]
- 2 * LL + k * edf
}
1) Why is AIC not working with objects of class mle - am I doing
something wrong, is it a bug or by design?
2) Just for confirmation - is my calculation of AIC correct?
Thanks
Rainer
More information about the R-help
mailing list