[R-sig-ME] Problem with computing gr and false convergence

Ben Bolker bbolker at gmail.com
Tue Jun 14 23:02:21 CEST 2011


On 06/14/2011 04:12 PM, Iker Vaquero Alba wrote:
>    Thank you very much. Data is attached.

  Unfortunately, looking at your data makes it very clear that you will
have a lot of trouble fitting this model: maybe this isn't the complete
data set ... ?

 * there are only two years, which makes it nearly impossible to handle
year as a random effect

  * you have a total of 94 observations in the data set, and your model
involves 41 (!!) fixed effect parameter.  There is just no way you can
fit this many parameters (even neglecting the random effects).

  I had some success with this model by dropping the interactions and
fitting only the main effects.  The site-level variance is estimated as
zero, but there is some pair*site variance (and a significant difference
between years, at least as inferred from a Wald Z test)

X <- read.table("nfledge-nhatch insects 2009-2010.txt",header=TRUE)
X <- transform(X,site=factor(site),pair=factor(pair),year=factor(year))
X <- transform(X,ctlength=scale(tlength,center=TRUE))
f1 <- nhatch~(sex+mod+briventral+brithr+tlength+cond)^2-sex:mod
ncol(model.matrix(f1,data=X)) ## 41 parameters!
f2 <- nhatch~sex+mod+briventral+brithr+tlength+cond+year
ncol(model.matrix(f2,data=X)) ## 12 parameters
with(X,table(site,pair,year))
library(lme4)
g1 <-
glmer(nhatch~sex+mod+briventral+brithr+ctlength+cond+year+(1|site/pair),
      data=X,family=poisson,na.action=na.omit)


> 
>    To center and scale continuous variables, I've tried standardizing
> them, as someone suggested in some post, and I have succesfully done
> before. But when fitting the model with standardized variables, I get:
> 
>    "Error in `contrasts<-`(`*tmp*`, value = "contr.treatment") :
>   contrasts can be applied only to factors with 2 or more levels"
> 
>    Any ideas? Thank you very much!
> 
> 
> ------------------------------------------------------------------------
> *De:* Ben Bolker <bbolker at gmail.com>
> *Para:* r-sig-mixed-models at r-project.org
> *Enviado:* mar,14 junio, 2011 21:09
> *Asunto:* Re: [R-sig-ME] Problem with computing gr and false convergence
> 
> On 06/14/2011 02:57 PM, Iker Vaquero Alba wrote:
>>
>> Dear R-users:
>>
>> I am fitting a model with quite many terms, and I'm having a lot of
>> problems. Either I get:
>>
>>
>> "In mer_finalize(ans) : gr cannot be computed at initial par (65)"
>>
>> or false convergence problems, when the model is a little bit
>> simpler. I attach the most complex one with "verbose=TRUE" to see if
>> you can help me detectt where the problem is:
>>
>>
>>
> hatchcoltailmodel1<-lmer(nhatch~sex+mod+briventral+brithr+tlength+cond+briventral:brithr+briventral:tlength+briventral:cond+briventral:sex+briventral:mod+
>>brithr:tlength+brithr:cond+brithr:sex+brithr:mod+tlength:cond+tlength:sex+tlength:mod+
>>
> cond:sex+cond:mod+(1|site/pair)+(1|year),family=poisson,na.action=na.omit,verbose=TRUE)
>>
>>  0:          nan:  1.06217 0.584705 0.261488 -15.3440 -0.757161
>> 16.9953 3.85760  1.53215  1.30924  5.14768 -0.0259057 0.0675839
>> 0.172804  9.56398 0.000488889 -0.000119170 0.0156963 0.00445958
>> -0.109915 -0.0119783 -0.0113610 -0.00132653 0.00594852 -2.29204e-05
>> -0.0678690 0.00288760 0.321050 -0.0107392 0.0195566 -0.00242138
>> -0.0538382 -0.0866086 -0.00632440 -0.168793 -0.0123981 0.00379237
>> -0.00313671 -0.0228579 0.504940      nan -0.722186 -1.31712 -0.618912
>>  -1.25492 Mensajes de aviso perdidos In mer_finalize(ans) : gr cannot
>> be computed at initial par (65)
>>
>>
> 
>   Very  hard to say without a reproducible example.  Can you post the
> data somewhere?
> 
>   How big is your data set?
> 
>   If any of your variables are continuous, consider centering and
> scaling them (e.g. using scale())
> 
> 
>   Other than that, I only have a couple of coding style suggestions.
> 
> 1. I *think* but am not sure that your very long model above is
> equivalent to
> 
> (briventral+brithr+tlength+cond+sex+mod)^2-mod:sex
> 
> (all main effects + all pairwise interactions except mod:sex) but you
> should of course check that (and the order might not be the same as the
> model you have above).
> 
> 2.  It is best to use the 'data' argument to specify a data frame
> (rather than attach()ing or having the variables floating around in the
> workspace)
> 
> _______________________________________________
> R-sig-mixed-models at r-project.org
> <mailto:R-sig-mixed-models at r-project.org> mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models




More information about the R-sig-mixed-models mailing list