我正在为CPUE数据运行零膨胀模型。这个数据有零膨胀的证据,我已经用Vuong测试证实了这一点(见下面的代码)。根据AIC,完整模型(zint)优于null。我现在想:
我已经向部门的一些统计人员寻求过帮助(他们以前从未这样做过,并将我发送到相同的谷歌搜索网站),在统计部门本身以外(每个人都太忙),以及stackoverflow feed。 / p>
我会很感激书籍的代码或指导(可在线免费获得),其代码涉及使用偏移变量时可视化ZIP和模型拟合。
yc=read.csv("CPUE_ycs_trawl_withcobb_BLS.csv",header=TRUE)
yc=yc[which(yc$countinyear<150),]
yc$fyear=as.factor(yc$year_cap)
yc$flocation=as.factor(yc$location)
hist(yc$countinyear,20)
yc$logoffset=log(yc$numtrawlyr)
###Run Zero-inflated poisson with offset for CPUE####
null <- formula(yc$countinyear ~ 1| 1)
znull <- zeroinfl(null, offset=logoffset,dist = "poisson",link = "logit",
data = yc)
int <- formula(yc$countinyear ~ assnage * spawncob| assnage * spawncob)
zint <- zeroinfl(int, offset=logoffset,dist = "poisson",link = "logit", data
= yc)
AIC(znull,zint)
g1=glm(countinyear ~ assnage * spawncob,
offset=logoffset,data=yc,family=poisson)
summary(g1)
####Vuong test to see if ZIP is even needed##
vuong(g1,zint)
##########DATASET###########
countinyear是第1列
##########DATASET###########
count assnage spawncob logoffset
56 0 0.32110173 2.833213
44 1 0.33712 2.833213
60 2 0.34053264 2.833213
0 4 0.19381496 2.833213
1 3 0.30819333 2.833213
33 0 0.32110173 2.833213
40 1 0.33712 2.833213
25 2 0.34053264 2.833213
0 3 0.30819333 2.833213
2 4 0.19381496 2.833213
6 0 0.32110173 2.833213
13 1 0.33712 2.833213
7 2 0.34053264 2.833213
0 3 0.30819333 2.833213
0 4 0.19381496 NA
5 0 0.32110173 2.833213
31 1 0.33712 2.833213
73 2 0.34053264 2.833213
0 3 0.30819333 2.833213
1 4 0.19381496 2.833213
0 0 0.32110173 2.833213
7 1 0.33712 2.833213
75 2 0.34053264 2.833213
3 3 0.30819333 2.833213
0 4 0.19381496 2.833213
19 0 0.32110173 2.833213
13 1 0.33712 2.833213
18 2 0.34053264 2.833213
0 3 0.30819333 2.833213
2 4 0.19381496 2.833213
11 0 0.32110173 2.833213
14 1 0.33712 2.833213
32 2 0.34053264 2.833213
1 3 0.30819333 2.833213
1 4 0.19381496 2.833213
12 0 0.32110173 2.833213
3 1 0.33712 2.833213
9 2 0.34053264 2.833213
2 3 0.30819333 2.833213
0 4 0.19381496 2.833213
5 0 0.32110173 2.833213
15 1 0.33712 2.833213
22 2 0.34053264 2.833213
5 3 0.30819333 2.833213
1 4 0.19381496 2.833213
1 0 0.32110173 2.833213
16 1 0.33712 2.833213
33 2 0.34053264 2.833213
4 3 0.30819333 2.833213
2 4 0.19381496 2.833213
6 0 0.32110173 2.833213
17 1 0.33712 2.833213
26 2 0.34053264 2.833213
1 3 0.30819333 2.833213
0 4 0.19381496 2.833213
16 0 0.32110173 2.833213
16 1 0.33712 2.833213
11 2 0.34053264 2.833213
1 3 0.30819333 2.833213
1 4 0.19381496 2.833213
2 0 0.32110173 2.833213
8 1 0.33712 2.833213
18 2 0.34053264 2.833213
0 3 0.30819333 2.833213
0 4 0.19381496 2.833213
2 0 0.32110173 2.833213
27 1 0.33712 2.833213
49 2 0.34053264 2.833213
1 3 0.30819333 2.833213
0 4 0.19381496 2.833213
1 0 0.32110173 2.833213
6 1 0.33712 2.833213
36 2 0.34053264 2.833213
17 3 0.30819333 2.833213
0 4 0.19381496 2.833213
10 0 0.32110173 2.833213
21 1 0.33712 2.833213
78 2 0.34053264 2.833213
32 3 0.30819333 2.833213
0 4 0.19381496 2.833213
0 0 0.32110173 2.833213
8 1 0.33712 2.833213
14 2 0.34053264 2.833213
7 3 0.30819333 2.833213
0 4 0.19381496 2.833213
0 1 0.13648433 2.833213
6 1 0.23952033 2.833213
12 2 0.32110173 2.833213
0 3 0.33712 2.833213
0 4 0.34053264 2.833213
30 0 0.13648433 2.833213
30 1 0.23952033 2.833213
25 2 0.32110173 2.833213
30 3 0.33712 2.833213
30 4 0.34053264 2.833213
68 0 0.13648433 2.833213
68 1 0.23952033 2.833213
55 2 0.32110173 2.833213
68 3 0.33712 2.833213
68 4 0.34053264 2.833213
0 0 0.13648433 2.833213
12 1 0.23952033 2.833213
26 2 0.32110173 2.833213
2 3 0.33712 2.833213
1 4 0.34053264 2.833213
0 0 0.13648433 2.833213
17 1 0.23952033 2.833213
36 2 0.32110173 2.833213
1 3 0.33712 2.833213
4 4 0.34053264 2.833213
1 0 0.13648433 2.833213
1 1 0.23952033 2.833213
4 2 0.32110173 2.833213
4 3 0.33712 2.833213
0 4 0.34053264 2.833213
3 0 0.13648433 2.833213
3 1 0.23952033 2.833213
3 2 0.32110173 2.833213
3 3 0.33712 2.833213
3 4 0.34053264 2.833213
0 0 0.13648433 2.833213
29 1 0.23952033 2.833213
33 2 0.32110173 2.833213
0 3 0.33712 2.833213
0 4 0.34053264 2.833213
0 0 0.13648433 2.833213
10 1 0.23952033 2.833213
7 2 0.32110173 2.833213
1 3 0.33712 2.833213
0 4 0.34053264 2.833213
0 0 0.13648433 2.833213
6 1 0.23952033 2.833213
18 2 0.32110173 2.833213
1 3 0.33712 2.833213
0 4 0.34053264 2.833213
0 0 0.13648433 2.833213
18 1 0.23952033 2.833213
37 2 0.32110173 2.833213
1 3 0.33712 2.833213
1 4 0.34053264 2.833213
0 0 0.13648433 2.833213
13 1 0.23952033 2.833213
26 2 0.32110173 2.833213
8 3 0.33712 2.833213
0 4 0.34053264 2.833213
0 0 0.13648433 2.833213
0 1 0.23952033 2.833213
1 2 0.32110173 2.833213
0 3 0.33712 2.833213
0 4 0.34053264 2.833213
0 0 0.13648433 2.833213
1 1 0.23952033 2.833213
5 2 0.32110173 2.833213
0 3 0.33712 2.833213
0 4 0.34053264 2.833213
0 0 0.13648433 2.833213
29 1 0.23952033 2.833213
15 2 0.32110173 2.833213
2 3 0.33712 2.833213
0 4 0.34053264 2.833213
0 0 0.13648433 2.833213
19 1 0.23952033 2.833213
25 2 0.32110173 2.833213
3 3 0.33712 2.833213
1 4 0.34053264 2.833213
0 0 0.13648433 2.833213
24 1 0.23952033 2.833213
40 2 0.32110173 2.833213
6 3 0.33712 2.833213
1 4 0.34053264 2.833213
0 0 0.03678637 2.772589
28 1 0.07414634 2.772589
28 2 0.13648433 2.772589
3 3 0.23952033 2.772589
2 4 0.32110173 2.772589
0 0 0.03678637 2.772589
3 1 0.07414634 2.772589
2 2 0.13648433 2.772589
0 3 0.23952033 2.772589
0 4 0.32110173 2.772589
4 0 0.03678637 2.772589
14 1 0.07414634 2.772589
6 2 0.13648433 2.772589
0 3 0.23952033 2.772589
0 4 0.32110173 2.772589
0 0 0.03678637 2.772589
6 1 0.07414634 2.772589
3 2 0.13648433 2.772589
2 3 0.23952033 2.772589
0 4 0.32110173 2.772589
0 0 0.03678637 2.772589
8 1 0.07414634 2.772589
2 2 0.13648433 2.772589
4 3 0.23952033 2.772589
1 4 0.32110173 2.772589
1 0 0.03678637 2.772589
12 1 0.07414634 2.772589
23 2 0.13648433 2.772589
0 3 0.23952033 2.772589
0 4 0.32110173 2.772589
0 0 0.03678637 2.772589
24 1 0.07414634 2.772589
56 2 0.13648433 2.772589
7 3 0.23952033 2.772589
4 4 0.32110173 2.772589
0 0 0.03678637 2.772589
22 1 0.07414634 2.772589
45 2 0.13648433 2.772589
3 3 0.23952033 2.772589
0 4 0.32110173 2.772589
0 0 0.03678637 2.772589
2 1 0.07414634 2.772589
18 2 0.13648433 2.772589
1 3 0.23952033 2.772589
0 4 0.32110173 2.772589
0 0 0.03678637 2.772589
5 1 0.07414634 2.772589
18 2 0.13648433 2.772589
5 3 0.23952033 2.772589
1 4 0.32110173 2.772589
0 0 0.03678637 2.772589
9 1 0.07414634 2.772589
25 2 0.13648433 2.772589
6 3 0.23952033 2.772589
1 4 0.32110173 2.772589
0 0 0.03678637 2.772589
1 1 0.07414634 2.772589
3 2 0.13648433 2.772589
1 3 0.23952033 2.772589
1 4 0.32110173 2.772589
0 0 0.03678637 2.772589
3 1 0.07414634 2.772589
16 2 0.13648433 2.772589
0 3 0.23952033 2.772589
0 4 0.32110173 2.772589
0 0 0.03678637 2.772589
7 1 0.07414634 2.772589
21 2 0.13648433 2.772589
8 3 0.23952033 2.772589
0 4 0.32110173 2.772589
0 0 0.03678637 2.772589
5 1 0.07414634 2.772589
22 2 0.13648433 2.772589
6 3 0.23952033 2.772589
0 4 0.32110173 2.772589
0 0 0.03678637 2.772589
11 1 0.07414634 2.772589
22 2 0.13648433 2.772589
6 3 0.23952033 2.772589
0 4 0.32110173 2.772589
1 0 0.11532605 2.564949
7 1 0.05628636 2.564949
11 2 0.03678637 2.564949
0 3 0.07414634 2.564949
0 4 0.13648433 2.564949
0 0 0.11532605 2.564949
4 1 0.05628636 2.564949
4 2 0.03678637 2.564949
0 3 0.07414634 2.564949
0 4 0.13648433 2.564949
0 0 0.11532605 2.564949
0 1 0.05628636 2.564949
5 2 0.03678637 2.564949
0 3 0.07414634 2.564949
1 4 0.13648433 2.564949
0 0 0.11532605 2.564949
3 1 0.05628636 2.564949
4 2 0.03678637 2.564949
0 3 0.07414634 2.564949
0 4 0.13648433 2.564949
0 0 0.11532605 2.564949
3 1 0.05628636 2.564949
0 2 0.03678637 2.564949
1 3 0.07414634 2.564949
0 4 0.13648433 2.564949
0 0 0.11532605 2.564949
1 1 0.05628636 2.564949
0 2 0.03678637 2.564949
0 3 0.07414634 2.564949
0 4 0.13648433 2.564949
0 0 0.11532605 2.564949
6 1 0.05628636 2.564949
9 2 0.03678637 2.564949
3 3 0.07414634 2.564949
0 4 0.13648433 2.564949
0 0 0.11532605 2.564949
3 1 0.05628636 2.564949
4 2 0.03678637 2.564949
3 3 0.07414634 2.564949
1 4 0.13648433 2.564949
0 0 0.11532605 2.564949
1 1 0.05628636 2.564949
3 2 0.03678637 2.564949
4 3 0.07414634 2.564949
0 4 0.13648433 2.564949
1 0 0.11532605 2.564949
3 1 0.05628636 2.564949
10 2 0.03678637 2.564949
2 3 0.07414634 2.564949
1 4 0.13648433 2.564949
0 0 0.11532605 2.564949
0 1 0.05628636 2.564949
3 2 0.03678637 2.564949
3 3 0.07414634 2.564949
1 4 0.13648433 2.564949
0 0 0.11532605 2.564949
24 1 0.05628636 2.564949
43 2 0.03678637 2.564949
11 3 0.07414634 2.564949
3 4 0.13648433 2.564949
0 0 0.11532605 2.564949
3 1 0.05628636 2.564949
19 2 0.03678637 2.564949
14 3 0.07414634 2.564949
2 4 0.13648433 2.564949
0 0 0.09016875 NA
25 1 0.14227471 2.833213
2 2 0.11532605 2.833213
0 3 0.05628636 2.833213
0 4 0.03678637 2.833213
0 0 0.09016875 2.833213
14 1 0.14227471 2.833213
0 2 0.11532605 2.833213
0 3 0.05628636 2.833213
0 4 0.03678637 2.833213
0 0 0.09016875 2.833213
12 1 0.14227471 2.833213
4 2 0.11532605 2.833213
0 3 0.05628636 2.833213
0 4 0.03678637 2.833213
1 0 0.09016875 2.833213
42 1 0.14227471 2.833213
20 2 0.11532605 2.833213
1 3 0.05628636 2.833213
2 4 0.03678637 2.833213
0 0 0.09016875 2.833213
48 1 0.14227471 2.833213
40 2 0.11532605 2.833213
1 3 0.05628636 2.833213
0 4 0.03678637 2.833213
10 0 0.09016875 2.833213
23 2 0.11532605 2.833213
0 3 0.05628636 2.833213
2 4 0.03678637 2.833213
2 0 0.09016875 2.833213
89 1 0.14227471 2.833213
5 2 0.11532605 2.833213
1 3 0.05628636 2.833213
6 4 0.03678637 2.833213
0 0 0.09016875 2.833213
27 1 0.14227471 2.833213
9 2 0.11532605 2.833213
3 3 0.05628636 2.833213
2 4 0.03678637 2.833213
1 0 0.09016875 2.833213
6 1 0.14227471 2.833213
0 2 0.11532605 2.833213
1 3 0.05628636 2.833213
0 4 0.03678637 2.833213
0 0 0.09016875 2.833213
65 1 0.14227471 2.833213
35 2 0.11532605 2.833213
1 3 0.05628636 2.833213
2 4 0.03678637 2.833213
0 0 0.09016875 2.833213
29 1 0.14227471 2.833213
26 2 0.11532605 2.833213
3 3 0.05628636 2.833213
1 4 0.03678637 2.833213
4 0 0.09016875 2.833213
105 1 0.14227471 2.833213
5 2 0.11532605 2.833213
0 3 0.05628636 2.833213
1 4 0.03678637 2.833213
4 0 0.09016875 2.833213
107 1 0.14227471 2.833213
5 2 0.11532605 2.833213
0 3 0.05628636 2.833213
0 4 0.03678637 2.833213
0 0 0.09016875 2.833213
17 1 0.14227471 2.833213
1 2 0.11532605 2.833213
0 3 0.05628636 2.833213
0 4 0.03678637 2.833213
3 0 0.09016875 2.833213
106 1 0.14227471 2.833213
1 2 0.11532605 2.833213
1 3 0.05628636 2.833213
0 4 0.03678637 2.833213
0 0 0.09016875 2.833213
21 1 0.14227471 2.833213
14 2 0.11532605 2.833213
5 3 0.05628636 2.833213
1 4 0.03678637 2.833213
0 0 0.09016875 2.833213
35 1 0.14227471 2.833213
12 2 0.11532605 2.833213
8 3 0.05628636 2.833213
2 4 0.03678637 2.833213
4 0 0.13510174 1.791759
1 1 0.10188844 1.791759
4 2 0.09016875 1.791759
0 3 0.14227471 1.791759
0 4 0.11532605 1.791759
3 0 0.13510174 1.791759
16 1 0.10188844 1.791759
11 2 0.09016875 1.791759
0 3 0.14227471 1.791759
0 4 0.11532605 1.791759
4 0 0.13510174 1.791759
20 1 0.10188844 1.791759
7 2 0.09016875 1.791759
0 3 0.14227471 1.791759
0 4 0.11532605 1.791759
0 0 0.13510174 1.791759
3 1 0.10188844 1.791759
1 2 0.09016875 1.791759
1 3 0.14227471 1.791759
1 4 0.11532605 1.791759
0 0 0.13510174 1.791759
2 1 0.10188844 1.791759
8 2 0.09016875 1.791759
2 3 0.14227471 1.791759
1 4 0.11532605 1.791759
0 0 0.13510174 1.791759
1 1 0.10188844 1.791759
40 2 0.09016875 1.791759
8 3 0.14227471 1.791759
0 4 0.11532605 1.791759
0 0 0.33638851 2.70805
0 1 0.20354567 2.70805
18 2 0.13510174 2.70805
2 3 0.10188844 2.70805
0 4 0.09016875 2.70805
0 0 0.33638851 2.70805
0 1 0.20354567 2.70805
1 2 0.13510174 2.70805
0 3 0.10188844 2.70805
0 4 0.09016875 2.70805
0 0 0.33638851 2.70805
1 1 0.20354567 2.70805
1 2 0.13510174 2.70805
0 3 0.10188844 2.70805
0 4 0.09016875 2.70805
0 0 0.33638851 2.70805
13 1 0.20354567 2.70805
23 2 0.13510174 2.70805
1 3 0.10188844 2.70805
13 4 0.09016875 2.70805
0 0 0.33638851 2.70805
1 1 0.20354567 2.70805
8 2 0.13510174 2.70805
3 3 0.10188844 2.70805
4 4 0.09016875 2.70805
0 0 0.33638851 2.70805
2 1 0.20354567 2.70805
9 2 0.13510174 2.70805
2 3 0.10188844 2.70805
0 4 0.09016875 2.70805
26 0 0.33638851 2.70805
2 1 0.20354567 2.70805
2 2 0.13510174 2.70805
0 3 0.10188844 2.70805
0 4 0.09016875 2.70805
57 0 0.33638851 2.70805
4 1 0.20354567 2.70805
6 2 0.13510174 2.70805
0 3 0.10188844 2.70805
1 4 0.09016875 2.70805
26 0 0.33638851 2.70805
3 1 0.20354567 2.70805
10 2 0.13510174 2.70805
2 3 0.10188844 2.70805
3 4 0.09016875 2.70805
9 0 0.33638851 2.70805
1 1 0.20354567 2.70805
3 2 0.13510174 2.70805
2 3 0.10188844 2.70805
0 4 0.09016875 2.70805
0 0 0.33638851 2.70805
0 1 0.20354567 2.70805
6 2 0.13510174 2.70805
1 3 0.10188844 2.70805
0 4 0.09016875 2.70805
0 0 0.33638851 2.70805
4 1 0.20354567 2.70805
16 2 0.13510174 2.70805
12 3 0.10188844 2.70805
3 4 0.09016875 2.70805
0 0 0.33638851 2.70805
7 1 0.20354567 2.70805
19 2 0.13510174 2.70805
8 3 0.10188844 2.70805
2 4 0.09016875 2.70805
14 0 0.33638851 2.70805
8 1 0.20354567 2.70805
33 2 0.13510174 2.70805
25 3 0.10188844 2.70805
4 4 0.09016875 2.70805
5 1 0.20354567 2.70805
15 2 0.13510174 2.70805
20 3 0.10188844 2.70805
10 4 0.09016875 2.70805
8 0 0.17597738 2.833213
28 1 0.25832942 2.833213
6 2 0.33638851 2.833213
0 3 0.20354567 2.833213
0 4 0.13510174 2.833213
4 0 0.17597738 2.833213
15 1 0.25832942 2.833213
27 2 0.33638851 2.833213
0 3 0.20354567 2.833213
0 4 0.13510174 2.833213
5 0 0.17597738 2.833213
13 1 0.25832942 2.833213
6 2 0.33638851 2.833213
0 3 0.20354567 2.833213
1 4 0.13510174 2.833213
0 0 0.17597738 2.833213
1 1 0.25832942 2.833213
0 2 0.33638851 2.833213
0 3 0.20354567 2.833213
2 4 0.13510174 2.833213
0 0 0.17597738 2.833213
6 1 0.25832942 2.833213
22 2 0.33638851 2.833213
0 3 0.20354567 2.833213
0 4 0.13510174 2.833213
0 0 0.17597738 2.833213
0 1 0.25832942 2.833213
11 2 0.33638851 2.833213
1 3 0.20354567 2.833213
2 4 0.13510174 2.833213
2 0 0.17597738 2.833213
0 1 0.25832942 2.833213
7 2 0.33638851 2.833213
3 3 0.20354567 2.833213
0 4 0.13510174 2.833213
1 0 0.17597738 2.833213
14 1 0.25832942 2.833213
23 2 0.33638851 2.833213
0 3 0.20354567 2.833213
1 4 0.13510174 2.833213
0 0 0.17597738 2.833213
0 1 0.25832942 2.833213
5 2 0.33638851 2.833213
2 3 0.20354567 2.833213
0 4 0.13510174 2.833213
0 0 0.17597738 2.833213
3 1 0.25832942 2.833213
6 2 0.33638851 2.833213
0 3 0.20354567 2.833213
1 4 0.13510174 2.833213
0 0 0.17597738 2.833213
0 1 0.25832942 2.833213
2 2 0.33638851 2.833213
0 3 0.20354567 2.833213
4 4 0.13510174 2.833213
2 0 0.17597738 2.833213
39 1 0.25832942 2.833213
18 2 0.33638851 2.833213
7 3 0.20354567 2.833213
0 4 0.13510174 2.833213
3 0 0.17597738 2.833213
25 1 0.25832942 2.833213
9 2 0.33638851 2.833213
3 3 0.20354567 2.833213
0 4 0.13510174 2.833213
4 0 0.17597738 2.833213
7 1 0.25832942 2.833213
1 2 0.33638851 2.833213
1 3 0.20354567 2.833213
0 4 0.13510174 2.833213
0 0 0.17597738 2.833213
1 1 0.25832942 2.833213
6 2 0.33638851 2.833213
1 3 0.20354567 2.833213
0 4 0.13510174 2.833213
2 0 0.17597738 2.833213
15 1 0.25832942 2.833213
49 2 0.33638851 2.833213
19 3 0.20354567 2.833213
2 4 0.13510174 2.833213
0 0 0.17597738 2.833213
0 1 0.25832942 2.833213
1 2 0.33638851 2.833213
0 3 0.20354567 2.833213
0 4 0.13510174 2.833213
3 0 0.17485677 2.302585
50 1 0.17597738 2.302585
25 2 0.25832942 2.302585
0 3 0.33638851 2.302585
0 4 0.20354567 2.302585
1 0 0.17485677 2.302585
7 1 0.17597738 2.302585
8 2 0.25832942 2.302585
0 3 0.33638851 2.302585
0 4 0.20354567 2.302585
3 0 0.17485677 2.302585
16 1 0.17597738 2.302585
63 2 0.25832942 2.302585
3 3 0.33638851 2.302585
0 4 0.20354567 2.302585
1 0 0.17485677 2.302585
34 1 0.17597738 2.302585
12 3 0.33638851 2.302585
4 4 0.20354567 2.302585
0 0 0.17485677 2.302585
29 1 0.17597738 2.302585
16 2 0.25832942 2.302585
0 3 0.33638851 2.302585
0 4 0.20354567 2.302585
0 0 0.17485677 2.302585
30 1 0.17597738 2.302585
13 2 0.25832942 2.302585
0 3 0.33638851 2.302585
2 4 0.20354567 2.302585
0 0 0.17485677 2.302585
15 1 0.17597738 2.302585
10 2 0.25832942 2.302585
0 3 0.33638851 2.302585
1 4 0.20354567 2.302585
4 0 0.17485677 2.302585
50 1 0.17597738 2.302585
32 2 0.25832942 2.302585
6 3 0.33638851 2.302585
8 4 0.20354567 2.302585
0 0 0.17485677 2.302585
32 1 0.17597738 2.302585
29 2 0.25832942 2.302585
4 3 0.33638851 2.302585
8 4 0.20354567 2.302585
0 0 0.17485677 2.302585
2 1 0.17597738 2.302585
2 2 0.25832942 2.302585
2 3 0.33638851 2.302585
3 4 0.20354567 2.302585
答案 0 :(得分:1)
用于可视化概率回归模型的拟合优度,&#34;标准&#34;残差(例如,泊松或偏差)通常不那么有用,因为它们主要捕获平均值的建模而不是整个分布的建模。有时使用的一种替代方案是(随机化的)分位数残差。没有随机化,它们被定义为qnorm(pdist(y))
,其中pdist()
是拟合分布函数(这里是ZIP模型),y
是观察值,qnorm()
是分位数函数。标准正态分布。如果模型拟合,残差的分布应该是标准法线,并且可以在Q-Q图中检查。在离散分布的情况下(如此处),需要随机化来打破数据的离散性质。见Dunn&amp; Smyth(1996年,计算和图形统计杂志, 5 ,236-244)了解更多详情。在R中,您可以使用R-Forge的countreg
包(希望很快也会在CRAN上)。
检查数据边际分布的另一种方法是所谓的根图。它在视觉上比较了计数,0,1,......的观察和拟合频率。通常比显示随机分位数残差的Q-Q图更好地显示过量零和/或过度离散的问题。请参阅我们的论文Kleiber&amp; Zeileis(2016年,美国统计学家, 70 (3),296-303,doi:10.1080/00031305.2016.1173590)了解更多详情。
将这些应用于您的回归模型可以快速显示零膨胀的 Poisson 并不能解释响应中的过度离散。 (计数高达100以上,基于泊松的分布几乎从不适合。)此外,零通胀模型不太适合,因为assnage
= 1和= 2那里是非常少的零,不需要零通货膨胀。这导致零膨胀部分中的相应系数朝向具有非常大的标准误差的-Inf
(如在二元回归中的准分离中)。因此,两部分障碍模型适合更好,并且可能更容易解释。最后,由于两个assnage
组不同,我会将assnage
编码为一个因素(我不清楚你是否已经这样做了。)
因此,为了分析您的数据,我使用帖子中提供的yc
并确保:
yc$assnage <- factor(yc$assnage)
第一次探索assnage
的影响我会在对数刻度上绘制count
是否为正(左:零障碍)和正count
。对:数)。
plot(factor(count > 0, levels = c(FALSE, TRUE), labels = c("=0", ">0")) ~ assnage,
data = yc, ylab = "count", main = "Zero hurdle")
plot(count ~ assnage, data = yc, subset = count > 0,
log = "y", main = "Count (positive)")
然后,我使用R-Forge的countreg
包来适应ZIP,ZINB和障碍NB模型。这还包含zeroinfl()
和hurdle()
函数的更新版本。
install.packages("countreg", repos = "http://R-Forge.R-project.org")
library("countreg")
zip <- zeroinfl(count ~ assnage * spawncob, offset = logoffset,
data = yc, dist = "poisson")
zinb <- zeroinfl(count ~ assnage * spawncob, offset = logoffset,
data = yc, dist = "negbin")
hnb <- hurdle(count ~ assnage * spawncob, offset = logoffset, data = yc,
dist = "negbin")
ZIP明显不合适,障碍NB略胜ZINB。
BIC(zip, zinb, hnb)
## df BIC
## zip 20 7700.085
## zinb 21 3574.720
## hnb 21 3556.693
如果检查summary(zinb)
,您还会看到零膨胀部分中的某些系数大约为10(对于虚拟变量),标准误差大一到两个数量级。这实质上意味着相应组中的零通胀概率变为零,因为负二项分布已经具有足够的零响应概率权重(assnage
组1和2)。
为了在HNB正确捕获响应时可视化ZIP模型不适合,我们现在可以使用根图。
rootogram(zip, main = "ZIP", ylim = c(-5, 15), max = 50)
rootogram(hnb, main = "HNB", ylim = c(-5, 15), max = 50)
ZIP的波浪状图案清楚地显示了模型未正确捕获的数据中的过度离散。相比之下,障碍相当合适。
作为最终检查,我们还可以查看障碍模型中分位数残差的Q-Q图。这些看起来相当正常,并且没有显示模型的可疑偏离。
qqrplot(hnb, main = "HNB")
由于残差是随机的,您可以重新运行代码几次以获得变化的印象。 qqrplot()
还有一些论据让您可以在单个图中探索这种变化。