Skip to content
Prev 58731 / 398502 Next

glm.nb stop on Error.

Hi,

I make an analysis sequence on R. In some cases the function glm.nb fail to 
ajust the model. Its Ok. The problem is that this error stop the program. I 
need treat this error and not stop the program. Something like this:

...
model <- glm.nb(y~x,maxit=1000)
if(glm.nb fail) {
teste[i] <- 0
}
else {       
teste[i] <- anova(modelo)$"P(>|Chi|)"[2]
}
...

I try this:
...
model <- NULL
model <- glm.nb(y~x,maxit=1000)
## When this fail model is not create, then model <- NULL
if(is.null(model)) {
teste[i] <- 0
}
else {       
teste[i] <- anova(modelo)$"P(>|Chi|)"[2]
}
...

But the problem is the glm.nb error stop the program.

Any idea?

Thanks
Ronaldo