[R-sig-ME] False convergence of glmer model and loglikelihood

Tahira Jamil tahirajamil at yahoo.com
Thu Dec 24 00:41:10 CET 2009


Dear R user:
To examine the power of the LRT, I have simulated replicate data sets under H1 and analyzed them using both H0 (interaction term=0)and H1 to see whether H0 is rejected by the LRT. My algorithm is

Log.Lik<-
          function(  n.sim ,n,K){

        LogL0<- rep(NA,n.sim)
        Df0<-rep(NA,n.sim)


       LogL<-rep(NA,n.sim)
       Df<-rep(NA,n.sim)



     for (s in  1:n.sim ){
                                                
              site<-rep(1:n,each=K)  # K= No of sp
              sp<-rep(1:K,n)
              Z<-runif(K,2,10)

             r.coef<- rmvnorm(K, mean=c(0,0),
                            sigma=matrix(c(6.65,-1.237,           
                                         -1.237,0.3033), 2),
                                        method="chol")
             i.coef<-5.045-1.05612*Z+r.coef[,1]
             s.coef<- (-1.9315)+0.322*Z+r.coef[,2]
          

            site.coef<-rnorm(n,0,0.37)
            random.intercept <- i.coef[sp]
            random.slope <- s.coef[sp]
            random.site<-site.coef[site]
            # Z<-rnorm(K,5.89,1.89)
            X<-runif(n,0,5)


            X0<-X[site]
            Z0<-Z[sp]


            Y0<-invlogit(random.intercept+  random.slope *X0+        random.site )
         #  Y<-exp(Y)/(1+exp(Y))
            y0=rbinom(n*K,1,Y0)
            data0<-data.frame(sp,site,y0,X0,Z0 )
            fm0<-glmer(y0 ~ X0+Z0+ (1+X0 | sp)+(1|site),
                         family = binomial,data0)

              LL0 <- logLik(fm0)
              LogL0[s] <- as.numeric(LL0)
              Df0[s] <- attr(LL0, "df")




            fm<-glmer(y0 ~ X0*Z0+ (1+X0 | sp)+(1|site),
                         family = binomial,data0)

              LL <- logLik(fm)
              LogL[s] <- as.numeric(LL)
              Df[s] <- attr(LL, "df")
              
              
            }
         no.sim<- seq(1,n.sim,1)
      return(data.frame(no.sim,LogL0,Df0,LogL,Df))
      }

If i run my Programe n.sim=1000 I got 37 warnings

> warnings()
Warning messages:
1: In mer_finalize(ans) : singular convergence (7)
2: In mer_finalize(ans) : false convergence (8)
3: In mer_finalize(ans) : false convergence (8).................


Now my question is how can I have a statement in my progromme that if false convergence then Loglik==NA

Some help will be great!
Cheers

Tahira Jamil
Biometris (Ph.D student)
Wageningen University Wageningen
Email: tahira.jamil at wur.nl




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