2

I'm trying to use the parallel computing version of dredge (package MUMIn) for model selection of my full glmer model:

 modmer.pom.full<-glmer(cbind(TEST,CONTROL)~ G+MS+l+MS*l+G*MS+G*l+I(l^2) + (1|c)+(1|s)+(1|l)+offset(log(qTEST/qCONTROL)),family=binomial(link = "logit"),data=df.pom.mer, control=glmerControl(optimizer="bobyqa"))

after setting the R cluster to be run in parallel,

cl <- makeCluster(3)
registerDoParallel(cl)
clusterExport(cl,"df.pom.mer")

I simply tried to use the pdredge function as it follows:

pdredge(modmer.pom.full,cluster=cl,rank = "AIC")

but there is not evaluation, contrary, I got the following output for all submodels:

Warning messages:
1: In eval(expr, envir, enclos) :
  could not find function "glmer" (model 0 skipped)

I did not observed this problem by using the non-parallel computing function dredge. It seems that glmer is not recognized by pdredge, but I could not find the cause. I'm new user of both MUMIn and parallel packages, so could it be that I' missing something importnat in pdredge arguments?

Thanks a lot, Juan

merv
  • 67,214
  • 13
  • 180
  • 245
jrs-x
  • 336
  • 1
  • 2
  • 10
  • 1
    It is explained in `?pdredge` -> "Details" (first paragraph). – Kamil Bartoń May 16 '15 at 13:16
  • upppsss...thanks a lot Kamil and sorry for this; I should think twice before asking. Solved. – jrs-x May 17 '15 at 14:15
  • Hi - I found your post in Cross Validation - Use nonlinear mixed model for binomial distributed data. I am trying to work on the same issue now and was wondering if you ever had any progress in the R environment on this topic? I just tried to use the nlme package to estimate the 3 selectivity parameters using a mixed effect apporach, but am having issues with residuals probably because I am not accounting for the log-likelihood binomial mass function. – user41509 Feb 13 '16 at 14:39
  • Hi user41509. Sorry for this late response. Nothing new under the sun, I haven't found any reliable way to implement the paired gear structural model (I guess we are talking about the same approach !?) into a mixed model approach, what's about you currently? – jrs-x Jan 19 '17 at 15:46

1 Answers1

1

Just for completeness, as suggested in comments, this works fine if you either (1) specify the fully qualified name (lme4::lmer below) or (2) use clusterEvalQ(cluster, library(lme4)) to make sure the package is loaded on the workers.

library(lme4)
library(parallel )
cluster = makeCluster(3, type = "SOCK")  ## also need snow installed
set.seed(101)
dd <- data.frame(x1=rnorm(1000),x2=rnorm(1000),x3=rnorm(1000),f=rep(1:20,each=50))
dd$z <- simulate(~x1+x2+x3+(1|f), newdata=dd, 
      newparams=list(theta=1,beta=rep(1,4), sigma=1), family=gaussian)[[1]]
full_model = lme4::lmer(z ~ x1*x2*x3 + (1 | f), data = dd, 
                        REML = FALSE, na.action = "na.fail")
clusterExport(cluster,"dd")
clusterEvalQ(cluster, library(lme4))
MuMIn::pdredge(full_model, cluster)
Ben Bolker
  • 211,554
  • 25
  • 370
  • 453