Re: [R] Individual log likelihoods of nlsList objects.

From: Prof Brian Ripley <>
Date: Fri 02 Jul 2004 - 06:34:27 EST

The function is logLik, not logLike! Try

> library(nlme)
> methods("logLik")

 [1] logLik.Arima*        logLik.corStruct*    logLik.glm*         
 [4] logLik.gls*          logLik.glsStruct*    logLik.gnls*        
 [7] logLik.gnlsStruct*   logLik.lm*           logLik.lme*         
[10] logLik.lmeStruct*    logLik.lmeStructInt* logLik.lmList*      
[13] logLik.nls*          logLik.reStruct*     logLik.varComb*     
[16] logLik.varFunc*     

    Non-visible functions are asterisked

so logLik.nls is still being used.

On Thu, 1 Jul 2004, Ken Kelley wrote:

> I was wondering if the logLike.nls() and logLike.nlme() functions are still
> being used. Neither function seems to be available in the most recent
> release of R (1.9.1).

I suspect you don't understand how R looks for them. Have you read the article on namespaces in R-News? Do you know what getAnywhere() does? The "nls" method for function logLik is not necessarily the same thing as a function logLik.nls, and even if it is, that function is not necessarily visible to the user (as distinct to the function logLik).

> The following is contained in the help file for logLik(): "classes which
> already have methods for this function include: 'glm', 'lm', 'nls' and
> 'gls', 'lme' and others in package 'nlme'."

NB: NO mention of "nlme" fits.

> Thus, I was expecting that logLik.nls() and logLik.nlme() could be used
> for objects of the nls and nlme class, respectively.

Why do you expect so? It doesn't even mention the "nlme" class. There is no logLik.nlme, and never was. (As nlme does not do exact ML fitting, it is not going to be able to calculate a likelihood without doing integration which it does not do. What nlme does is ML in a local linear approximation.)

> Are these functions no longer needed because logLike() subsumes
> logLike.nls() and logLike.nlme() as special cases? Did/does
> logLike.nls() and logLike.nlme() have any advantages above and beyond
> logLike() when applying them to nls and nlme objects?

Please do read up about methods, method dispatch and namespaces.

Brian D. Ripley,        
Professor of Applied Statistics,
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________ mailing list
PLEASE do read the posting guide!
Received on Fri Jul 02 06:39:14 2004

This archive was generated by hypermail 2.1.8 : Wed 03 Nov 2004 - 22:54:39 EST