1

I've seen that a common error when running a generalized least squares (gls) from nlme package in R is the "false convergence (8)". I am trying to run gls models to account for the spatial dependence of my residuals, but I got stucked with the same problem. For example:

library(nlme)

set.seed(2)
samp.sz<-400
lat<-runif(samp.sz,-4,4)
lon<-runif(samp.sz,-4,4)
exp1<-rnorm(samp.sz)
exp2<-rnorm(samp.sz)

resp<-1+4*exp1-3*exp2-2*lat+rnorm(samp.sz)
mod.cor<-gls(resp~exp1+exp2,correlation=corGaus(form=~lat,nugget=TRUE))

Error in gls(resp ~ exp1 + exp2, correlation = corGaus(form = ~lat, nugget = TRUE)) : 
  false convergence (8)

(the above data simulation was copied from here because it yields the same problem I am facing).

Then, I read that the function glsControl has some parameters (maxIter, msMaxIter, returnObject) that can be setted prior running the analysis, which can solve this error. As an attempt to understand what was going on, I adjusted the three parameters above to 500, 2000 and TRUE, and ran the same code above, but the error still shows up. I think that the glsControl didn't work at all, because none result was shown even I've asked for it.

glsControl(maxIter = 500, msMaxIter=2000, returnObject = TRUE)
mod.cor<-gls(resp~exp1+exp2,correlation=corGaus(form=~lat,nugget=TRUE))

For comparison, if I run different models with the same variables, it works fine and no error is shown.

For example, models containing only one explanatory variable.

mod.cor2<-gls(resp~exp1,correlation=corGaus(form=~lat,nugget=TRUE))
mod.cor3<-gls(resp~exp2,correlation=corGaus(form=~lat,nugget=TRUE))

I really digged into several sites, foruns and books in a desperate search trying to solve it, and then I come to know that the 'false convergence' is a recurrent error that many users have faced. However, none of the previous posts seems to solve it for me. i really thought the glsControl could provide an alternative, but it didn't. Do you guys have a clue on how can I solve that?

I really appreciate any help. Thanks in advance.

Roland
  • 127,288
  • 10
  • 191
  • 288

1 Answers1

2

The problem is that the nugget effect is very small. Provide better starting values:

mod.cor <- gls(resp ~ exp1 + exp2, 
  correlation = corGaus(c(200, 0.1), form = ~lat, nugget = TRUE))
summary(mod.cor)
#<snip>
#Correlation Structure: Gaussian spatial correlation
# Formula: ~lat 
# Parameter estimate(s):
#       range       nugget 
#2.947163e+02 5.209379e-06
#</snip>

Note that this model may be sensitive to starting values even if there is no error or warning.

I would like to add a quote from library(lme4); help("convergence"):

The lme4 package uses general-purpose nonlinear optimizers (e.g. Nelder-Mead or Powell's BOBYQA method) to estimate the variance-covariance matrices of the random effects. Assessing reliably whether such algorithms have converged is difficult.

I believe something similar applies here. This model is clearly problematic and you should be grateful for getting this error. You should at least check how the fit changes with different starting values and try increasing the number of iterations or decreasing the tolerance. In the end, I would suggest looking for a model that better fits the data (we know that this would be an OLS model including lat as a linear predictor here).

PS: A good coding style uses blanks where appropriate.

Roland
  • 127,288
  • 10
  • 191
  • 288
  • Thank you very much. In the case of estimating a good nugget starting effect (10, 0.1). Because using semivariograms to estimate it requires first running the model – Luiz Henrique Varzinczak Jan 05 '18 at 12:38
  • 1
    You can always run a model without the correlation structure and investigate the residuals. – Roland Jan 05 '18 at 13:09