user53020
user53020

Reputation: 889

Models fail to converge when using MuMIn::dredge

I am getting some error from the MuMIn::dredge function in R and do not know how to solve it.

Here is my data ...

library(lme4)
library(MuMIn)
library(arm)

I constructed a global model:

options(na.action = "na.fail") 
global.model<-lmer(yld.res ~ rain + brk+ act + 
    onset + wid + (1|state),data=dat,REML=FALSE)
stdz.model <- standardize(global.model,standardize.y = FALSE)
model.set <- dredge(stdz.model)

I get the following error which I do not know why is happening. For clarification, yld.res is residual that are obtained from the linear regression of yld against year for each state. dredge works fine if I use yld as response. Any help or suggestion would be appreciated.

Fixed term is "(Intercept)"
Warning messages:
1: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
 unable to evaluate scaled gradient
2: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
 Model failed to converge: degenerate  Hessian with 1 negative eigenvalues
3: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
 unable to evaluate scaled gradient
4: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
 Model failed to converge: degenerate  Hessian with 1 negative eigenvalues
5: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
 unable to evaluate scaled gradient
6: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
 Model failed to converge: degenerate  Hessian with 1 negative eigenvalues
7: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
unable to evaluate scaled gradient
8: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv,  :
Model failed to converge: degenerate  Hessian with 1 negative eigenvalues

Upvotes: 2

Views: 1612

Answers (1)

Ben Bolker
Ben Bolker

Reputation: 226761

tl;dr I think these are false positives. I don't see anything fishy in the data or the models. The likelihood curve is completely flat at the edge of the estimated space, which is screwing up the convergence checks (this is unusual, but there's nothing wrong with it).

Replicating your setup:

dd <- read.csv("SOtmpdat.csv")
library(lme4)
library(MuMIn)
library(arm)
options(na.action = "na.fail") 
global.model <- lmer(yld.res ~ rain + brk+ act + onset +
                   wid + (1|state), data=dd,REML=FALSE)
stdz.model <- standardize(global.model,standardize.y = FALSE)
model.set <- dredge(stdz.model)

Check out data:

library(ggplot2); theme_set(theme_bw())
library(reshape2)
mm <- melt(dd,id.var=c("year","state","yld.res"))
ggplot(mm,aes(value,yld.res,colour=state))+geom_point()+
    facet_wrap(~variable,scale="free")+geom_smooth(method="lm")

enter image description here

Not much going on here, but also nothing too bizarre-looking.

Look at coefficients of standardized model:

library(dotwhisker)
dwplot(stdz.model)+geom_vline(xintercept=0,lty=2)

enter image description here

No huge pairwise correlations among predictors:

cor(as.matrix(dd[,3:8]))
pairs(as.matrix(dd[,3:8]),gap=0,cex=0.5)

enter image description here

Let's find one of the models that breaks:

options(warn=1)
model.set <- dredge(stdz.model,trace=TRUE)

And try it out:

test1 <- lmer(formula = yld.res ~ z.brk + z.onset + (1 | state),
       data = model.frame(stdz.model),
       REML = FALSE)

Look more carefully:

mf <- transform(model.frame(stdz.model),
                z.onset.cat=cut_number(z.onset,4))
ggplot(mf,
       aes(z.brk,yld.res,
           colour=state))+geom_point()+
    facet_wrap(~z.onset.cat)

enter image description here

Again, nothing too funny-looking.

Let's explore the model fit by hand: there's only one explicit parameter (the among-state standard deviation).

tt <- as.function(test1)
tvec <- seq(0,1,length=501)
dvec <- sapply(tvec,tt)
par(las=1,bty="l")
plot(tvec,dvec,type="l")

enter image description here

Looks fine.

Upvotes: 4

Related Questions