我将尝试探索在数据集中填补缺失值的方法。我的数据集包含2001年至2009年、1月至12月、男性/女性和4个年龄组的发生次数(非自然、自然和总计)。
我正在研究的一种填补方法是泊松回归填补法。
假设我的数据如下所示:
我正在研究的一种填补方法是泊松回归填补法。
假设我的数据如下所示:
Year Month Gender AgeGroup Unnatural Natural Total
569 2006 5 Male 15up 278 820 1098
570 2006 6 Male 15up 273 851 1124
571 2006 7 Male 15up 304 933 1237
572 2006 8 Male 15up 296 1064 1360
573 2006 9 Male 15up 298 899 1197
574 2006 10 Male 15up 271 819 1090
575 2006 11 Male 15up 251 764 1015
576 2006 12 Male 15up 345 792 1137
577 2007 1 Female 0 NA NA NA
578 2007 2 Female 0 NA NA NA
579 2007 3 Female 0 NA NA NA
580 2007 4 Female 0 NA NA NA
581 2007 5 Female 0 NA NA NA
...
在进行基本的GLM回归后,由于缺失数据,删除了96个观测值。
在R中,是否有一种方法/包/函数可以使用此GLM模型的系数来“预测”(即填补)Total的缺失值(即使它只是将其存储在单独的数据框中 - 我将使用Excel合并它们)?我知道我可以使用系数来预测不同的层次行 - 但这将需要很长时间。希望有一种一步函数/方法?
Call:
glm(formula = Total ~ Year + Month + Gender + AgeGroup, family = poisson)
Deviance Residuals:
Min 1Q Median 3Q Max
-13.85467 -1.13541 -0.04279 1.07133 10.33728
Coefficients:
Estimate Std. Error z value Pr(>|z|)
(Intercept) 13.3433865 1.7541626 7.607 2.81e-14 ***
Year -0.0047630 0.0008750 -5.443 5.23e-08 ***
Month 0.0134598 0.0006671 20.178 < 2e-16 ***
GenderMale 0.2265806 0.0046320 48.916 < 2e-16 ***
AgeGroup01-4 -1.4608048 0.0224708 -65.009 < 2e-16 ***
AgeGroup05-14 -1.7247276 0.0250743 -68.785 < 2e-16 ***
AgeGroup15up 2.8062812 0.0100424 279.444 < 2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
(Dispersion parameter for poisson family taken to be 1)
Null deviance: 403283.7 on 767 degrees of freedom
Residual deviance: 4588.5 on 761 degrees of freedom
(96 observations deleted due to missingness)
AIC: 8986.8
Number of Fisher Scoring iterations: 4
iplot
包在这方面非常有帮助。 - Iteratorglm
不支持级联,但你可以使用前向选择变量进行类似操作。无论如何,最初的问题与预测有关,而不是所有随后的数据分析。 :) - Iterator