As a case in point, lately I've been writing BUGS/JAGS models, and I
came across this inconsistency.
If you have a univariate normal parameter, you can write:
alpha ~ dnorm(0, 0.001)
If you have a multivariate normal parameter, you have to write:
alpha ~ dmnorm(mu[], tau[,])
and then you have to define mu[] and tau[,] in the data that you pass to
BUGS. It'd be more convenient and consistent to define mu[] and tau[,]
directly in the model file, not in the data.
As Ben says, you can define constants in the
"transformed data" section of the model file,
which is for any variables that can be defined
solely in terms of the variables in the "data" block
or earlier in the "transformed data" block.
Also, you won't need the brackets. It'll look
like:
transformed data {
covar_matrix(2) Sigma;
vector(2) mu;
Sigma[1,1] <- 1.7;
Sigma[2,2] <- 1.3;
Sigma[1,2] <- 0.4;
Sigma[2,1] <- Sigma[1,2];
mu[1] <- 3.7;
mu[2] <- -14.2;
}
model {
y ~ multi_normal(mu,Sigma);
...
}
I keep thinking I should add a literal assignment syntax for
matrices, to allow something like:
Sigma <- ((1,7. 0.4),
(0.4, 1.3));
mu <- (3.7, -14.2);
or even a general expression that would allow variables
or other expressions as well as constants.
It's on the to-do list, but I'm in the middle
of trying to refactor the parser to break it into
multiple translation units to ease the burden on
the C++ compilers and assemblers.
We'll also be adding other parameterizations and vectorized
versions for multiple samples.
We will try very very hard to keep the model syntax
backwards compatible.
You can look in the directory of BUGS examples for more
examples of Stan's syntax.
- Bob