[R-sig-ME] Setting correlation to 0 for factored random effects

Matthew Albrecht albrem04 at student.uwa.edu.au
Mon Aug 30 05:14:12 CEST 2010


  Dear list,
How do you (can you) set the correlation among factored random effects 
to zero?

#For example:
     set.seed(69)
     sid <- factor(rep((1:10), 4))
     fac <- factor(rep(c("a","b","c","d"),each=10))
     dv <- c(rnorm(10, sd=1), rnorm(10, sd=2), rnorm(10, sd=3), 
rnorm(10, sd=4))
     df1 <- data.frame(sid, fac, dv)

     fm1 <- lmer(dv~fac+(1+fac|sid), data=df1)
     fm2 <- lmer(dv~fac+(0+fac|sid), data=df1)

#The method for setting the correlation to zero for the relationship 
between a continuous variable and the intercept is as far as I can tell 
not doing what I want it to. However, I think I can do it by creating 
new factors as below:

     df1$faca <- ifelse(df1$fac=="a", 1, 0)
     df1$facb <- ifelse(df1$fac=="b", 1, 0)
     df1$facc <- ifelse(df1$fac=="c", 1, 0)
     df1$facd<-ifelse(df1$fac=="d", 1, 0)

     
fm3<-lmer(dv~fac+(0+faca|sid)+(0+facb|sid)+(0+facc|sid)+(0+facd|sid), 
data=df1)

#Is this giving me what I want? (It seems to be). And is there another 
way for when I have more complex models?

Thanks,
Matt Albrecht




More information about the R-sig-mixed-models mailing list