[R] aic calculus for glm models
ripley@stats.ox.ac.uk
ripley at stats.ox.ac.uk
Wed Jun 26 17:18:33 CEST 2002
On Wed, 26 Jun 2002, Pierre-Andre Cornillon wrote:
> 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 ?
1/disp is *not* the ML estimator of \phi. See the reference below.
I don't think what R quotes as the aic is anything sensible.
> 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
Actually aic is minus twice the log-likelihood (that's two mistakes) plus
twice (# of linear parameters plus number of scale parameters).
> 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
Well, a long essay on fitting glms would be useful to some users but that
is not the function of the help page (especially without mathematical
notation). You will find this all explained in Venables & Ripley (1999)
and its on-line Statistical Complements.
> PS2 : I am using R Version 1.4.1
Time to upgrade.
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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