[R-lang] random factor nested in a fixed factor with lmer

T. Florian Jaeger tiflo at csli.stanford.edu
Wed Jan 16 00:07:50 UTC 2008


On Jan 15, 2008 3:35 PM, Austin Frank <austin.frank at gmail.com> wrote:

> On Mon, Jan 14 2008, Jonathan Berant wrote:
>
> > So the items are nested in a fixed factor called 'cond' (with 3
> > ordered levels).  I am not sure what is the syntax for fitting such a
> > model
> >
> > the dependent variable is 'expScore' and the predictors are 'sex'
> > (between subject factor with 2 levels), 'relig' (between subject
> > factor with 2 levels) and 'cond' (within subject factor with 3 levels
> > within which the items are nested)
> >
> > I tried doing:
> > lmerA = lmer(expScore~(relig+sex+cond)^2+(1|subjId) + (1|itemId),
> > data=religData)
> >
> > So how do I specify that items is a random factor nested in a fixed
> > factor?
>
> Jonathan--
>
> The correct answer partly depends on what variance structure you want to
> fit for the random effects.


In any case, however, you do not want to treat different items as if there
are the same. so, you should not use the same item id for items that are
actually different. i should have been clearer about this in my last
message.

Florian


>  You can try the following variations to get
> an idea of the different ways of dealing with nested effects within
> lmer:
>
> --8<---------------cut here---------------start------------->8---
> lmerB = lmer(expScore ~ (relig+sex+cond)^2 +
>                        (1 | subjId) +
>                        (1 | cond / itemId),
>             data=religData)
>
> lmerC = lmer(expScore ~ (relig+sex+cond)^2 +
>                        (1 | subjId) +
>                        (1 | cond : itemId),
>             data=religData)
>
> lmerD = lmer(expScore ~ (relig+sex+cond)^2 +
>                        (1 | subjId) +
>                        (1 | cond) +
>                        (1 | cond : itemId),
>             data=religData)
> --8<---------------cut here---------------end--------------->8---
>
> HTH,
> /au
>
> --
> Austin Frank
> http://aufrank.net
> GPG Public Key (D7398C2F): http://aufrank.net/personal.asc
>
> _______________________________________________
> R-lang mailing list
> R-lang at ling.ucsd.edu
> http://pidgin.ucsd.edu/mailman/listinfo/r-lang
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://pidgin.ucsd.edu/pipermail/r-lang/attachments/20080115/906138d7/attachment.htm 


More information about the R-lang mailing list