How to set two random effects separately in lme?

I am making a linear mixed effects model that is installed by REML in the nlme package. And these are the codes that work for me:

# Linear mixed-effects model fit by REML (intercept and not slope) x <- lme (DV ~ IV1 + IV2 + IV1*IV2, data=a.frame, random=~1|speaker) summary(x) # Linear mixed-effects model fit by REML (slope and no intercept) x1 <- lme (DV ~ IV1 + IV2 + IV1*IV2, data=a.frame, random=~IV3-1|speaker) summary(x1) # Linear mixed-effects model fit by REML (slope and intercept) x2 <- lme (DV ~ IV1 + IV2 + IV1*IV2, data=a.frame, random=~IV3|speaker) summary(x2) #nested random effect x5 <- lme (DV ~ IV1 + IV2 + IV1*IV2, data=a.frame, random=~1|speaker/item) summary(x5) 

What I really would like to do is have a model with a speaker and an object as random effects separately. I tried using this formula:

 x4 <- lme (DV ~ IV1 + IV2 + IV1*IV2, data=a.frame, random=~1|speaker + 1|item) 

However, this formula gives me the following warning message:

 Warning message: In Ops.factor(speaker, 1) : + not meaningful for factors 

Do you have any idea what this means? And how can I put both the speaker and the subject as random effects separately?

+7
random r nlme
source share
1 answer

I think that you can enable two random effects separately (one for speakers and one for time) using lme() following code:

 x4 <- lme (DV ~ IV1 + IV2 + IV1*IV2, data=a.frame, random=~ speaker + item -1 | id), 

with the id a higher level variable in which both speaker and item are nested. If you do not have such a variable, you can enter it as a new variable with a value of 1 for all cases.

+1
source share

All Articles