[R] definition of AIC and BIC in gls

Gavin Simpson gavin.simpson at ucl.ac.uk
Fri Aug 21 09:49:41 CEST 2009


On Thu, 2009-08-20 at 09:08 -0400, Bond, Stephen wrote:
> Hello everybody,
> 
> Please help with connecting the AIC and BIC numbers printed by
> summary.gls to the logLik number.
> 
> 
>  1.  is the logLik number the true ML or density scaling constants
> have been omitted?

I'm not sure, sorry, but the best place to look would be the code or the
book that accompanies the nlme package:

Pinheiro, J.C., and Bates, D.M. (2000) "Mixed-Effects Models in S
     and S-PLUS", Springer.

>  2.  what is the formula for calculating the AIC and BIC from logLik
> (and how can I see it)? I tried printing summary.gls but it says
> object not found.

That code is in the nlme namespace so you need to work a little bit
harder to see it.

One way is to use the getAnywhere function.

start with

methods(summary)

after loading the nlme package and you'll see summary.gls listed but it
has an * appended to the name, indicating that it is non-visible. Now we
know that the function exists, do

getAnywhere(summary.gls)

and the function code will be displayed.

Alternatively, you could grab the package sources from CRAN and delve
into the raw source code there. If you look at the code for summary.gls
you'll see that the three things you enquire about are performed using
the logLik, AIC, and BIC generic functions.

To see what methods are available for class "gls", do:

methods(class = "gls")

So look inside logLik.gls, AIC.logLik and BIC.logLik using getAnywhere
and that should hopefully answer your questions.

HTH

G

> 
> Thank you very much.
> Stephen
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%




More information about the R-help mailing list