Hello all. 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). 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'." Thus, I was expecting that logLik.nls() and logLik.nlme() could be used for objects of the nls and nlme class, respectively. 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? On a related note, is there a way to get the log likelihoods of each individual from an nlsList object? On p. 349 of Pinheiro and Bates (2000) the logLik() function is said to give the sum of the individual nls log-likelihoods. However, logLike(some.nlsList.object) does not work for me (even when there are no NAs). Any ideas? Thanks for any thoughts or feedback. Have a good day, Ken
Prof Brian Ripley
2004-Jul-01 20:34 UTC
[R] Individual log likelihoods of nlsList objects.
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, 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 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
>>>>> "Ken" == Ken Kelley <kkelley at nd.edu> >>>>> on Thu, 1 Jul 2004 14:23:16 -0500 writes:Ken> Hello all. Ken> I was wondering if the logLike.nls() and logLike.nlme() functions are still Ken> being used. no, but the correctly spelled ones, logLik.nls and logLik.nlme are Ken> Neither function seems to be available in the most recent Ken> release of R (1.9.1). how do you know? Ken> The following is contained in the help file for Ken> logLik(): "classes which already have methods for this Ken> function include: 'glm', 'lm', 'nls' and 'gls', 'lme' Ken> and others in package 'nlme'." Hence do rather believe the documentation .... Ken> Thus, I was expecting Ken> that logLik.nls() and logLik.nlme() could be used for Ken> objects of the nls and nlme class, respectively. They *are* used whenever you (or your code indirectly) call logLik(.) on "nls" or "nlme" objects respectively. You were never to call these directly, and you this has been discouraged a bit more as a side effect of the introduction of name spaces for all "core" and recommended (and quite a few more CRAN and bioconductor) packages. You definitely need to learn about Classes and Methods ("S3" in this case) in R {or the S language in general}, and read the article about "Namespaces" in R-news, or (more technical), Luke Tierney's pages on this. If you want to see them use, e.g., getAnywhere("logLik.nls") Ken> Are these functions no longer needed because logLike() Ken> subsumes logLike.nls() and logLike.nlme() as special Ken> cases? Did/does logLike.nls() and logLike.nlme() have Ken> any advantages above and beyond logLike() when applying Ken> them to nls and nlme objects? Ken> On a related note, is there a way to get the log likelihoods of each Ken> individual from an nlsList object? Ken> On p. 349 of Pinheiro and Bates (2000) the logLik() function is said to give Ken> the sum of the individual nls log-likelihoods. However, Ken> logLike(some.nlsList.object) does not work for me (even when there are no Ken> NAs). Any ideas? if you are insisting on typo-ing you will have more problems with all versions of S ;-) or did you try logLik( <...> ) ? In any case use, (small) reproducible examples for these. Have you read the posting guide, mentioned at the tail of this message? Regards, Martin