The BUGS language: stochastic nodes [ top | home ]
In the text-based model description, stochastic nodes are represented by the node name followed by a twiddles
symbol followed by the distribution name followed by a comma-separated list of parents enclosed in brackets
e.g.
r ~ dbin(p, n)
The distributions that can be used in WinBUGS are described in Distributions. Clicking on the name of each
distribution should provide a link to an example of its use provided with this release. The parameters of a
distribution must be explicit nodes in the graph (scalar parameters can also be numerical constants) and so
may not be function expressions.
For distributions not featured in Distributions, see Tricks: Advanced Use of the BUGS Language.
Censoring and truncation [ top | home ]
Censoring is denoted using the notation I(lower, upper) e.g.
x ~ ddist(theta)I(lower, upper)
denote a quantity x from distribution ddist with parameters theta, which had been observed to lie
between lower and upper. Leaving either lower or upper blank corresponds to no limit, e.g.
I(lower,) corresponds to an observation known to lie above lower. Whenever censoring is specified the
censored node contributes a term to the full conditional distribution of its parents. This structure is only of use if
x has not been observed (if x is observed then the constraints will be ignored).
It is vital to note that this construct does NOT correspond to a truncated distribution, which generates a
likelihood that is a complex function of the basic parameters. Truncated distributions might be handled by
out an algebraic form for the likelihood and using the techniques for arbitrary distributions described in
Tricks: Advanced Use of the BUGS Language.
It is also important to note that if x, theta, lower and upper are all unobserved, then lower and
upper must not be functions of theta.
Constraints on using certain distributions [ top | home ]
Contiguous elements: Multivariate nodes must form contiguous elements in an array. Since the final element
in an array changes fastest, such nodes must be defined as the final part of any array. For example, to define a
set of K * K Wishart variables as a single multidimensional array x[i,j,k], we could write:
for (i in 1:I) {
x[i, 1:K, 1:K] ~ dwish(R[i,,], 3)
}
R[i,,] is an array of specified prior parameters.
No missing data: Data defined as multinomial or as multivariate Student-t must be complete, in that missing
values are not allowed in the data array. We realise this is an unfortunate restriction and we hope to relax it in
the future. For multinomial data, it may be possible to get round this problem by re-expressing the multivariate
likelihood as a sequence of conditional univariate binomial distributions.
Note that multivariate normal data may now be specified with missing values.
Conjugate updating: Dirichlet and Wishart distributions can only be used as parents of multinomial and
multivariate normal nodes respectively.
Parameters you can't learn about and must specify as constants: The parameters of Dirichlet and Wishart
distributions and the order (N) of the multinomial distribution must be specified and cannot be given prior
distributions. (There is, however, a trick to avoid this constraint for the Dirichlet distribution − see
here.)
Structured precision matrices for multivariate normals: these can be used in certain circumstances. If a