Dear R users,
I am trying to fully understand the difference between estimating
overdispersion with glm.nb() from MASS compared to glm(..., family =
quasipoisson).
It seems that (i) the coefficient estimates are different and also (ii) the
summary() method for glm.nb suggests that overdispersion is taken to be one:
"Dispersion parameter for Negative Binomial(0.9695) family taken to be 1",
which is not what I expected.
The code I used is pasted below:
x <- rep(seq(0,23,by=1),50);
s <- rep(seq(1,2,length=50*24),1);
tmp <-
cbind.data.frame(y=rnbinom(length(tmp1),mu=8*(sin(2*pi*x/24)+2),size =
1),x=x,s=s);
tmp.glm.qp <- glm(y~factor(x)-1,data = tmp, family=quasipoisson,
offset=log(s));
tmp.glm.nb <- glm.nb(y~factor(x)-1 +offset(log(s)),data = tmp);
On a more advanced topic, I was furthermore hoping to compare models with a
global estimate of overdispersion with one that allows overdispersion to be
estimated separately for each level of the factor x. Can I achieve that in
glm or do I need to employ a mixed effects model ?
Thanks!
Markus
[[alternative HTML version deleted]]
______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.