[R] names() function and lmer()

Douglas Bates bates at stat.wisc.edu
Sat Jul 15 18:29:23 CEST 2006


On 7/15/06, A.R. Criswell <rstatistics at gmail.com> 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?

Yes.

The recommended way of retrieving information form a fitted model
object like an lmer object is with extractor functions.  See

?lmer-class

for a list of such methods.  That help page also documents the slots
in the object.  The lmer class is an S4 class and uses typed slots
instead of  named components.

The str function displays the structure of pretty well any type of R
object, including S3 classed objects or S4 classed objects.  That is
my favorite way of checking the structure of an object.

Please remember that it is risky to count on being able to reach in to
an object and pull out slots or components and operate on them.  The
names and contents of slots are not guaranteed to stay constant.  The
lme4 and Matrix packages have been under development for a long time
and should continue to be regarded as under development.  When we
change the internal representation we do change the extractor
functions accordingly.  It is a bug if an internal change causes an
extractor function in the package to fail to return correct results.
It is not a bug if an internal change causes your code that assumes a
particular, obsolete representation to break.



More information about the R-help mailing list