[R] How to find S4 generics? (was: inames() function and lmer())

Spencer Graves spencer.graves at pdf.com
Wed Jul 19 05:38:17 CEST 2006


*****
***** "methods" *****
*****
	  You have asked an excellent question.  I can provide a partial answer 
below.  First, however, I wish to pose a question of my own, which could 
help answer your question:

	  How can one obtain a simple list of the available generics for a 
class?  For an S3 class, the 'methods' functions provide that.  What 
about an S4 class?  That's entirely opaque to me, if I somehow can't 
find the relevant information in other ways.  For example, ?lmer-class 
lists many but not all of the methods available for objects of class 
'lmer'.  I think I once found a way to get that, but I'm not able to 
find documentation on it now.

*****
***** Retrieving information from an 'lmer' object *****
*****
	  There are many ways to retrieve information from an object.  For 
'lmer', I think the best source of information is probably the help 
pages for 'lmer' and 'lmer-class'.  The latter tells you that there are 
"Methods" anova, coef, coerce, deviance, logLik, update, simulate, 
solve, terms, vcov, ranef and VarCorr for extracting information or 
modifying an object of class 'lmer'.  There are also other methods not 
listed on that page like 'fixef'.  I don't know how to find those easily.

	  There is also the excellent vignette("MlmSoftRev") in the 'mlmRev' 
package.  (For help with it, see, e.g., 
"http://finzi.psych.upenn.edu/R/Rhelp02a/archive/76134.html".)

	  Finally, the function 'str' will in most cases expose the structure 
of an object, thereby making it relatively easy to figure out how to get 
what is needed for many applications.  That does not always work, 
however, because 'str' is a generic function, not a primitive.  'str' 
seems to expose everything one might possibly want to know about an 
'lmer' object (apart from the theory behind it).  This is not the case 
for an object of class 'logLik', because a function 'str.logLik' 
provides a succinct summary of a 'logLik' object in a non-standard 
format.  The following will defeat 'str.logLik':

 > fm1 <- lmer(Reaction ~ Days + (Days|Subject), sleepstudy)
 > lglk1 <- logLik(fm1)
 > str(lglk1)
Class 'logLik' : -871.8 (df=5) # I don't understand this.
 > str(unclass(lglk1)) # This is in the standard 'str' format:
  atomic [1:1] -872
  - attr(*, "nobs")= int 180
  - attr(*, "nall")= int 180
  - attr(*, "df")= num 5
  - attr(*, "REML")= logi TRUE

	  Best Wishes,
	  Spencer Graves

A.R. Criswell wrote:
> Hello All,
> 
> I would like to retrieve some of the results from the lmer(...)
> function in library lme4. If I run a model, say
> 
> fm.1 <- lmer(y ~ 1 + (1 | x), data = dog)
> 
> and try names(fm.1), I get NULL. Is there anyway to retrieve the information?
> 
> Thanks
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html



More information about the R-help mailing list