4
votes
$\begingroup$

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.

$\endgroup$

2 Answers 2

2
votes
$\begingroup$

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

$\endgroup$
7
  • $\begingroup$ 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? $\endgroup$
    – utdiscant
    Commented Feb 3, 2013 at 22:55
  • $\begingroup$ You could pass the vector pi from R or define it in the model file; it contains the probabilities that sum to one. $\endgroup$
    – user12719
    Commented Feb 4, 2013 at 0:15
  • $\begingroup$ Usually the probabilities are derived from another distribution. See e.g. mixture models $\endgroup$
    – user12719
    Commented Feb 4, 2013 at 0:38
  • 1
    $\begingroup$ 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, ...). $\endgroup$
    – user12719
    Commented Feb 5, 2013 at 18:57
  • 1
    $\begingroup$ 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) $\endgroup$
    – Scransom
    Commented Sep 3, 2015 at 5:51
0
votes
$\begingroup$

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)).

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.