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

Jonathan Berant yonatansito at gmail.com
Mon Jan 14 15:07:46 UTC 2008









Dear list,

I am trying to fit a model using lmer()
I have the 2 usual random factors:
1. subjects 
2. items
However the items are divided into 3 groups and so I actually have - 
15 items randomly sampled from group 1 
15 items randomly sampled from group 2 
15 items randomly sampled from group 3.

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)

however when I run: ranef(lmerA) 

I see that lmer doesn't deal with that since there are only 15 numbers
for the item random effect when in fact there are 45 items.

So how do I specify that items is a random factor nested in a fixed factor?
Thanks!





More information about the R-lang mailing list