Unrealistic coefficients when comparing two count samples with glm poisson
source link: https://stats.stackexchange.com/questions/539208/unrealistic-coefficients-when-comparing-two-count-samples-with-glm-poisson/539212#539212
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
I would like to test the significance of the difference in mean between two independent count samples. I'm doing this with a GLM poisson in R, as shown in the code below:
a=c(0,0,0,0,0,0,0,0,0,0)
b=c(1,2,0,1,1,2,0,1,0,2)
c=data.frame(sp=c(a,b),grp=c(rep('A',10),rep('B',10)))
summary(glm(sp~grp,data=c,family=poisson))
Call:
glm(formula = sp ~ grp, family = poisson, data = c)
Deviance Residuals:
Min 1Q Median 3Q Max
-1.41421 -0.00006 -0.00006 0.00000 0.87897
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) -20.3 4914.8 -0.004 0.997
grpB 20.3 4914.8 0.004 0.997
(Dispersion parameter for poisson family taken to be 1)
Null deviance: 22.1807 on 19 degrees of freedom
Residual deviance: 8.3178 on 18 degrees of freedom
AIC: 28.159
Number of Fisher Scoring iterations: 18
As you can see, the coefficient values are not reflecting reality. I noticed that this happened because group "A" has mean=0. In this way, I would like to know if there is any way to fix this problem in glm, or if there is any other better method to test my hypothesis.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK