[R] glm.nb difficulties

ben@zoo.ufl.edu ben at zoo.ufl.edu
Wed May 16 19:41:46 CEST 2001


  I'm having problems (or to be precise a student is having problems,
which I'm having problems helping her with) trying to use glm.nb() from
the MASS package to do some negative binomial fits on a data set that is,
admittedly, wildly overdispersed (some zeros and some numbers in the
hundreds).

  glm.nb is failing to converge, and furthermore is (to my surprise)
producing values of theta that are larger and larger.

  Does anyone have advice beyond "don't do that"?  I did get some results
out of glm(...,family=quasipoisson()), but ideally I'd like to be able to
get likelihoods/AIC for model selection out of this exercise.


  thanks,
    Ben Bolker

#############################################
library(MASS)

tadT <- c(0,0,0,450,0,0,0,315,233,0,200,300)
Distance <- rep(c(10,100,500),rep(4,3))

plot(tadT)
plot(Distance,jitter(tadT))

## constant model
tad.con <- glm.nb(tadT ~ 1, control=glm.control(trace=10))
log(mean(tadT))  ## OK, it got the mean right at least ...

## given more iterations to get where it's going, it goes
## out of control (and crashes)
glm.nb(tadT ~ 1, control=glm.control(trace=10,maxit=100))

## doesn't help to make an identity link
glm.nb(tadT ~ 1,link=identity, control=glm.control(trace=10))
glm.nb(tadT ~ 1,link=identity, control=glm.control(trace=10,maxit=100))

## also try as a function of distance
tad.dist <- glm.nb(tadT ~ Distance)
## with trace/maxit set
glm.nb(tadT ~ Distance,control=glm.control(trace=10,maxit=100))
## does setting init.theta <<1 help?
glm.nb(tadT ~ Distance,init.theta=1e-6,control=glm.control(trace=10,maxit=100))
glm.nb(tadT ~ Distance,init.theta=1e-1,control=glm.control(trace=10,maxit=100))


## setting all zeros to 1 gives reasonable answers but???
tadT1 <- tadT
tadT1[tadT1==0] <- 1
glm.nb(tadT1 ~ Distance,control=glm.control(trace=10,maxit=100))

## quasipoisson does work ... but no likelihood/AIC available
glm.q1 <- glm(tadT ~ 1,family=quasipoisson())
glm.qd <- glm(tadT ~ Distance,family=quasipoisson())


-- 
318 Carr Hall                                bolker at zoo.ufl.edu
Zoology Department, University of Florida    http://www.zoo.ufl.edu/bolker
Box 118525                                   (ph)  352-392-5697
Gainesville, FL 32611-8525                   (fax) 352-392-3704

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list