r - Runtime error in JAGS -


i'm attempting in jags:

z[l] ~ dbeta(0.5,0.5) y[i,l] ~ z[l]*dnorm(0,10000) + inprod(1-z[l],dnegbin(exp(eta_star[i,l]),alpha[l])) 

(dnorm(0,10000) models dirac delta in 0: see here if interested in model).

but get:

     runtime error:      incorrect number of arguments in function dnegbin 

but if this:

y[i,l] ~ dnegbin(exp(eta_star[i,l]),alpha[l]) 

it runs fine. wonder cannot multiply value distribution, imagine work:

z[l] ~ dbeta(0.5,0.5) pointmass_0[l] ~ dnorm(0,10000) y[i,l] ~ dnegbin(exp(eta_star[i,l]),alpha[l]) y_star[i,l] = z[l]*pointmass_0[l]+inprod(1-z[l],y[i,l]) 

if run get:

ystar[1,1] logical node , cannot observed 

you looking model zero-inflated negative binomial model. can in jags if use "ones trick", pseudo-likelihood method can used when distribution of outcome variables not 1 of standard distributions in jags can still write down expression likelihood.

the "ones trick" consists of creating pseudo-observations value 1. these modeled bernoulli random variables probability parameter lik/c lik likelihood of observations , c large constant ensure lik/c << 1.

data {    c <- 10000    (i in 1:n) {       one[i,1] <- 1    } } model {     (i in 1:n) {       one[i,1] ~ dbern(lik[i,1]/c)        lik[i,1] <- (y[i,1]==0)*z[1] + (1 - z[1]) * lik.nb[i,1]          lik.nb[i,1] <- dnegbin(y[i,1], exp(eta_star[i,1]), alpha[1])    }     z[l] ~ dbeta(0.5,0.5) } 

note name dnegbin overloaded in jags. there distribution has 2 parameters , function takes 3 arguments , returns likelihood. using latter.

i thinking of adding zero-inflated versions of count distributions jags, since above construction quote awkward user, whereas zero-inflated distributions quite easy implement internally in jags.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -