Zero-inflated models

1,992 views
Skip to first unread message

Laura Serra Saurina

unread,
Mar 21, 2012, 6:08:35 AM3/21/12
to r-inla-disc...@googlegroups.com
Hi,

I would like to know the difference between the two types of zero-inflated models (type 0 and type 1). Looking at the formula I noticed that type 0 only includes positives values and type 1 includes all kind of values. Is there any other difference?

Type 0: Prob(y|...) = p x 1[y=0] + (1 - p) x Poisson(y | y > 0)

 

Type 1: Prob(y|...) = p x 1[y=0] + (1 - p) x Poisson(y)


Moreover, could you give me the Type2's formula? I haven't found it.

Thank you very much.

Laura.




Finn Lindgren

unread,
Mar 21, 2012, 7:22:03 AM3/21/12
to r-inla-disc...@googlegroups.com

On Wednesday, 21 March 2012 11:08:35 UTC+1, Laura Serra Saurina wrote:
I would like to know the difference between the two types of zero-inflated models (type 0 and type 1). Looking at the formula I noticed that type 0 only includes positives values and type 1 includes all kind of values. Is there any other difference?

Type 0: Prob(y|...) = p x 1[y=0] + (1 - p) x Poisson(y | y > 0)

Type 1: Prob(y|...) = p x 1[y=0] + (1 - p) x Poisson(y)

Type 1 is a mixture of a point mass at 0 and a regular Poisson distribution, whereas Type 0 is a mixture of a truncated Poisson (the y>0 bit) and a point mass at 0, so that the probability at zero is governed directly by p.

This means e.g. that Type 0 can have a _lower_ probability at 0 than a pure Poisson, relative to the probability at 1, whereas Type 1 can only increase the relative probability for 0.
 

Moreover, could you give me the Type2's formula? I haven't found it.

The description of Type 2 is at the end of page 6 of
http://www.math.ntnu.no/~hrue/r-inla.org/doc/likelihood/zeroinflated.pdf
It's like Type 1 but with a different definition of p.

/Finn

Victor

unread,
May 2, 2012, 11:30:19 AM5/2/12
to r-inla-disc...@googlegroups.com
 I am new to INLA and i was trying to fit a zero inflated poisson model (0) but i required the model to include a spatial component for example CAR model

i seem to be fitting the model well without fail when i do not include the spatial component, but perhaps am missing some part of model specification or parameters

my data distribution has a classical zero-inflated like histogram with very few large values

my question is 1) is a specification of spatial component the right thing to do e.g using besag 2) how best do i initiate the parameters when i call INLA

Daniel Simpson

unread,
May 2, 2012, 11:31:34 AM5/2/12
to Victor, r-inla-disc...@googlegroups.com
Hi Victor,
Could you send some example code that doesn't work?

Thanks,

Dan

Victor

unread,
May 2, 2012, 11:49:30 AM5/2/12
to r-inla-disc...@googlegroups.com, Victor
am still trying to figure out how best to include a sample data set, but basically (y) comprise of values with range from zero (0) (highest frequency) to 800 (just one value)  

    hist(y, breaks = 400)
    f.mod1 <- y ~ cov1 +  f(ID, model="besag", graph.file = "dist.adj")  # where cov1 is a linear covariate
    mod1 <- inla(f.mod1, family = "zeroinflatedpoisson0", data = mydata, E=pop, control.compute=list(dic=TRUE,cpo=TRUE))

basically the PIT values fail in above

Thanks


Daniel Simpson

unread,
May 2, 2012, 2:14:57 PM5/2/12
to Victor, r-inla-disc...@googlegroups.com
Hi Victor,
Without being able to try it on your dataset, it's hard to know
exactly what happened.

I ran the following code, where the graph and data were taken from the
bym example.

library(INLA)

#taken from BYM example. Read data and graph and organise dataframe
data(Germany)
g = system.file("demodata/germany.graph", package="INLA")
source(system.file("demodata/Bym-map.R", package="INLA"))
Germany = cbind(Germany,region.struct=Germany$region)

#this is similar to your formula
formula1 = Y ~ f(region.struct,model="besag",graph.file=g) +x

#this is similar to your inla call
result = inla(formula1, family="zeroinflatedpoisson0",data=Germany,
E=E, control.compute = list(dic=TRUE, cpo=TRUE))

summary(result)

I get sensible results, but the following warning message is produced:
"Warning message:
In INLA::f(region.struct, model = "besag", graph.file = g) :
Argument 'graph.file' in 'f()' is obsolete; please use the more
general argument 'graph' instead."

You can get rid of this by changing the formula to
formula1 = Y ~ f(region.struct,model="besag",graph=g) +x


So, can you please send me the exact error message that you got when
you tried to run the problem. There are also some things that you can
check:
-- Is INLA updated? Use inla.update(testing=TRUE)
-- Is your graph file valid? Use inla.debug.graph()
-- Is the data frame in order?

Best wishes,

Dan
Message has been deleted

Belay Birlie

unread,
Aug 12, 2016, 4:11:19 AM8/12/16
to R-inla discussion group
Dear All 

I am trying to fit a zero inflated model in INLA using  Prob(y|...) = p x 1[y=0] + (1 - p) x Poisson(y | y > 0). Is there a possibility to model p as a function of covariates. In JAGS I can specify this in this way. 

model {
    
    for( j in 1 : N ) 
{
    y[j] ~dpois(mu[j])
    mu[j] <- (1 - u[j])*lambda[j]
    u[j]~dbern(p[j])
    logit(p[j]) <- a[1]+ a[2]*time[j]+a[3]*Trt[j]+a[4]*Season[j]+b1[id2[j]]
    
    log(lambda[j]) <-beta[1]+ beta[2]*time[j]+beta[3]*Trt[j]+ beta[4]*Season[j]+beta[5]*Trt[j]*time[j]+b2[id2[j]]

}

Thus, I am looking for help to do the same thing in INLA
Belay 

Håvard Rue

unread,
Aug 12, 2016, 4:13:39 AM8/12/16
to Belay Birlie, R-inla discussion group
On Fri, 2016-08-12 at 01:11 -0700, Belay Birlie wrote:
> Dear All 
>
> I am trying to fit a zero inflated model in INLA using  Prob(y|...) =
> p x 1[y=0] + (1 - p) x Poisson(y | y > 0). Is there a possibility to
> model p as a function of covariates. 


yes. since the poisson part is y|y>0, you can. see
inla.doc("zeroinflated") and the spde-tutorial for a worked out example
for zero-inflated rain data, which is the same as yours. you have to
use two likelihoods, one for the 'p' and one for the 'y'. 
--
Håvard Rue
Department of Mathematical Sciences
Norwegian University of Science and Technology
N-7491 Trondheim, Norway
Voice: +47-7359-3533 URL : http://www.math.ntnu.no/~hrue
Mobile: +47-9260-0021 Email: havar...@math.ntnu.no

R-INLA: www.r-inla.org
Reply all
Reply to author
Forward
0 new messages