0

I'm trying to run mixed models using 'foreach' and 'dopar' but I keep getting an error that says "task 1 failed - "could not find function "lmer"".

Here's an example:

library(lme4)
A=c(30,39,52,58,90,102,109,120)
B <- c(10,11,12,13,14,16,17,18)
C=c(rep(1,4),rep(2,4))

abc <- function(){
model.data <- data.frame(A=A,B=B,C=C)
model.mixed<-lmer(A~B+(B|C),data=model.data)
return(summary(model.mixed)$coefficients[,1])
}

foreach(i = 1:3, .combine = rbind) %dopar% abc()

Would really appreciate any help on this.

sh1291
  • 45
  • 1
  • 1
  • 5

0 Answers0