[R] monte carlo simulations/lmer

Douglas Bates dmbates at gmail.com
Mon Aug 15 20:16:33 CEST 2005


On 8/13/05, Eduardo Leoni <e.leoni at gmail.com> wrote:
> Hi - I am doing some monte carlo simulations comparing bayesian (using
> Plummer's jags) and maximum likelihood (using lmer from package lme4
> by Bates et al).
> 
> I would like to know if there is a way I can flag nonconvergence and
> exceptions. Currently the simulations just stop and the output reads
> things like:
> 
> Error in optim(.Call("lmer_coef", x, 2, PACKAGE = "Matrix"), fn, gr,
> method = "L-BFGS-B",  :
>     L-BFGS-B needs finite values of 'fn'
> In addition: Warning message:
> Leading minor of size 1 of downdated X'X is indefinite
> 
> Error in .local(object, ...) : Leading 2 minor of Omega[[1]] not
> positive definite
> In addition: Warning messages:
> 1: optim or nlminb returned message ERROR: ABNORMAL_TERMINATION_IN_LNSRCH
> in: "LMEoptimize<-"(`*tmp*`, value = list(maxIter = 200, msMaxIter = 200,
> 2: optim or nlminb returned message ERROR: ABNORMAL_TERMINATION_IN_LNSRCH
> in: "LMEoptimize<-"(`*tmp*`, value = list(maxIter = 200, msMaxIter = 200,

As Rolf Turner indicated, you can wrap the call to lmer in try() to
prevent breaking the loop on convergence failure.  I'm not sure
exactly what Bayesian analysis you are doing but you may want to look
at the function mcmcsamp in versions 0.98-1and later of the Matrix
package.  It can take a fitted lmer object and create an MCMC sample
from the posterior distribution of the parameters assuming a locally
uniform prior on the fixed-effects parameters and the non-informative
prior described by Box and Tiao for the variance-covariance matrices.




More information about the R-help mailing list