0

I´m comparing the incidence in four different regions in order to see whether they are equal or not. First I fit a poisson model, but I´m uncertain as to how I can test the variance=mean assumption when I use an offset. Hence, I wanted to fit a negative binomial function and compare the two with a likelihood-ratio test. However, the glm.bn function from MASS throws an error. Any ideas what is wrong?

library(MASS)
b <- data.frame(
  s=c(1800,539,490,301),
  pop=c(2900000,1327000,880000,268000),
  reg=c("A","B","C","D")
)

glm.nb(s~reg+offset(log(pop)),data=b)

results in

Error in while ((it <- it + 1) < limit && abs(del) > eps) { : 
  missing value where TRUE/FALSE needed
Andrie
  • 176,377
  • 47
  • 447
  • 496
Misha
  • 3,114
  • 8
  • 39
  • 60
  • 1
    make sure to include a call to `library(MASS)` (or other relevant packages) if your sample code depends on it – Ricardo Saporta Aug 06 '13 at 16:07
  • 2
    If you only have 4 observations with which to fit 4 parameters, there's no way you can test for overdispersion. The error is probably related to that. – Hong Ooi Aug 06 '13 at 16:13
  • See this answer https://stackoverflow.com/a/11751740/9956805 which shows that because there is no boundary for the theta parameter, it can cause issues when fitting the model. – Rekyt Apr 09 '20 at 06:45

0 Answers0