Hi John, David's advice is probably sufficient, but I thought I would just add the following example, showing how to find out what extractor functions have been defined for a particular s4 class:
class(fm2) #find out the class of fm2 ("mer") showMethods(classes="mer") # find out what methods are defined for objects of class "mer". Notice that one of the defined methods is "coef". Notice also that methods "fixef" and "ranef" are also defined. fixef(fm2) #extract fixed effect coefficients ranef(fm2) #extract random effects coefficients coef(fm2) #extract "coefficients" (sum of fixed and random effects). On Mon, May 3, 2010 at 10:16 AM, David Winsemius <dwinsem...@comcast.net> wrote: > > On May 3, 2010, at 9:41 AM, John Sorkin wrote: > >> R 2.10.0 >> windows XP >> >> I am trying to get the coefficients returned from lmer. Normally I would >> use the names function to get the objects returned by the function. This >> does not work in lmer, but it does for lm: > > When you read the help page for lmer it refers your to the description of > "mer"-class where that help page tells you that it is an S4 object and > offers a wide variety of extractor method functions, including a coef > function. The str function would have shown you the slot names, but at your > level of knowledge, it would probably be safer to work with the > extractor/accessor functions. (I speak from sad experience. The authors of > that package know a lot more than either of us.) > > -- > David. >> >> <- lmer(Reaction ~ Days + (1|Subject) + (0+Days|Subject), sleepstudy) >>> >>> names(fm2) >> >> NULL >> >>> fitlm <- lm(Reaction ~ Days, sleepstudy) >>> names(fitlm) >> >> [1] "coefficients" "residuals" "effects" "rank" >> [5] "fitted.values" "assign" "qr" "df.residual" >> [9] "xlevels" "call" "terms" "model" >> >> How does one know what is returned by lmer, and how does one access the >> various parts? I looked at the code for lmer, but at least on my level of R >> sophistication, the nature of the data returned in not clear. >> >> Thanks, >> John >> >> >> John David Sorkin M.D., Ph.D. >> Chief, Biostatistics and Informatics >> University of Maryland School of Medicine Division of Gerontology >> Baltimore VA Medical Center >> 10 North Greene Street >> GRECC (BT/18/GR) >> Baltimore, MD 21201-1524 >> (Phone) 410-605-7119 >> (Fax) 410-605-7913 (Please call phone number above prior to faxing) >> >> Confidentiality Statement: >> This email message, including any attachments, is for th...{{dropped:6}} >> >> ______________________________________________ >> R-help@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. > > David Winsemius, MD > West Hartford, CT > > ______________________________________________ > R-help@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. > -- Ista Zahn Graduate student University of Rochester Department of Clinical and Social Psychology http://yourpsyche.org ______________________________________________ R-help@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.