I am running a zero-inflated model for CPUE data. This data has evidence of zero-inflation which I have confirmed with a Vuong test (in code below). The full model (zint) is better than the null according to AIC. I now want to:
- Examine the residuals of the full model to determine model fit (having trouble due to lack of info from colleagues, internet, and R books)
- If model fit appears to be okay, visualize the output of the model (how to formulate equations of real-parameter values when using an offset variable)
I have asked help from a few statisticians in the department (they have never done this before and send me to the same google search sites), outside to the stats department itself (everyone is too busy), and stackoverflow feeds.
I would appreciate code or guidance to books (available free online) with code that deal with visualizing ZIPs and model fit when using an offset variable.
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 is column #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