0
$\begingroup$

I am working with count data where I have an abundance of zeros for one of my categorical factors (Day). I have generated two models, p1 and m1, with zeroinfl() and glm() respectively. According to the pscl package, I can use vuong() to compare the fit of these models. This comparison fails with the error:

NA or numerical zeros or ones encountered in fitted probabilities dropping these 69 cases, but proceed with caution Error in if (v[j] > 0) { : missing value where TRUE/FALSE needed In addition: Warning message: In matrix(c(0, aic.factor, bic.factor), nrow = neff, ncol = 3, byrow = TRUE) : data length exceeds size of matrix

I am not sure how to address this error. It may be a factor of the data itself/misuse of zeroinfl()? Below you will find example data and the models. The summary output of each individual model is as follows.

> summary(p1)



Pearson residuals:
    Min      1Q  Median      3Q     Max 
-4.1235 -1.3127 -0.7073  1.2650 13.3738 

Count model coefficients (poisson with log link):
                         Estimate Std. Error  z value Pr(>|z|)    
(Intercept)             11.974985   0.001449 8263.627   <2e-16 ***
Day2                   1.841290   0.001498 1229.524   <2e-16 ***
GroupE                 -0.058573   0.002080  -28.160   <2e-16 ***
GroupL                 -0.022356   0.002307   -9.692   <2e-16 ***
Day2:GroupE             0.033049   0.002131   15.506   <2e-16 ***
Day2:GroupL            -0.510861   0.002359 -216.575   <2e-16 ***

Zero-inflation model coefficients (binomial with log link):
                        Estimate Std. Error z value Pr(>|z|)  
(Intercept)              -0.6933     0.4083  -1.698   0.0895 .
Day2                     -0.8112     0.7455  -1.088   0.2766  
GroupE                    0.2876     0.4715   0.610   0.5419  
GroupL                    0.5110     0.4282   1.193   0.2328  
Day2:GroupE              -1.4917     1.2431  -1.200   0.2301  
Day2:GroupL              -1.8972     1.2317  -1.540   0.1235  
--- 
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 

Number of iterations in BFGS optimization: 14 
Log-likelihood: -1.208e+07 on 12 Df

    > summary(m1)


    Deviance Residuals: 
        Min       1Q   Median       3Q      Max  
    -1349.5   -531.6   -227.5    311.6   2480.8  

    Coefficients:
                             Estimate Std. Error z value Pr(>|z|)    
    (Intercept)             11.281836   0.001449  7785.3   <2e-16 ***
    Day2                     2.283125   0.001498  1524.6   <2e-16 ***
    GroupE                  -0.464042   0.002080  -223.1   <2e-16 ***
    GroupL                  -1.120968   0.002307  -486.0   <2e-16 ***
    Day2:GroupE              0.620839   0.002131   291.3   <2e-16 ***
    Day2:GroupL              0.781906   0.002359   331.5   <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: 57480533  on 68  degrees of freedom
    Residual deviance: 33466708  on 63  degrees of freedom
    AIC: 33467398

    Number of Fisher Scoring iterations: 7
p1=zeroinfl(Count ~ Day*Group, link = "log", dist="poisson", data = df) 
m1=glm(formula = Count ~ Day*Group, family = poisson(link="log", data = df)
vuong(p1,m1)


Day Group   Count
2   E   343874
2   E   1218298
2   E   1368672
2   E   354983
2   E   237219
2   E   635455
2   E   382917
2   E   596436
2   E   1759721
2   C   271107
2   C   406661
2   C   2277301
2   C   0
2   C   232378
2   C   3197440
2   C   0
2   C   388092
2   C   232378
2   L   813322
2   L   1138650
2   L   881098
2   L   46936
2   L   921765
2   L   433772
2   L   1358359
2   L   894074
2   L   990795
2   L   38730
2   L   0
2   L   542214
2   L   77459
2   L   154918
2   L   209319
2   L   162664
2   L   271107
2   L   1046595
2   E   1026504
2   E   203330
2   E   4164301
2   E   715259
2   E   0
2   E   650657
1   E   0
1   E   165952
1   E   162664
1   E   0
1   E   0
1   E   0
1   C   0
1   C   171206
1   C   271107
1   C   0
1   C   33888
1   C   0
1   L   0
1   L   0
1   L   0
1   L   90369
1   L   0
1   L   220080
1   L   0
1   L   0
1   L   0
1   L   0
1   L   0
1   L   0
1   E   120492
1   E   0
1   E   0
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.