Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201977

In R is there a way to increase the number of iterations of a likelihood ratio test using afex::mixed for a GLMM?

$
0
0

I have a GLMM that I am performing using lme4 that requires me to increase the number of iterations of a given model for it to converge. (see below)

Eavers <-glmer(Total.Aversive ~ c.conc*Sex*Condition*Environment 
                   + (c.conc|RatID), data=mydetoh, family=poisson)

    # Model did not converge, used code below to extend # of iterations and start from where the previous model left off.
    ss1 <- getME(Eavers,c("theta","fixef"))
    Eavers <- update(Eavers,start=ss1,control=glmerControl(optCtrl=list(maxfun=2e6)))
    summary(Eavers)

The "Eavers" model converges just fine with the above iteration increase. However, my "Environment" variable is a 3-level categorical variable. Thus, I need to use afex::mixed to run a likelihood ratio test to garner parameter estimates for the Environment variable overall. I cannot use anova or Anova to do this because it is a GLMM not an LMM. So, it seems I need to do this somehow in the afex::mixed command.

However, when attempting to run with allFit (or all_fit) = TRUE, the allFit arguments are disregarded and I have the same convergence failure warnings for all the models in the LRTs (see below)

Eavers.mxd<- afex::mixed(Total.Aversive ~ c.conc*Sex*Condition*Environment 
                    + (c.conc|RatID), data=mydetoh, family=poisson, method="LRT",progress = TRUE, all_fit = TRUE)

Warning messages:
1: extra argument(s) ‘all_fit’ disregarded
2: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  ... :
  Model failed to converge with max|grad| = 0.00100889 (tol = 0.001, component 1)
3: extra argument(s) ‘all_fit’ disregarded
4: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  ... :
  Model failed to converge with max|grad| = 0.00385805 (tol = 0.001, component 1)

etc...

I also tried allFit because that appears to be the new name of all_fit in the afex library.

        Eavers.mxd<- afex::mixed(Total.Aversive ~ c.conc*Sex*Condition*Environment 
                    + (c.conc|RatID), data=mydetoh, family=poisson, method="LRT",progress = TRUE, allFit = TRUE)

Warning messages:
1: extra argument(s) ‘allFit’ disregarded
2: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  ... :
  Model failed to converge with max|grad| = 0.00100889 (tol = 0.001, component 1)
3: extra argument(s) ‘allFit’ disregarded
4: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  ... :
  Model failed to converge with max|grad| = 0.00385805 (tol = 0.001, component 1)

etc...

These left me with the same warning messages as without allFit and additional warning messages informing me that allFit was disregarded as below. I squared my Z-values for other variables from the original GLMER to see how well they compared with the Chi-square values from the summary of the non-converged afex::mixed LRT and they were not close enough to be comfortable just reporting those values.

Am I using the wrong name for allFit/all_fit? Is there some other argument that I am missing in order to do this?

I just need to get the overall parameter estimates here for Environment and need to be able to increase the iterations on all models run in afex::mixed LRTs. I may need to increase the iterations twice as I had to do with one of the original GLMER models. Please provide code if you know, thanks in advance!


Viewing all articles
Browse latest Browse all 201977

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>