[R] aic calculus for glm models
Pierre-Andre Cornillon
pac at Uhb.Fr
Wed Jun 26 16:50:06 CEST 2002
I am trying to know exactly the formulas used to calculate aic for glm
models. In glm.fit, the calculus of aic is:
aic.model <- aic(y, n,mu, weights, dev) + 2 * fit$rank
where 2 * fit$rank is (may be am i wrong?) twice the numbers of
parameters p and aic(y, n, mu, weights, dev)
refers to the function defined in the family function (which is for
Gamma family, for instance)
aic <- function(y, n, mu, wt, dev) {
n <- sum(wt)
disp <- dev/n
-2 * sum(dgamma(y, 1/disp, scale = mu * disp, log = TRUE) *
wt) + 2
}
Its seems to me that 1/disp = \phi is the ML estimator of \phi,
-2 * sum(dgamma(y, 1/disp, scale = mu * disp, log = TRUE) * wt) is
twice the log likelihood of the observations at the ML estimators mu
and disp. But what is the + 2 ?
The same thing occurs in the gaussian family: aic = function(y, n, mu,
wt, dev) sum(wt) * (log(dev/sum(wt) * 2 * pi) + 1) + 2
with dev/sum(wt) is the ML estimator of sigma^2, thus aic is
twice the likelihood function of the observations evaluated at ML
parameters + 2
I have probably not understood something but ??
Pierre-Andre Cornillon
PS may be some indications in the help page of summary.glm to explain
that the dispersion parameter \phi displayed by glm.summary is
estimated as advocated by Mc Cullagh & Nelder (1989, p.296) could be
useful for some users
PS2 : I am using R Version 1.4.1
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list