
   Thank you very much once again. The code for the graphs is really useful. 
However, I have to be a bit annoying again. When I have this model:

   > summary(s.g1.15)
Generalized linear mixed model fit by the Laplace approximation 
Formula: nhatch ~ mod + briventral + brithr + year + (1 | site/pair) 
   Data: X 
   AIC   BIC logLik deviance
 60.49 86.42 -19.25    38.49
Random effects:
 Groups    Name        Variance  Std.Dev.
 pair:site (Intercept) 0.0058536 0.076509
 site      (Intercept) 0.0000000 0.000000
Number of obs: 78, groups: pair:site, 33; site, 10

Fixed effects:
             Estimate Std. Error z value Pr(>|z|)    
(Intercept)  2.098850   0.241289   8.698  < 2e-16 ***
modEC       -0.176176   0.230818  -0.763   0.4453    
modR        -0.127108   0.160630  -0.791   0.4288    
modRC       -0.844478   0.211418  -3.994 6.49e-05 ***
modS        -0.493701   0.194935  -2.533   0.0113 *  
modSC       -0.366979   0.195177  -1.880   0.0601 .  
briventral   0.004852   0.001990   2.439   0.0147 *  
brithr      -0.009836   0.004923  -1.998   0.0457 *  
year2010     0.383809   0.163887   2.342   0.0192 *  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

Correlation of Fixed Effects:
           (Intr) modEC  modR   modRC  modS   modSC  brvntr brithr
modEC       0.027                                                 
modR       -0.355  0.423                                          
modRC      -0.419  0.272  0.440                                   
modS       -0.227  0.395  0.490  0.365                            
modSC      -0.425  0.276  0.468  0.372  0.365                     
briventral -0.577 -0.345 -0.063  0.023 -0.198  0.145              
brithr     -0.453 -0.047  0.027  0.163  0.090 -0.004 -0.281       
year2010   -0.039 -0.051 -0.011 -0.016 -0.715  0.021  0.171 -0.131


   and I try to simplify, again, the variable "briventral", I get the same error 
message as usual:

   > s.g1.21<-update(s.g1.15,~.-briventral)
Mensajes de aviso perdidos
1: In mer_finalize(ans) :
  Cholmod warning 'not positive definite' at 
file:../Cholesky/t_cholmod_rowfac.c, line 432
2: In mer_finalize(ans) : false convergence (8)

   I cannot understand why, I mean, if the models with more parameters in it 
worked, why this one, which is much less suspicious of being overfitted, 
doesn't? Obviously it looks like there's a big problem with the variable itself. 
Any ideas about what could it be, or posible solutions? 

   Sorry again. Thank you very much

   Iker




________________________________
De: Ben Bolker <bbolker@gmail.com>

CC: r-sig-mixed-models@r-project.org
Enviado: mié,15 junio, 2011 16:14
Asunto: Re: [R-sig-ME] Problem with computing gr and false convergence

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 06/14/2011 06:45 PM, Iker Vaquero Alba wrote:
> 
>    Thank you so much for that, Ben.
> 
>    I´m trying to do a split plot simplification with that model, but I
> still get this message with briventral:
> 
>     s.g1.5<-update(g1,~.-briventral)
> Mensajes de aviso perdidos
> 1: In mer_finalize(ans) :
>   Cholmod warning 'not positive definite' at
> file:../Cholesky/t_cholmod_rowfac.c, line 432
> 2: In mer_finalize(ans) : false convergence (8)
> 
> 
>     Do you think I should try to centre and scale that variable as well?
> 
>    Thank you.
> 
>    Iker.

  Oddly enough I am able to fit the model better when the continuous
variables are *not* centered and scaled.  I can't explain this
particularly well, but weird things sometimes happen when you have a
model that is on the edge of being overfitted (which this one still is
- -- 12 parameters plus two nested random effects for 94 data points in a
fairly unbalanced design). Some code is also included below to take a
quick look at the distribution of the data.  There are some patterns,
but the continuous variables don't seem to be doing too much ...

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),
               cbriventral=scale(briventral))
f1 <- nhatch~(sex+mod+briventral+brithr+tlength+cond)^2-sex:mod
[[elided Yahoo spam]]
f2 <- nhatch~sex+mod+briventral+brithr+tlength+cond+year
ncol(model.matrix(f2,data=X)) ## 12 parameters  (still dicey)
with(X,table(site,pair,year))
library(lme4)
X <-
na.omit(subset(X,select=c(site,pair,year,sex,mod,nhatch,briventral,brithr,tlength,cond)))

g1 <-
glmer(nhatch~sex+mod+briventral+brithr+tlength+cond+year+(1|site/pair),
      data=X,family=poisson)
s.g1.5<-update(g1,~.-briventral)

library(ggplot2)
X2 <- melt(X,id.var=1:6)
ggplot(X2,
       aes(x=value,y=nhatch,colour=mod,shape=sex))+
         geom_point()+facet_grid(year~variable,scale="free_x")
ggplot(X,
     aes(x=mod,y=nhatch,colour=mod))+geom_boxplot()+facet_grid(year~sex)

dd <- drop1(g1)


> 
> ------------------------------------------------------------------------
> *De:* Ben Bolker <bbolker@gmail.com>

> *CC:* r-sig-mixed-models@r-project.org
> *Enviado:* mar,14 junio, 2011 23:02
> *Asunto:* Re: [R-sig-ME] Problem with computing gr and false convergence
> 
> 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
[[elided Yahoo spam]]
> 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"
>>
[[elided Yahoo spam]]
>>
>>
>> ------------------------------------------------------------------------
>> *De:* Ben Bolker <bbolker@gmail.com <mailto:bbolker@gmail.com>>
>> *Para:* r-sig-mixed-models@r-project.org
> <mailto:r-sig-mixed-models@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@r-project.org <mailto:R-sig-mixed-models@r-project.org>
>> <mailto:R-sig-mixed-models@r-project.org
> <mailto:R-sig-mixed-models@r-project.org>> mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
> 

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk34vmEACgkQc5UpGjwzenNQ6wCfcdqWiIBponA2bbunKJva2L2V
drIAnA8HrCIYfGt/yWpZUdgMPTTP5CeX
=wLn4
-----END PGP SIGNATURE-----

	[[alternative HTML version deleted]]


