[R] convergence problem gamm / lme

Simon Wood s.wood at bath.ac.uk
Fri Jan 23 12:32:21 CET 2009


Geert,

Can you get a simpler model with, say, a quadratic dependence on lon, lat to 
converge, using glmmPQL? The answer might give a clue about whether the issue  
is related to using a smoother, or is something more basic.

How confident are you that the Poisson assumption is reasonable?

Can the model be fitted to a random subsample of the data, or does it always 
fail? PQL can fail to converge, but it's usually not as obstinate as it seems 
to be in this case, if the model structure is reasonable and identifiable.

best,
Simon





On Thursday 22 January 2009 15:52, geert aarts wrote:
> Hope one of you could help with the following question/problem:
> We would like to explain the spatial
> distribution of juvenile fish. We have 2135 records, from 75 vessels
> (code_tripnr) and 7 to 39 observations for each vessel, hence the random
> effect for code_tripnr. The offset (‘offsetter’) accounts for the haul
> duration and sub sampling factor. There are no extreme outliers in lat/lon.
> The model we try to fit is:
>
>
>
>
> gamm3<-gamm(count~offset(offsetter)+s(lon,lat),random=list(code_tripnr=~1),
>family="poisson", niterPQL=200)
>
>  Maximum number of PQL iterations:  200
>
> iteration 1
>
> iteration 2
>
> Error in MEestimate(lmeSt, grps) :
>
>
> NA/NaN/Inf in foreign function call (arg 1)
>
>
>
> We tried several things. We added some
> noise to lon and lat, modelled the density instead of using a count with
> model offset, and we normalized the explanatory variables. We also changed
> several settings (see models below).
>
>
>
> Interestingly, we do manage to fit a more
> complex model:
>
>  gamm2<-gamm(count~offset(offsetter)+
> s(lat,lon,year,dayofyear), random=list(code_tripnr=~1),family="poisson",
> correlation = corGaus(0.1, form=~lat + lon))
>
>
>
> The models are fitted using mgcv 1.4-1 and
> R 2.7.1 on a 64Bits Debian OS.
>
>
>
> So there seems to be a convergence problem, correct? And does someone have
> an idea what might cause this? Secondly are there some tricks/solutions.
> E.g. perhaps we could use the results from the more complex model (gamm2
> above), but I do not know exactly how. All help/advice would be greatly
> appreciated.
>
>
>
> Kind regards, Geert
>
>
>
>
>
>
>
> gamm3<-gamm(count~offset(offsetter)+s(lon,lat),
> random=list(code_tripnr=~1),family="poisson", correlation = corExp(1,
> form=~X + Y),nite
>
> rPQL=200)
>
>  Maximum number of PQL iterations:  200
>
> iteration 1
>
> iteration 2
>
> Error in recalc.corSpatial(object[[i]],
> conLin) :
>
>
> NA/NaN/Inf in foreign function call (arg 1)
>
> > gamm3<-gamm(count~offset(offsetter)+s(lon,lat,k=c(1,1)),random=list(code_
> >tripnr=~1),family="poisson",
>
> niterPQL=200)
>
>  Maximum number of PQL iterations:  200
>
> iteration 1
>
> iteration 2
>
> Error in lme.formula(fixed = fixed, random
> = random, data = data, correlation = correlation,  :
>
>   nlminb
> problem, convergence error code = 1
>
>
> message = false convergence (8)
>
> In addition: Warning messages:
>
> 1: In if (k < M + 1) { :
>
>   the
> condition has length > 1 and only the first element will be used
>
>
>
>
>
> .Options$mgcv.vc.logrange=0.001 # we also
> tried higher settings
>
>
> gamm3<-gamm(count~offset(offsetter)+s(lon,lat),random=list(code_tripnr=~1),
>family="poisson", niterPQL=200, control=lmeControl(opt="optim"))
>
>
>
>  Maximum number of PQL iterations:  200
>
> iteration 1
>
> iteration 2
>
> Error in optim(c(coef(lmeSt)),
> function(lmePars) -logLik(lmeSt, lmePars),
>
>
>
> initial value in 'vmmin' is not finite
>
>
>
> gamm3<-gamm(count~offset(offsetter)+s(lon,lat),random=list(code_tripnr=~1),
>family="poisson", niterPQL=200,control=lmeControl(minAbsParApV
>
> ar=0.0000000000001))
>
>  Maximum number of PQL iterations:  200
>
> iteration 1
>
> iteration 2
>
> Error in recalc.corSpatial(object[[i]],
> conLin) :
>
>
> NA/NaN/Inf in foreign function call (arg 1)
>
>
>
>
> gamm3<-gamm(count~offset(offsetter)+s(lon,lat),random=list(code_tripnr=~1),
>family="poisson", niterPQL=200)
>
>  Maximum number of PQL iterations:  200
>
> iteration 1
>
> iteration 2
>
> Error in MEestimate(lmeSt, grps) :
>
>
> NA/NaN/Inf in foreign function call (arg 1)
>
>
>
>
> gamm3<-gamm(count~offset(offsetter)+s(lon,lat,k=c(1,1)),random=list(code_tr
>ipnr=~1),family="poisson", niterPQL=200)
>
>  Maximum number of PQL iterations:  200
>
> iteration 1
>
> iteration 2
>
> Error in lme.formula(fixed = fixed, random
> = random, data = data, correlation = correlation,  :
>
>
> nlminb problem, convergence
> error code = 1
>
>
> message = false convergence (8)
>
> In addition: Warning messages:
>
> 1: In if (k < M + 1) { :
>
>   the
> condition has length > 1 and only the first element will be used
>
> 2: In smooth.construct.tp.smooth.spec(object,
> dk$data, dk$knots) :
>
>
> basis dimension, k, increased to minimum possible
>
>
>
>
>
>
> gamm3<-gamm(count~offset(offsetter)+s(lon,lat,k=c(8,8)),random=list(code_tr
>ipnr=~1),family="poisson", niterPQL=200)
>
>  Maximum number of PQL iterations:  200
>
> iteration 1
>
> iteration 2
>
> Error in lme.formula(fixed = fixed, random
> = random, data = data, correlation = correlation,  :
>
>
> nlminb problem, convergence
> error code = 1
>
>
> message = false convergence (8)
>
> In addition: Warning messages:
>
> 1: In if (k < M + 1) { :
>
>   the
> condition has length > 1 and only the first element will be used
>
> 2: In 1:UZ.len : numerical expression has 2
> elements: only the first used
>
> 3: In if (p.rank > ncol(XZ)) p.rank
> <- ncol(XZ) :
>
>   the
> condition has length > 1 and only the first element will be used
>
> 4: In 1:p.rank : numerical expression has 2
> elements: only the first used
>
> 5: In if (p.rank < k - j) Xf <- XZU[,
> (p.rank + 1):(k - j), drop = FALSE] else Xf <- matrix(0,  :
>
>   the
> condition has length > 1 and only the first element will be used
>
> 6: In (p.rank + 1):(k - j) :
>
>
> numerical expression has 2 elements: only the first used
>
> 7: In 1:p.rank : numerical expression has 2
> elements: only the first used
>
>
>
>
> gamm3<-gamm(count~offset(offsetter)+s(lon,lat,k=c(4,4),fx=T),random=list(co
>de_tripnr=~1),family="poisson", niterPQL=200)
>
>  Maximum number of PQL iterations:  200
>
> iteration 1
>
> iteration 2
>
> Error in MEestimate(lmeSt, grps) :
>
>
> NA/NaN/Inf in foreign function call (arg 1)
>
> In addition: Warning messages:
>
> 1: In if (k < M + 1) { :
>
>   the
> condition has length > 1 and only the first element will be used
>
> 2: In 1:UZ.len : numerical expression has 2
> elements: only the first used
>
>
>
>
> gamm3<-gamm(count~offset(offsetter)+te(lon,lat),random=list(code_tripnr=~1)
>,family="poisson", niterPQL=200,control=lmeControl(opt="opti
>
> m"))
>
>  Maximum number of PQL iterations:  200
>
> iteration 1
>
> iteration 2
>
> Error in optim(c(coef(lmeSt)),
> function(lmePars) -logLik(lmeSt, lmePars),
>
>
>
> initial value in 'vmmin' is not finite
>
>
>
>
> gamm3<-gamm(count~offset(offsetter)+s(lon,lat),random=list(code_tripnr=~1),
>family="poisson", niterPQL=200,control=lmeControl(tolerance=
>
> 0.00000000000001))
>
>  Maximum number of PQL iterations:  200
>
> iteration 1
>
> iteration 2
>
> Error in MEestimate(lmeSt, grps) :
>
>
> NA/NaN/Inf in foreign function call (arg 1)
>
> > gamm3<-gamm(count~offset(offsetter)+s(lon,lat),random=list(code_tripnr=~1
> >),family="poisson",
>
> niterPQL=200,control=lmeControl(niterEM=200))
>
>  Maximum number of PQL iterations:  200
>
> iteration 1
>
> iteration 2
>
> Error in MEestimate(lmeSt, grps) :
>
>
> NA/NaN/Inf in foreign function call (arg 1)
>
>
>
>
> gamm3<-gamm(count~offset(offsetter)+s(lon,lat),random=list(code_tripnr=~1),
>family="poisson",
> niterPQL=200,control=lmeControl(msTol=0.00000000000000001))
>
>  Maximum number of PQL iterations:  200
>
> iteration 1
>
> iteration 2
>
> Error in MEestimate(lmeSt, grps) :
>
>
> NA/NaN/Inf in foreign function call (arg 1)
>
>
>
>
> gamm3<-gamm(count~offset(offsetter)+s(lon,lat),random=list(code_tripnr=~1),
>family="poisson",
> niterPQL=200,control=lmeControl(.relStep=0.00000000000000000001))
>
>  Maximum number of PQL iterations:  200
>
> iteration 1
>
> iteration 2
>
> Error in MEestimate(lmeSt, grps) :
>
>
> NA/NaN/Inf in foreign function call (arg 1)
>
>
>
>
> gamm3<-gamm(count~offset(offsetter)+s(lon,lat),random=list(code_tripnr=~1),
>family="poisson",
> niterPQL=200,control=lmeControl(nlmStepMax=0.00000000000000000001))
>
>  Maximum number of PQL iterations:  200
>
> iteration 1
>
> iteration 2
>
> Error in MEestimate(lmeSt, grps) :
>
>
> NA/NaN/Inf in foreign function call (arg 1)
>
>
>
>
> gamm3<-gamm(count~offset(offsetter)+s(lon,lat),random=list(code_tripnr=~1),
>family="poisson",
> niterPQL=200,control=lmeControl(minAbsParApVar=0.0000000000001))
>
>  Maximum number of PQL iterations:  200
>
> iteration 1
>
> iteration 2
>
> Error in MEestimate(lmeSt, grps) :
>
>
> NA/NaN/Inf in foreign function call (arg 1)
>
>
>
>
> gamm3<-gamm(count~offset(offsetter)+s(lon,lat),random=list(code_tripnr=~1),
>family="poisson", niterPQL=200, control=lmeControl(returnObject=T))
>
>  Maximum number of PQL iterations:  200
>
> iteration 1
>
> iteration 2
>
> Error in MEestimate(lmeSt, grps) :
>
>
> Singularity in backsolve at level 0, block 1
>
> In addition: Warning messages:
>
> 1: In logLik.reStruct(object, conLin) :
>
>
> Singular precision matrix in level -1, block 1
>
> 2: In logLik.reStruct(object, conLin) :
>
>
> Singular precision matrix in level -1, block 1
>
> 3: In logLik.reStruct(object, conLin) :
>
>
> Singular precision matrix in level -1, block 1
>
> 4: In logLik.reStruct(object, conLin) :
>
>
> Singular precision matrix in level -1, block 1
>
> 5: In logLik.reStruct(object, conLin) :
>
>
> Singular precision matrix in level -1, block 1
>
> 6: In MEestimate(lmeSt, grps) :
>
>
> Singular precision matrix in level -1, block 1
>
>
> _________________________________________________________________
>
>
> 	[[alternative HTML version deleted]]

-- 
> Simon Wood, Mathematical Sciences, University of Bath, Bath, BA2 7AY UK
> +44 1225 386603  www.maths.bath.ac.uk/~sw283 




More information about the R-help mailing list