Hi! I have fitted a Negative Binomial model (glm.nb) and a Poisson model (glm family=poisson) to some count data. Both have the same explanatory variables & dataset When I call sum(fitted(model.poisson)) for my GLM-Poisson model, I obtain exactly the same number of counts as my data. However, when I call sum(fitted(model.neg.binomial)) for my Negative Binomial model I clearly obtain many more count data (approx 27% more counts). Can anyone explain why such stark contrast between the two models exist? Why is the Negative Binomial massively over-estimating the values? Does it have to do with the dispersion parameter of the Negative Binomial model? Any thoughts or suggestions will be much appreciate it. Tomas -- View this message in context: http://r.789695.n4.nabble.com/over-estimation-Negative-Binomial-models-tp3912692p3912692.html Sent from the R help mailing list archive at Nabble.com.
over-estimation Negative Binomial models
3 messages · D_Tomas, Ben Bolker
D_Tomas <tomasmeca <at> hotmail.com> writes:
I have fitted a Negative Binomial model (glm.nb) and a Poisson model (glm family=poisson) to some count data. Both have the same explanatory variables & dataset When I call sum(fitted(model.poisson)) for my GLM-Poisson model, I obtain exactly the same number of counts as my data. However, when I call sum(fitted(model.neg.binomial)) for my Negative Binomial model I clearly obtain many more count data (approx 27% more counts). Can anyone explain why such stark contrast between the two models exist? Why is the Negative Binomial massively over-estimating the values? Does it have to do with the dispersion parameter of the Negative Binomial model?
Nothing springs to mind immediately. Can you post a reproducible example? The trivial example below works:
z <- rpois(1000,5) pm <- glm(z~1,family=poisson) sum(fitted(pm))
[1] 4975
sum(z)
[1] 4975
nbm <- MASS::glm.nb(z~1)
Warning messages: 1: In theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace = control$trace > : iteration limit reached 2: In theta.ml(Y, mu, sum(w), w, limit = control$maxit, trace = control$trace > : iteration limit reached
sum(fitted(nbm))
[1] 4975
Ben, this is a continuation of the query i posted on: http://r.789695.n4.nabble.com/GLM-and-Neg-Binomial-models-td3902173.html I cannot give you a direct example (big dataset) of what i did aside from what i have written: fitpoisson <- glm((RESPONSE) ~ A + B + offset(log(LENGTH)) + offset(log(LENGTH_OBSERVATION)),family="poisson",data= dataset) fitneg <- glm.nb((RESPONSE) ~ A + B + offset(log(LENGTH)) + offset(log(LENGTH_OBSERVATION)),data= dataset)
sum(fitted(fitpoisson))
[1] 373
sum(fitted(fitneg))
[1] 514 Observed data is 373.... Any thoughts? tomas -- View this message in context: http://r.789695.n4.nabble.com/over-estimation-Negative-Binomial-models-tp3912692p3915162.html Sent from the R help mailing list archive at Nabble.com.