Home › forums › Mixed Models › mixed parametric bootstrapping with optimx::nlminb
- This topic has 4 replies, 2 voices, and was last updated 8 years, 5 months ago by
henrik.
-
AuthorPosts
-
-
June 1, 2017 at 08:37 GMT+0000 #76
Peter VavraParticipantI’m having trouble getting a glmm fitted using
optimix::nlminb(the default optimizer doesn’t converge) and calculating the p-values using parametric bootstrapping, using themixed()function. Interestingly, using likelihood ratio tests works just fine with the “same” code.this one works without any errors:
m6.LRT <- mixed( decision ~ expectation.mean * expectation.var * c.offer + (1 + c_c.offer | subject.id) + (0 + c_expectation.mean1 | subject.id), family="binomial", data=data.merged, method="LRT", cl=my.cluster, control=glmerControl(optimizer = "optimx",calc.derivs = FALSE, optCtrl = list(method = "nlminb", starttests = FALSE, kkt = FALSE))and this one (I only changed
method="LRT"tomethod="PB") does not work:m6.PB <- mixed( decision ~ expectation.mean * expectation.var * c.offer + (1 + c_c.offer | subject.id) + (0 + c_expectation.mean1 | subject.id), family="binomial", data=data.merged, method="PB", cl=my.cluster, control=glmerControl(optimizer = "optimx",calc.derivs = FALSE, optCtrl = list(method = "nlminb", starttests = FALSE, kkt = FALSE))Instead, I get the following error message:
Error in optwrap(object@optinfo$optimizer, ff, x0, lower = lower, control = control$optCtrl, : must specify 'method' explicitly for optimxAny ideas what I can do to make it work?
-
June 1, 2017 at 09:43 GMT+0000 #77
henrikKeymasterDoes it help to load
optimxat the clusters before running the code?
clusterEvalQ(my.cluster, library(optimx))If not, please let me know and I will investigate this further.
-
June 1, 2017 at 21:18 GMT+0000 #78
Peter VavraParticipantIt’s not an issue with the multi-core/cluster environment.
I’ve tried the suggested code, and also simply commented out the
cl=my.clusterline – still no success.However, running it on a single core gave a clue which might be helpful for debugging this: In my case, 8 models need to be fit. That step seems to work, as all eight “progress dots” (the
[........]) are there and the error message pops up when the function proceeds to calculate the p-values, i.e. just afterObtaining 7 p-values: [ -
June 1, 2017 at 22:57 GMT+0000 #79
henrikKeymasterThe problem appears to be in the function calculating the parametric bootstrap
pbkrtest::PBmodcomp:require(lme4) require(optimx) require(pbkrtest) ## Linear mixed effects model: data(beets, package="pbkrtest") sug <- lmer(sugpct ~ block + sow + harvest + (1|block:harvest), data=beets, REML=FALSE, control =lmerControl(optimizer = "optimx",optCtrl = list(method = "nlminb", starttests = FALSE, kkt = FALSE))) sug.h <- update(sug, .~. -harvest) PBmodcomp(sug, sug.h, nsim=50) # Error in optwrap(object@optinfo$optimizer, ff, x0, lower = lower, control = control$optCtrl, : # must specify 'method' explicitly for optimxI will contact the author and let you know what comes out of it. I can do little at the time.
-
June 6, 2017 at 09:25 GMT+0000 #80
henrikKeymasterAfter contacting
pbkrtestauthor Søren Højsgaard he told me that it was actually a bug inlme4::refit. So I looked into it and wrote a bug fix that was just merged intolme4: https://github.com/lme4/lme4/pull/421So either you wait until the new version of
lme4appears on CRAN (and I have no idea when this might be) or you install the development version:library("devtools"); install_github("lme4/lme4",dependencies=TRUE)
Note that installing the development version might require other dependencies depending on your OS (e.g.,RToolson Windows orXCodeon Mac).
-
-
AuthorPosts
- You must be logged in to reply to this topic.