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

Viechtbauer Wolfgang (STAT) Wolfgang.Viechtbauer at STAT.unimaas.nl
Thu Dec 24 01:41:39 CET 2009


Dear Tahira,

Have a look at "try". In particular, put try() around your glmer() calls, then check for the class of the returned object, and if it is not what you want, set Loglik==NA.

Best,

--
Wolfgang Viechtbauer                        http://www.wvbauer.com/
Department of Methodology and Statistics    Tel: +31 (0)43 388-2277
School for Public Health and Primary Care   Office Location:
Maastricht University, P.O. Box 616         Room B2.01 (second floor)
6200 MD Maastricht, The Netherlands         Debyeplein 1 (Randwyck)
________________________________________
From: r-sig-mixed-models-bounces at r-project.org [r-sig-mixed-models-bounces at r-project.org] On Behalf Of Tahira Jamil [tahirajamil at yahoo.com]
Sent: Thursday, December 24, 2009 12:41 AM
To: r-sig-mixed-models at r-project.org
Subject: [R-sig-ME] False convergence of glmer model and loglikelihood

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

_______________________________________________
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