[R-sig-ME] lower and upper bounds for optimizer="nloptwrap"

Ben Bolker bbo|ker @end|ng |rom gm@||@com
Fri Apr 8 03:24:45 CEST 2022


    glmmTMB should let you pass lower/upper bounds to the nlminb 
optimizer, although it's a little bit obscure (you need

  glmmTMB(optCtrl = list(lower = ..., upper = ...)

and you need to know the mapping/order in which the various model 
components get embedded so you can line up the lower/upper controls 
appropriately.

library(glmmTMB)
data("sleepstudy", package = "lme4")
fm1 <- glmmTMB(Reaction ~ Days + (Days|Subject), sleepstudy)
fm1$obj$par
  beta  beta betad theta theta theta
     1     1     0     0     0     0

this tells you that the fixed effects parameters come first in the 
parameter vector ...

   I don't think glmulti is going to work with glmmTMB though.

On 4/7/22 2:05 PM, Andras Farkas via R-sig-mixed-models wrote:
> Philip,
> 
> thanks. my actual model is based on some biological process/es where a negative value (or at times a value outside of a particular range) would not make sense, if estimated... I have done the model run with brms in the past which made this easi(er), but I also wanted to see if I can take advantage of automated model selection procedures available in R (have "way too many potential predictors"), so switched to frequentist approach to try to make it work with glmulti as I am far from being an R coding expert and there are enough available resources on the web that I have found helpful to set up the glmulti run with lmer... But I guess I may be stuck with bayesian it seems if I must box them in?
> 
> 
> thanks for the help
> 
> Andras
> 
> 
> 
> 
> 
> 
> On Thursday, April 7, 2022, 01:35:41 PM EDT, Phillip Alday <me using phillipalday.com> wrote:
> 
> 
> 
> 
> 
> lme4 uses the profiled log likelihood -- for linear mixed models, the
> maximum-likelihood estimates of the fixed effects can be computed
> directly for a given value of the random effects. Because of this, the
> optimization bounds are for the random effects (or more precisely, the
> lower Cholesky factor of the scaled random effects) and only serve to
> restrict them to possible values (positive variances and correlations in
> [-1, +1]).
> 
> In other words, you can't constrain the fixed effects in lme4.
> 
> Is there an inferential reason why you want to constrain the fixed effects?
> 
> On 7/4/22 12:18 pm, Andras Farkas via R-sig-mixed-models wrote:
>> Hello,
>>
>> wonder if I could get some help on how to specify lower and upper bounds for optimizer="nloptwrap". To date my approach looks like:
>>
>>
>> lmercontrollist<-lmerControl(optimizer = "nloptwrap",
>>                               restart_edge = TRUE,
>>                               boundary.tol = 1e-5,
>>                               calc.derivs = TRUE,
>>                               use.last.params = FALSE,
>>                               sparseX = FALSE,
>>                               standardize.X = FALSE,
>>                               ## input checking options
>>                               check.nobs.vs.rankZ = "ignore",
>>                               check.nobs.vs.nlev = "stop",
>>                               check.nlev.gtreq.5 = "ignore",
>>                               check.nlev.gtr.1 = "stop",
>>                               check.nobs.vs.nRE= "stop",
>>                               check.rankX = c("message+drop.cols", "silent.drop.cols", "warn+drop.cols",
>>                                               "stop.deficient", "ignore"),
>>                               check.scaleX = c("warning","stop","silent.rescale",
>>                                                "message+rescale","warn+rescale","ignore"),
>>                               check.formula.LHS = "stop",
>>                               ## convergence checking options
>>                               check.conv.grad     = .makeCC("warning", tol = 2e-3, relTol = NULL),
>>                               check.conv.singular = .makeCC(action = "message", tol = formals(isSingular)$tol),
>>                               check.conv.hess     = .makeCC(action = "warning", tol = 1e-6),
>>                               ## optimizer args
>>                               optCtrl = list(maxeval=100,lower = rep.int(0, 21),upper = rep.int(5, 21)),
>>                               mod.type = "lmer")
>>
>> let us ignore model appropriateness here and just focus on the constraints:
>>
>> m1 <- lmer(Reaction ~ Days + Subject+ (1|Days),data=sleepstudy,verbose=1,control =lmercontrollist)
>> summary(m1)
>>
>>
>>   as you will see the fixed effect values are negative. I also tried lb and ub instead of lower and upper based on nloptr function, but also did not help. Besides, just to be sure I understand correctly, the length of the lower/upper bounds must be the same as the length of fixed and random effect, correct? here I set to 21 based on output but am not exactly sure if the residual has to be included in the count or not...
>>
>> much appreciate your help,
>>
>> Andras
> 
>>
>> _______________________________________________
>> R-sig-mixed-models using r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
> 
>>
> 
> _______________________________________________
> R-sig-mixed-models using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models

-- 
Dr. Benjamin Bolker
Professor, Mathematics & Statistics and Biology, McMaster University
Director, School of Computational Science and Engineering
(Acting) Graduate chair, Mathematics & Statistics



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