首页 > 解决方案 > 没有线性预测器的泊松 GLM 模型

问题描述

我正在尝试在 R 中运行代码(我对此很陌生),并且我得到了一个非常大的数据集,我需要使用它来拟合泊松 glm,例如 log(mu) = B0 +B1x1。设 Yi 为对象 i 的响应计数,xi = 1(黑色)和 xi = 0(白色)。

该数据集可在 www.stat.ufl.edu/~aa/glm/data 找到。

我加载了数据,但我很难理解这个模型。这是我到目前为止的代码,但显然我遗漏了一些东西。

str(hdata)
head(hdata)
attach(hdata)
hfit = glm(count ~ factor(race), family = poisson(link = log))
summary(hfit)

#plot the model
par(mfrow = c(2,2))
plot(hfit)

#overdispersion test
library(AER)
dispersiontest(hfit, trafo =1)

#goodness of fit test
sum(resid(hfit, type="pearson")^2)
#pvalue
1 - pchisq(2279.873, 1306)

我需要这个模型的帮助,因为我似乎无法区分每场比赛,我认为这就是我需要做的。当我运行 hfit 的摘要时,我最终得到 -2.38 作为截距,1.73 作为 factor(race)1。AIC 为 1122。此外,当我进行过度分散测试时,我得到 c = 0.743,如果模型具有等分散性,则 c = 0。我说的对吗?谢谢

标签: rlinear-regression

解决方案


推荐阅读