I am running a hierarchical Bayesian model and would like to use the "ones trick" to self-define a likelihood function, just to prevent the problems that dmulti() may have with zeros. To be able to use the "ones trick", I would first need to specify the pmf for multinomial distribution.
In this post, Martyn Plummer mentioned that we can actually get the likelihood of the Gamma distribution by using dgamma() directly, e.g.:
logGamma[i] <- log(dgamma(y[i], shape[i], rate[i]))
Based on above, I assumed it applies to other distribution functions too and wrote below code:
where both y.comp[i,2:5,k] and y.comp[i,6,k] are both observations, and comp.p[i,1:4,k] is the expected population composition obtained from the process model.
However, when I run this, I obtained an error message like this:
Error in jags.model("test.R", data = data, inits = inits, n.chains = length(inits), : RUNTIME ERROR: Compilation error on line 186. Unknown function: dmulti
And my questions are:
- I wonder has anyone met the same error? As the dmulti() should be the right function to use for multinomial distribution, I wonder does this mean I cannot obtain likelihood of multinomial distribution from dmulti() directly?
- If I cannot obtain likelihood directly with dmulti(), I wonder is there any function that can help me put down the pmf of multinomial distribution in JAGS, as the pmf is quite a complicated one?