Message-ID: <64f15d49-edb6-aa3e-559f-6aeebf781a5d@gmail.com>
Date: 2019-10-07T18:13:55Z
From: Ben Bolker
Subject: allFit fails after removing object with starting values for model parameters from workspace
In-Reply-To: <dac46509-6d60-ea60-f139-1732f88f6d97@math.uni-giessen.de>
This works for me in the latest *development* version of lme4
(probably fixed since around the end of August). Does devel version
work for you? Maybe getting to be time for a new release (it's been 6
months: here's what's changed ...
https://github.com/lme4/lme4/blob/master/inst/NEWS.Rd )
On 2019-10-07 1:12 p.m., Gerrit Eichner wrote:
> Dear Ben and other lmer-experts,
>
> if I extend my setting a little bit, a new/similar problem appears.
> For some reasons I would like to change the control structures and
> "hardwire" that as in:
>
> lmerCtrl <- lmerControl(optCtrl = list(xtol_abs = 1e-9,
> ?????????????????????????????????????? ftol_abs = 1e-9))
>
> theta <- c(1, 0.01, 0.2)
> fm <- eval(bquote(
> ???? lmer(Reaction ~ Days + (Days | Subject), data = sleepstudy,
> ????????? start = .(theta),
> ????????? control = .(lmerCtrl))? # THIS IS NEW.
> ?))
>
>
> Then allFit "goes on strike" again, now complaining about unused
> arguments:
>
> allFit(fm, verbose = FALSE)
> Error in (function (optimizer = "nloptwrap", restart_edge = TRUE,
> boundary.tol = 1e-05,? :
> ? unused arguments (checkControl = list("ignore", "stop", "ignore",
> "stop", "stop", "message+drop.cols", "warning", "stop"), checkConv =
> list(list("warning", 0.002, NULL), list("message", 1e-04),
> list("warning", 1e-06)))
>
>
> Any ideas how to circumvent this?
>
> ? Best regards? --? Gerrit
>
> ---------------------------------------------------------------------
> Dr. Gerrit Eichner?????????????????? Mathematical Institute, Room 212
> gerrit.eichner at math.uni-giessen.de?? Justus-Liebig-University Giessen
> Tel: +49-(0)641-99-32104????????? Arndtstr. 2, 35392 Giessen, Germany
> http://www.uni-giessen.de/eichner
> ---------------------------------------------------------------------
>
> Am 08.08.2019 um 15:41 schrieb Gerrit Eichner:
>> Thx a lot, Ben, for the fast reply which clearly explains the
>> cause of my problem. I've just found a solution which works for
>> me (and which is not as simple as "don't delete theta" ;-) ):
>> I "hardwire" theta's value into the function call:
>>
>> theta <- c(1, 0.01, 0.2)
>> fm <- eval(bquote(
>> ??? lmer(Reaction ~ Days + (Days | Subject), data = sleepstudy,
>> ???????? start = .(theta))
>> ??? ))
>>
>> rm(theta)
>> allFit(fm, verbose = FALSE)
>>
>>
>> Works like a "charm", at least in my current workflow. :-)
>>
>> ??Thanks once more? --? Gerrit
>>
>> ---------------------------------------------------------------------
>> Dr. Gerrit Eichner?????????????????? Mathematical Institute, Room 212
>> gerrit.eichner at math.uni-giessen.de?? Justus-Liebig-University Giessen
>> Tel: +49-(0)641-99-32104????????? Arndtstr. 2, 35392 Giessen, Germany
>> http://www.uni-giessen.de/eichner
>> ---------------------------------------------------------------------
>>
>> Am 08.08.2019 um 15:26 schrieb Ben Bolker:
>>>
>>> ?? This is not surprising, as allFit() uses update(), which tries to
>>> re-evaluate the function ... at the very least allFit needs a
>>> documentation update with that hint ... (I also notice at a glance that
>>> the allFit docs seem to be incomplete anyway).
>>>
>>> ?? If you say more about your workflow we might be able to find a way to
>>> help.? (If your workflow is this simple then the answer would be "well
>>> then don't delete theta" ...)
>>>
>>> ?? cheers
>>> ???? Ben Bolker
>>>
>>>
>>> On 2019-08-08 9:06 a.m., Gerrit Eichner wrote:
>>>> Dear lmer-experts,
>>>>
>>>> if I refit a fitted model with all available optimizers AFTER
>>>> removing the object which contains the starting values for the
>>>> parameters of the model as in
>>>>
>>>> theta <- c(1, 0.01, 0.2)
>>>> fm <- lmer(Reaction ~ Days + (Days | Subject), data = sleepstudy,
>>>> ??????????? start = theta)
>>>> rm(theta)
>>>> allFit(fm, verbose = FALSE)
>>>>
>>>> none of the optimizers succeeds:
>>>>
>>>> original model:
>>>> Reaction ~ Days + (Days | Subject)
>>>> optimizers (7): bobyqa, Nelder_Mead, nlminbwrap, nmkbw,
>>>> optimx.L-BFGS-B,
>>>> nloptwrap.NLOPT_LN_N...
>>>> 7 optimizer(s) failed
>>>> differences in negative log-likelihoods:
>>>> max= -Inf ; std dev= NA
>>>> Warning messages:
>>>> 1: In min(nllvec) : no non-missing arguments to min; returning Inf
>>>> 2: In max(nllvec - min(nllvec)) :
>>>> ?? no non-missing arguments to max; returning -Inf
>>>>
>>>>
>>>> If I don't remove theta from my workspace everything works fine.
>>>> Is there a workaround for this - from my perspective - unwanted
>>>> behaviour? (I have situations where allFit is used in a different
>>>> environment from the one wherein the model was fit, e.g., after
>>>> fitting the model the object which contains the fit is saved and
>>>> later loaded in another R-session to be processed by allFit.)
>>>> I could, of course, save theta everytime as well ... Any ideas?
>>>>
>>>> ??Best regards? --? Gerrit
>>>>
>>>> ---------------------------------------------------------------------
>>>> Dr. Gerrit Eichner?????????????????? Mathematical Institute, Room 212
>>>> gerrit.eichner at math.uni-giessen.de?? Justus-Liebig-University Giessen
>>>> Tel: +49-(0)641-99-32104????????? Arndtstr. 2, 35392 Giessen, Germany
>>>> http://www.uni-giessen.de/eichner
>>>>
>>>> _______________________________________________
>>>> R-sig-mixed-models at r-project.org mailing list
>>>> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>>>
>>> _______________________________________________
>>> R-sig-mixed-models at r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>>>
>>
>> _______________________________________________
>> R-sig-mixed-models at r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>
> _______________________________________________
> R-sig-mixed-models at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models