Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Zero-Inflation NB - object 'model_count' not found

I am modeling a mediated zero-inflated negative binomial (ZINB) model. i am following the steps of O'Rourke & Vazquez (2019) --> https://www.sciencedirect.com/science/article/abs/pii/S0306460319301078

A few days ago i was running a different ZINB model which ran perfectly fine. However, today i wrote a different model, same variables, but somehow it doesn't run anymore and gives a strange error. When i try my previous model i suddenly get the same error, namely:

Error in zeroinfl(Y1 ~ X1 + M1 | X1 +  : object 'model_count' not found

The rest of my code:

#loading required packages
library(psych)
library(foreign)
library(ggplot2)
library(MASS)
library(pscl)
library(nonnest2)
library(lmtest)
library(boot)

#Import data
mydata

#Fit a ZINB model
ex1zinb <- zeroinfl(X1 ~ Y1 + M1 | Y1 + M1, data = mydata, dist="negbin", EM= TRUE)

I already checked the assumption for the statistical analyses etc., and it is especially strange that a similar model did run a few days ago and not anymore. I did try to install several packages today but i ran into a non-zero exit status. Following some comments on stackoverflow i installed a package by adding dependencies = TRUE, but it ran stuck. Afterwards the problems started. Maybe there is something wrong with my packages?

When loading the libraries i get the following messages:

> library(psych)
> library(foreign)
> library(ggplot2)
Need help? Try Stackoverflow: https://stackoverflow.com/tags/ggplot2

Attaching package: ‘ggplot2’

The following objects are masked from ‘package:psych’:

    %+%, alpha

> library(MASS)
> library(pscl)
Classes and Methods for R developed in the
Political Science Computational Laboratory
Department of Political Science
Stanford University
Simon Jackman
hurdle and zeroinfl functions by Achim Zeileis
> library(nonnest2)
This is nonnest2 0.5-3.
nonnest2 has not been tested with all combinations of model classes.
> library(lmtest)
Loading required package: zoo

Attaching package: ‘zoo’

The following objects are masked from ‘package:base’:

    as.Date, as.Date.numeric

> library(boot)

Attaching package: ‘boot’

The following object is masked from ‘package:psych’:

    logit

Anyone some suggestions/insights? Thanks in advance!

Edit: i do get a normal output when running a non-zero inflated negative binomial model. The following code runs smooth:

summary(ex1nb <- glm.nb(Y1~ X1 + M1, data = mydata))

So i think my data is fine?

like image 762
Principia Avatar asked Apr 22 '20 10:04

Principia


People also ask

When to use zero inflation?

Details. If the amount of observed zeros is larger than the amount of predicted zeros, the model is underfitting zeros, which indicates a zero-inflation in the data. In such cases, it is recommended to use negative binomial or zero-inflated models.

Do we really need zero-inflated models?

There is no need to use a zero-inflated Poisson model. You may use the negative binomial regression model since it allows for overdispersion. Now the only question remains whether to use a zero-inflated negative binomial model, which is a special case of the negative binomial model.


Video Answer


1 Answers

I got that error too. I used R 4.0 then tried R 3.6. No luck.

I was able to get the error to go away when I removed the EM = TRUE parameter.

I'm not sure if this helps.

like image 178
Micajah Avatar answered Oct 12 '22 08:10

Micajah