Download JAGS Version 3.0.0 user manual
Transcript
‘Y‘ <c(1, 3, 3, 3, 5)
‘N‘ <5
It is an error to supply a data value for a deterministic node. (See, however, section 7.0.3
on observable functions).
2.1.3
Node Array dimensions
Array declarations
JAGS allows the option of declaring the dimensions of node arrays in the model file. The
declarations consist of the keyword var (for variable) followed by a comma-separated list of
array names, with their dimensions in square brackets. The dimensions may be given in terms
of any expression of the data that returns a single integer value.
In the linear regression example, the model block could be preceded by
var x[N], Y[N], mu[N], alpha, beta, tau, sigma, x.bar;
Undeclared nodes
If a node array is not declared then JAGS has three methods of determining its size.
1. Using the data. The dimension of an undeclared node array may be inferred if it is
supplied in the data file.
2. Using the left hand side of the relations. The maximal index values on the left
hand side of a relation are taken to be the dimensions of the node array. For example,
in this case:
for (i in 1:N) {
for (j in 1:M) {
Y[i,j] ~ dnorm(mu[i,j], tau)
}
}
Y would be inferred to be an N × M matrix. This method cannot be used when there
are empty indices (e.g. Y[i,]) on the left hand side of the relation.
3. Using the dimensions of the parents If a whole node array appears on the left hand
side of a relation, then its dimensions can be inferred from the dimensions of the nodes
on the right hand side. For example, if A is known to be an N × N matrix and
B <- inverse(A)
Then B is also an N × N matrix.
6