Dear lme4 experts,

I have looked into the convergence warning thing a bit and it seems like
most models that I ran and that show convergence warnings pass the
with(model@optinfo$derivs,solve(Hessian,gradient)). That's really great! I
hope this test can be used as a substitute for the existing hessian and
absolute grad tests that fail so miserably with all larger models. Thanks a
lot.

However, I observed some strange behavior. I have three computers. One with
an AMD processor and on this computer solve(Hessian,gradient) is rarely
above 0. I also have two newer computers with recent Intel processors and
on these computers I occaisonally get solve(Hessian,gradient) > .001. It
commonly goes away after I refit but I never get the same values as on the
AMD machine. When I use 32bit R on the intels it also goes away.

Any ideas why this happens?

Below is an example of the AMD/Intel discrepancy (maybe a bad one but easy
to replicate).

I also checked with numDeriv and there are no differences commonly. By the
way, I noticed that I need to increase r in numDeriv for larger models
because numDeriv always stops after 4 iterations even when it has not
converged such that it yields wrong gradient estimates. When I increase r
and use numDeriv, I generally get the same estimates. For large models, I
sometimes need r=14. I believe that this may be helpful for Robert Long's
problem.

Thanks,
Tom


AMD:

>
> library(MASS)
> data(nlschools)
> library(lme4)
> df = data.frame(nlschools)
>
> rs2_glm2 = glmer(COMB ~ SES + (SES | class), family = "binomial",
+     data = df, control=glmerControl(tolPwrss = 1e-7,
+ optimizer="bobyqa",
+ optCtrl=list(maxfun=100000000)))
Warnmeldung:
In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
  Model failed to converge with max|grad| = 12.0734 (tol = 0.001)
>
> rs2_glm2b = glmer(COMB ~ SES + (SES | class), family = "binomial",
+     data = df, control=glmerControl(tolPwrss = 1e-7,
+ optimizer="Nelder_Mead",
+ optCtrl=list(maxfun=100000000)))
Warnmeldung:
In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
  Model failed to converge with max|grad| = 21.9445 (tol = 0.001)
>
>
> library(nloptr)
>  defaultControl <- list(algorithm="NLOPT_LN_BOBYQA",
+                                 xtol_rel=1e-6,maxeval=1e5)
>          nloptwrap2 <- function(fn,par,lower,upper,control=list(),...) {
+              for (n in names(defaultControl))
+                  if (is.null(control[[n]])) control[[n]] <-
defaultControl[[n]]
+              res <-
nloptr(x0=par,eval_f=fn,lb=lower,ub=upper,opts=control,...)
+              with(res,list(par=solution,
+                            fval=objective,
+                            feval=iterations,
+                            conv=if (status>0) 0 else status,
+                            message=message))
+          }
>
>
>
> rs2_glm2c = glmer(COMB ~ SES + (SES | class), family = "binomial",
+     data = df, control=glmerControl(tolPwrss = 1e-7,
+ optimizer="nloptwrap2"))
>
> rs2_glm2d = glmer(COMB ~ SES + (SES | class), family = "binomial",
+     data = df, control=glmerControl(tolPwrss = 1e-7,
+ optimizer="nloptwrap2",optCtrl=list(algorithm="NLOPT_LN_NELDERMEAD")))
Warnmeldungen:
1: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
  Model failed to converge with max|grad| = 16.2358 (tol = 0.001)
2: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
  Model is nearly unidentifiable: large eigenvalue ratio
 - Rescale variables?
>
> with(rs2_glm2@optinfo$derivs,solve(Hessian,gradient))
[1]  5.628057e-05  6.775849e-05 -7.998031e-05 -8.151270e-05 -8.092893e-05
> with(rs2_glm2b@optinfo$derivs,solve(Hessian,gradient))
[1] 5.022248e-05 5.057946e-05 5.079597e-05 5.104958e-05 5.084180e-05
> with(rs2_glm2c@optinfo$derivs,solve(Hessian,gradient))
[1] -1.609587e-04  9.238453e-06  2.183147e-07 -2.386170e-05  1.359452e-06
> with(rs2_glm2d@optinfo$derivs,solve(Hessian,gradient))
[1] -4.999612e-05  4.997835e-05  1.174517e-06  5.000784e-05 -4.994025e-05
> sessionInfo()
R version 3.0.3 (2014-03-06)
Platform: x86_64-w64-mingw32/x64 (64-bit)



Intel:
>
> library(MASS)
> data(nlschools)
> library(lme4)
> df = data.frame(nlschools)
>
> rs2_glm2 = glmer(COMB ~ SES + (SES | class), family = "binomial",
+     data = df, control=glmerControl(tolPwrss = 1e-7,
+ optimizer="bobyqa",
+ optCtrl=list(maxfun=100000000)))
Warning messages:
1: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
  Model failed to converge with max|grad| = 0.242031 (tol = 0.001)
2: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
  Model failed to converge: degenerate  Hessian with 1 negative eigenvalues
>
> rs2_glm2b = glmer(COMB ~ SES + (SES | class), family = "binomial",
+     data = df, control=glmerControl(tolPwrss = 1e-7,
+ optimizer="Nelder_Mead",
+ optCtrl=list(maxfun=100000000)))
Warning message:
In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
  Model failed to converge with max|grad| = 21.9445 (tol = 0.001)
>
>
> library(nloptr)
>  defaultControl <- list(algorithm="NLOPT_LN_BOBYQA",
+                                 xtol_rel=1e-6,maxeval=1e5)
>          nloptwrap2 <- function(fn,par,lower,upper,control=list(),...) {
+              for (n in names(defaultControl))
+                  if (is.null(control[[n]])) control[[n]] <-
defaultControl[[n]]
+              res <-
nloptr(x0=par,eval_f=fn,lb=lower,ub=upper,opts=control,...)
+              with(res,list(par=solution,
+                            fval=objective,
+                            feval=iterations,
+                            conv=if (status>0) 0 else status,
+                            message=message))
+          }
>
>
>
> rs2_glm2c = glmer(COMB ~ SES + (SES | class), family = "binomial",
+     data = df, control=glmerControl(tolPwrss = 1e-7,
+ optimizer="nloptwrap2"))
Warning messages:
1: In optwrap(optimizer, devfun, start, rho$lower, control = control,  :
  convergence code -2 from nloptwrap2
2: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
  Model failed to converge with max|grad| = 81.2371 (tol = 0.001)
>
> rs2_glm2d = glmer(COMB ~ SES + (SES | class), family = "binomial",
+     data = df, control=glmerControl(tolPwrss = 1e-7,
+ optimizer="nloptwrap2",optCtrl=list(algorithm="NLOPT_LN_NELDERMEAD")))
Warning messages:
1: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
  Model failed to converge with max|grad| = 16.2357 (tol = 0.001)
2: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
  Model is nearly unidentifiable: large eigenvalue ratio
 - Rescale variables?
>
> with(rs2_glm2@optinfo$derivs,solve(Hessian,gradient))
[1]  1.127671e-04  2.383063e-04 -3.040499e-04 -1.999103e-05  6.426745e-05
> with(rs2_glm2b@optinfo$derivs,solve(Hessian,gradient))
[1] 5.022248e-05 5.057946e-05 5.079597e-05 5.104958e-05 5.084180e-05
> with(rs2_glm2c@optinfo$derivs,solve(Hessian,gradient))
[1]  9.4326383374 -0.9909674438 -0.0000282799 -6.6806148859  0.9188746463
> with(rs2_glm2d@optinfo$derivs,solve(Hessian,gradient))
[1] -4.999612e-05  4.997836e-05  4.086415e-07  5.000782e-05 -4.994070e-05


> sessionInfo()
R version 3.0.1 (2013-05-16)
Platform: x86_64-w64-mingw32/x64 (64-bit)

	[[alternative HTML version deleted]]

