# Zero-inflated model predicting only a small range of values. I need help

I built a ZI model and it is producing predicted values that are from a very small range when compared to the observed values. Plus it does not produce any zeros. See the fitted vs. observed graph below.

http://tinypic.com/r/16bbrxs/9

My model structure is given below. My response is a count variable and the predictor is continuous water level measurements (scaled).

m.u.meanwl.gu <- zeroinfl(GU ~ MeanWLScaled | MeanWLScaled, data = uluabat_wl_fg, dist = "negbin", link = "logit")


I need help to figure out what's wrong and fix it. Thanks in advance.

If you call predict.zeroinfl() without any parameters, it uses the default setting for the type parameter, which is type="response". You will then get a prediction for the mean, or the expected response. This expectation will typically vary much less than your actual observations, will not be integer, and will be larger than zero.

To obtain a probabilistic prediction of the probabilities to observe specific actual count observations, use type="prob". An example:

> library(pscl)
> fm_zip <- zeroinfl(art ~ ., data = bioChemists)
1        2        3        4        5        6
2.037956 1.323124 1.308704 1.439982 2.363233 0.854771
0         1         2          3          4           5           6
1 0.2162690 0.1937560 0.2279639 0.17880748 0.10518810 0.049503684 0.019414543
2 0.3626973 0.2429423 0.2058847 0.11631983 0.04928840 0.016708046 0.004719819
3 0.3655549 0.2445794 0.2051107 0.11467420 0.04808441 0.016129943 0.004508999
4 0.3582308 0.2127514 0.2034182 0.12966290 0.06198734 0.023707199 0.007555727
5 0.1071273 0.2125181 0.2559524 0.20550920 0.12375553 0.059619449 0.023934814
6 0.5218005 0.2328010 0.1513963 0.06563783 0.02134296 0.005551943 0.001203522
7            8            9           10           11           12
1 0.006526345 0.0019196452 5.019025e-04 1.181028e-04 2.526437e-05 4.954139e-06
2 0.001142821 0.0002421248 4.559820e-05 7.728561e-06 1.190849e-06 1.682002e-07
3 0.001080390 0.0002265110 4.221291e-05 7.080172e-06 1.079567e-06 1.508923e-07
4 0.002064075 0.0004933813 1.048304e-04 2.004632e-05 3.484891e-06 5.553353e-07
5 0.008236171 0.0024798688 6.637118e-04 1.598722e-04 3.500850e-05 7.027254e-06
6 0.000223623 0.0000363569 5.254177e-06 6.833844e-07 8.080398e-08 8.758139e-09
13           14           15           16           17           18
1 8.967384e-07 1.507227e-07 2.364440e-08 3.477356e-09 4.813281e-10 6.292303e-11
2 2.192977e-08 2.654955e-09 2.999969e-10 3.177955e-11 3.168471e-12 2.983515e-13
3 1.946804e-08 2.332345e-09 2.607955e-10 2.733875e-11 2.697294e-12 2.513358e-13
4 8.168817e-08 1.115779e-08 1.422441e-09 1.700050e-10 1.912317e-11 2.031584e-12
5 1.302074e-06 2.240273e-07 3.597518e-08 5.415971e-09 7.673982e-10 1.026932e-10
6 8.762517e-10 8.140690e-11 7.058791e-12 5.738134e-13 4.390178e-14 3.172269e-15
19
1 7.792861e-12
2 2.661494e-14
3 2.218703e-14
4 2.044694e-13
5 1.301911e-11
6 2.171585e-16
>


Look at ?predict.zeroinfl for more information.

• Thank you for your reply, Sir. I understood what you said. However, this function is no longer available in the most recent form of "pscl"package. So I simply used the generic predict() function with type ="prob" command. It gave me a huge object with tons of numbers in it. It basically has probabilities for each possible value I guess. All I want to do is to use a basic predicted vs observed graph to see how well my model is performing and I still can't do it. Is there a way to get this plot by the method you said for either zeroinfl or glmmTMB objects. – KO 88 Apr 21 at 16:19
• predict.zeroinfl() is available in pscl 1.5.2, see p. 60 in the reference manual. ... – Stephan Kolassa Apr 21 at 18:36
• ... About getting a predicted vs. observed graph: there are different ways of predicting. What you had originally was a plot of predicted expectations. Which does not give an indication of variability. You could extract predicted probabilities, then calculate lower and upper quantiles and plot those. Then you could check whether, e.g., 80% of observations are between the 10% and the 90% quantile prediction. – Stephan Kolassa Apr 21 at 18:39