Categorical distribution in JAGS

How do I specify for a variable to be uniformly sampled from the discrete values $1,2,\ldots,10$ in JAGS? I guess I want to use the dcat() distribution, but I have yet to find good documentation of the parameters for this.

Have a look at the JAGS user manual. dcat(pi) is defined with a density of $\pi_x/\sum_i{\pi_i}$.

• So I want to pass a list of probabilities to dcat(). Can this list be specified in the JAGS model or do I have to pass it from R? Feb 3 '13 at 22:55
• You could pass the vector pi from R or define it in the model file; it contains the probabilities that sum to one. Feb 4 '13 at 0:15
• Usually the probabilities are derived from another distribution. See e.g. mixture models Feb 4 '13 at 0:38
• I assume you want to use dcat as a prior. In your model specify e.g.: mu ~ dcat(pi). Then specify pi <- c(0.2,0.5,0.3) and include it in the jags.model data list: data=list(pi=pi, ...). Feb 5 '13 at 18:57
• dcat(pi) as @user12719 is correct to use, but important to note that unlike BUGS language and other specifications of categorical distributions, JAGS is not expecting pi to sum to 1 and normalizes it internally. This can effect the way each pi[i] is estimated. (answering instead of commenting as not enough rep to comment here) Sep 3 '15 at 5:51

Kruschke's in his book Doing Bayesian Data Analysis 2ed on page 278 has following code

    model{
...
...
m ~ dcat( mPriorProb[] )
mPriorProb[1] <- .5
mPriorProb[2] <- .5
}


To quote from the book:

The argument of the dcat distribution is a vector of probabilities for each category. JAGS does not allow the vector constants to be defined inside the argument, like this: m ~ dcat(c(.5,.5)).