[Lign251] BLUPs
Roger Levy
rlevy at ucsd.edu
Sat Dec 6 15:26:20 PST 2008
Leslie Lee wrote:
> Hi,
>
> For 7.1(ii), I tried to generate the BLUPs:
>
>> b2=ranef(aa.f1.lmer)
>
> Even though this gives me 2 (unnamed) columns of 76 rows, corresponding to
> the speaker and the BLUPs, R doesn't seem to treat this as a regular data
> frame:
>
>> summary(b2)
> Length Class Mode
> Speaker 1 data.frame list
>
> The length of the thing is only 1, even though I see 2 columns and 76
> rows. I also can't access either column in the thing. How do I change this
> into a regular dataframe or into a vector?
Hi Leslie,
Good question: what's going on is that ranef() returns a list. For
information on lists, read chapter 6 of:
http://cran.r-project.org/doc/manuals/R-intro.pdf
Each component of the list corresponds to one of the clusterings of the
data -- so for example, applying ranef() to a model like
lmer(rt ~ Freq + (1 | Subj) + (1 | Item))
would give you a two-component list: a Subj component and an Item
component. Each component is itself a data frame where each column is a
cluster-level parameter and each row is a cluster. What you want to do is
b2 <- ranef(aa.f1.lmer)[[1]]
or
b2 <- ranef(aa.f1.lmer)$Speaker
or
b2 <- ranef(aa.f1.lmer)[["Speaker"]]
Hope this helps!
Roger
--
Roger Levy Email: rlevy at ling.ucsd.edu
Assistant Professor Phone: 858-534-7219
Department of Linguistics Fax: 858-534-4789
UC San Diego Web: http://ling.ucsd.edu/~rlevy
More information about the Lign251
mailing list