如何在JAGS中设置零膨胀泊松?


12

我正在尝试在R和JAGS中建立零膨胀泊松模型。我是JAGS的新手,我需要一些有关该操作的指南。

我一直在尝试以下方法,其中y [i]是观察到的变量

model {
for (i in 1:I) {

    y.null[i] <- 0
    y.pois[i] ~ dpois(mu[i])
    pro[i] <- ilogit(theta[i])
    x[i] ~ dbern(pro[i])

    y[i] <- step(2*x[i]-1)*y.pois[i] + (1-step(2*x[i]-1))*y.null[i]

    log(mu[i]) <- bla + bla +bla + ....
    theta[i] <- bla + bla + bla + ....
}

}

但是,这不起作用,因为您不能在观察到的变量上使用<-。

任何想法如何更改/解决此问题?还有其他方法可以在JAGS中建立零膨胀泊松模型吗?


这可能会有所帮助:分类数据的贝叶斯模型作者
P。Congdon

Answers:


3

这是一个简单的解决方案,它使用的一个事实是,当lambda参数为零时,泊松将为您提供零。但是请注意,如果lambda恰好为零,则JAGS倾向于断开,因此为“ + 0.00001”。

model {
  for (i in 1:I) {

    y[i] ~ dpois(mu1[i])

    mu1[i] <- mu[i]*x[i] + 0.00001

    x[i] ~ dbern(pro[i])
    logit(pro[i]) <- theta[i]

    mu[i] <- bla + bla +bla + ....
    theta[i] <- bla + bla + bla + ....
  }

4
C <- 10000 #Constant 1/0 trick

# Likelihood:
for ( i in 1:ny ) {

#Likelihood of the count model component
LikCountModel[i] <- pow(mu[i],y[i])/y_fact[i]*exp(-mu[i])

#Count model component
eta[i] <- bet0 + inprod( beta[] , B[i,] )
mu[i] <- exp(eta[i])

#ZI Component
zeta[i] <- gamm0 + inprod( gamma[] , G[i,] )
w[i] <- exp(zeta[i])/(1+exp(zeta[i]))

#1/0 Tricks: ones is a column containing only ones, with the same size of y
  p[i] <- L[i] / C
  ones[i] ~ dbern(p[i])

#Full likelihood expression
L[i] <- LikCountModel[i] * (1-w[i]) + equals(y[i],0)*w[i]
}

#then set your priors for all beta and gamma
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.