[R-sig-ME] Mixed Models convergence problems, Jordi Rosich
Jordi Rosich
jordirosich16 at gmail.com
Tue Nov 22 15:20:19 CET 2016
Thank you very much for your answer,
We have checked some of the possible solutions you proposed as well as the
?convergence help page:
-Center and scale predictor variables didn’t solve the convergence problems
because our variables are components obtained in a PCA analysis and are
“already centered”.
-Increasing the number of iterations of the optimizer didn’t solve the
convergence problem in all the different models.
-We didn’t check singularity or recompute gradient and Hessian with
Richardson extrapolation as we got unexpected values in some parts of
the process or didn’t fully understand how the process works.
-We tried to run the models with different optimizers as explained in the
?convergence page and got the attached output. It seems that changing the
optimizers didn't
One of the reasons we think our models could continue to fail is because in
our data (see previous mail for details) the levels of the random factor
Territory totally explain if a tree/nest-site/landscape is occupied or
unoccupied. For exemple, in Territory 1 all four trees/nest-site
forests/landscapes are occupied; in Territory 15 all three trees/nest-site
forests/landscapes are unoccupied. This happens with all our territories,
all nests/"no-nests" of a territory are either occupied or unoccupied.
Could this situation be problematic when estimating the random factor
variance and thus, is there a possibility that the convergence problem has
a relation with this fact?
Thank you in advance. Waiting for your answer,
Jordi Rosich
2016-11-15 6:19 GMT+01:00 Phillip Alday <Phillip.Alday at unisa.edu.au>:
> Hi Jordi,
>
> Without really knowing anything about your data (or more generally
> types of data common to your field) ....
>
> - Your model doesn't seem exceptionally complex -- just main effects
> and a single scalar (intercept-only) random effect. Of course, a simple
> model can still be "too" complex if you don't have much data.
>
> - However, it sometimes makes sense to use a more complicated model
> when you have convergence issues on a simple model -- sometimes, you
> really do need covariates to get any type of decent fit. (Based on your
> email, you may have already experienced this.)
>
> - Categorical variables are particularly 'nasty' when it comes to the
> number of model parameters as a categorical variable with n levels
> requires n-1 parameters in the model! Continuous variables only require
> 1 parameter apiece (correlation parameters in the random effects
> excepted).
>
> - Watch out for multicollinearity -- how strongly do tree height and
> tree width correlate with each other?
>
> - Your particular convergence warning often means that the optimiser
> was still moving along towards convergence / the solution when
> optimisation was stoppe. Sometimes this can be helped by just
> increasing the number of iterations that the optimiser is allowed to
> take, although this will increase computer time.
>
> - Make sure to check out the help page: ?convergence (after loading
> lme4) has many tips and tricks.
>
> Best,
> Phillip
>
> On Mon, 2016-11-14 at 22:33 +0100, Jordi Rosich wrote:
> > Hello,
> >
> >
> >
> > I'm Jordi Rosich, a student currently collaborating with the Biology
> > Conservation Group of the University of Barcelona. I'm writing you
> > because
> > I'm having model convergence troubles with some GLMMs using the
> > function
> > glmer of the package lme4 of R.
> >
> > Our research addresses nest-site selection of the Goshawk, a
> > territorial
> > bird of prey, and specifically we aim to understand which
> > environmental
> > variables are relevant for nest site-selection in this species.
> >
> >
> >
> >
> > *Our approach**:*
> >
> > 1) We sampled several environmental variables in sites used by
> > this
> > bird species in nest (1) and unoccupied sites (0), and therefore
> > occupation
> > status (0/1) is our dependent variable and the environmental
> > variables our
> > independent variables.
> >
> > 2) We performed three analysis at 3 different spatial-scales:
> > nest
> > tree, nest-site forest (being the 18 meters radius circular area
> > around the
> > nest-tree), and landscape around nest-site (500 meters radius
> > circular area
> > around the nest-tree).
> >
> > 3) We sampled 29 Goshawk nests comprised in 13 breeding pairs
> > territories (each territory may hold several nests) and 30 control
> > non-occupied random trees comprised in 25 "pseudo-territories" (the
> > near
> > trees being included in this "territories"). To avoid
> > pseudoreplication of
> > nests of the same breeding pair (or territory) we have considered the
> > factor "Territory" as our random factor in the mixed models. The
> > model
> > definition is approximately Y = explanatory variables +
> > (1|id Territory),
> > where Y is the occupation status (0/1) (See an example below).
> >
> > 4) Our independent variables are both categorical (e.g. tree
> > species;
> > aspect: an angle recoded into 4 categories) and continuous
> > (components
> > resulting of a PCA on several original environmental variables,
> > performed
> > to reduce the number of original variables). For more details for
> > each
> > analysis:
> >
> >
> > -Nest-tree scale: 2 continuous variables (FAC1TreeHeight,
> > FAC2TreeWidth)
> > and 1 four level categorical variable (TreeSpecies).
> >
> >
> >
> > -Nest-site forest scale: 4 continuous variables
> > (FAC1BroadLeavedTrees,
> > FAC2YoungPines, FAC3MaturePines, FAC4SlopeAndShrubs) and 1 four level
> > categorical variable (ForestAspect).
> >
> >
> >
> > -Landscape scale: 3 continuous variables (FAC1PinusVSQuercus,
> > FAC2HumanizedLand, FAC3DistanceToRoads).
> >
> >
> >
> >
> >
> >
> >
> > One example of the script used to model would be:
> >
> >
> >
> > mod1 <-
> > glmer(Occupation~FAC1Treeheight+FAC2TreeWidth+Sp+(1|Territory),
> > family=binomial, data=trees)
> >
> >
> >
> >
> >
> > *The problem: *
> >
> >
> >
> > While creating the candidate models with glmer function to later
> > select the
> > best ones by their AICcs, we've faced some warnings telling that some
> > of
> > the models are failing to converge:
> >
> >
> >
> > In checkConv(attr(opt, "derivs"), opt$par, ctrl =
> > control$checkConv, :
> >
> > Model failed to converge with max|grad| = 0.0483015 (tol = 0.001,
> > component 1)
> >
> >
> >
> > It happens specially, although not always, with the models with more
> > parameters and also with those containing categorical variables.
> >
> >
> >
> >
> > *My question: *
> >
> >
> >
> > Given our variables, random factor and data is there any particular
> > reason
> > why our models could fail to converge? If so, is there a possible
> > solution
> > to the convergence problem?
> >
> >
> >
> >
> >
> > Thank you very much in advance. Waiting for your answer,
> >
> >
> > Jordi Rosich
> >
> > [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > R-sig-mixed-models at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
-------------- next part --------------
source(system.file("utils", "allFit.R", package="lme4"))
mod1.all <- allFit(mod7)
ss <- summary(mod7.all)
> source(system.file("utils", "allFit.R", package="lme4"))
Loading required package: optimx
Loading required package: dfoptim
Warning messages:
1: package �optimx� was built under R version 3.1.3
2: package �dfoptim� was built under R version 3.1.3
>
> mod7.all <- allFit(mod7)
bobyqa : [OK]
Nelder_Mead : [OK]
nlminbw : [OK]
nmkbw : [OK]
optimx.L-BFGS-B : Warning messages:
1: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
unable to evaluate scaled gradient
2: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
Model failed to converge: degenerate Hessian with 2 negative eigenvalues
3: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
Model failed to converge with max|grad| = 0.0348916 (tol = 0.001, component 1)
4: In optwrap(optimizer, devfun, start, rho$lower, control = control, :
convergence code 52 from optimx
[OK]
nloptwrap.NLOPT_LN_NELDERMEAD : Warning messages:
1: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
unable to evaluate scaled gradient
2: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
Model failed to converge: degenerate Hessian with 2 negative eigenvalues
[OK]
nloptwrap.NLOPT_LN_BOBYQA : Warning messages:
1: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
unable to evaluate scaled gradient
2: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
Model failed to converge: degenerate Hessian with 1 negative eigenvalues
[OK]
Warning messages:
1: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
unable to evaluate scaled gradient
2: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
Model failed to converge: degenerate Hessian with 1 negative eigenvalues
> ss <- summary(mod7.all)
>
> ss
$which.OK
bobyqa Nelder_Mead
TRUE TRUE
nlminbw nmkbw
TRUE TRUE
optimx.L-BFGS-B nloptwrap.NLOPT_LN_NELDERMEAD
TRUE TRUE
nloptwrap.NLOPT_LN_BOBYQA
TRUE
$msgs
$msgs$bobyqa
[1] "unable to evaluate scaled gradient"
[2] "Model failed to converge: degenerate Hessian with 2 negative eigenvalues"
$msgs$Nelder_Mead
[1] "Model failed to converge with max|grad| = 0.0348916 (tol = 0.001, component 1)"
$msgs$nlminbw
NULL
$msgs$nmkbw
NULL
$msgs$`optimx.L-BFGS-B`
[1] "unable to evaluate scaled gradient"
[2] "Model failed to converge: degenerate Hessian with 2 negative eigenvalues"
$msgs$nloptwrap.NLOPT_LN_NELDERMEAD
[1] "unable to evaluate scaled gradient"
[2] "Model failed to converge: degenerate Hessian with 1 negative eigenvalues"
$msgs$nloptwrap.NLOPT_LN_BOBYQA
[1] "unable to evaluate scaled gradient"
[2] "Model failed to converge: degenerate Hessian with 1 negative eigenvalues"
$fixef
(Intercept) FAC1 Sp FAC2
bobyqa 16.50173 100.19109 -10.120367 15.785298
Nelder_Mead 14.29626 92.75704 -9.035921 14.328520
nlminbw 16.84478 104.24393 -10.379773 16.282572
nmkbw 16.84713 104.25701 -10.380784 16.283287
optimx.L-BFGS-B 16.78863 104.46214 -10.365431 16.283422
nloptwrap.NLOPT_LN_NELDERMEAD 6.80864 29.37206 -5.122633 7.822627
nloptwrap.NLOPT_LN_BOBYQA 6.80864 29.37206 -5.122633 7.822627
FAC1:Sp
bobyqa -28.000155
Nelder_Mead -25.885299
nlminbw -29.141723
nmkbw -29.145838
optimx.L-BFGS-B -29.207095
nloptwrap.NLOPT_LN_NELDERMEAD -8.478911
nloptwrap.NLOPT_LN_BOBYQA -8.478911
$llik
bobyqa Nelder_Mead
-14.93282 -15.25304
nlminbw nmkbw
-14.92859 -14.92859
optimx.L-BFGS-B nloptwrap.NLOPT_LN_NELDERMEAD
-14.92882 -15.49699
nloptwrap.NLOPT_LN_BOBYQA
-15.49699
$sdcor
Territori.(Intercept)
bobyqa 78.94909
Nelder_Mead 46.62540
nlminbw 84.60254
nmkbw 84.60060
optimx.L-BFGS-B 83.86274
nloptwrap.NLOPT_LN_NELDERMEAD 23.59960
nloptwrap.NLOPT_LN_BOBYQA 23.59960
$theta
Territori.(Intercept)
bobyqa 78.94909
Nelder_Mead 46.62540
nlminbw 84.60254
nmkbw 84.60060
optimx.L-BFGS-B 83.86274
nloptwrap.NLOPT_LN_NELDERMEAD 23.59960
nloptwrap.NLOPT_LN_BOBYQA 23.59960
$times
user.self sys.self elapsed user.child sys.child
bobyqa 41.67 0.00 41.73 NA NA
Nelder_Mead 2.86 0.00 2.85 NA NA
nlminbw 0.78 0.00 0.78 NA NA
nmkbw 1.14 0.00 1.15 NA NA
optimx.L-BFGS-B 3.18 0.02 3.30 NA NA
nloptwrap.NLOPT_LN_NELDERMEAD 0.39 0.00 0.41 NA NA
nloptwrap.NLOPT_LN_BOBYQA 0.36 0.01 0.41 NA NA
$feval
bobyqa Nelder_Mead
30031 1792
nlminbw nmkbw
NA 696
optimx.L-BFGS-B nloptwrap.NLOPT_LN_NELDERMEAD
246 289
nloptwrap.NLOPT_LN_BOBYQA
289
More information about the R-sig-mixed-models
mailing list