Dear Community,
I am trying to run the example model for a multivariate (hierarchical) regression on page 95 of the Reference Manual for Stan version 2.2.0 but I am running into a compiling error.
This is the error message returned when calling stan():
TRANSLATING MODEL 'fullmodel' FROM Stan CODE TO C++ CODE NOW.
Error in stanc(file = file, model_code = model_code, model_name = model_name, :
failed to parse Stan model 'fullmodel' with error message:
EXPECTATION FAILURE LOCATION: file=input; line=27, column=57
beta[j] ~ multi_normal((u[j] * gamma)’, Sigma_beta);
^-- here
DIAGNOSTIC(S) FROM PARSER:
no matches for function name="multi_normal_log"
arg 0 type=vector
arg 1 type=row vector
arg 2 type=matrix
available function signatures for multi_normal_log:
0. multi_normal_log(vector, vector, matrix) : real
unknown distribution=multi_normal
Parser expecting: <eps>
I have actually slightly modified the code to fit a logistic rather than a linear model but I doubt this is the problem. Here is the modified code (note commented out lines):
fullmodel<- '
data {
int<lower=0> N; // num individuals
int<lower=1> K; // num ind predictors
int<lower=1> J; // num groups
int<lower=1> L; // num group predictors
int<lower=1,upper=J> jj[N]; // group for individual
matrix[N,K] x; // individual predictors
matrix[J,L] u; // group predictors
vector[N] y; // outcomes
}
parameters {
corr_matrix[K] Omega; // prior covariance
vector<lower=0>[K] tau; // prior scale
matrix[L,K] gamma; // group coeffs
vector[K] beta[J]; // indiv coeffs by group
#real<lower=0> sigma; // prediction error scale of the original linear model (commented out)
}
model {
matrix[K,K] Sigma_beta;
Sigma_beta <- diag_matrix(tau) * Omega * diag_matrix(tau);
tau ~ cauchy(0,2.5);
Omega ~ lkj_corr(2);
for (l in 1:L)
gamma[l] ~ normal(0,5);
for (j in 1:J)
beta[j] ~ multi_normal((u[j] * gamma)’, Sigma_beta);
for (n in 1:N)
#y[n] ~ normal(x[n] * beta[jj[n]], sigma); // original linear predictor commented out
y[n] ~ bernoulli(inv_logit(x[n] * beta[jj[n]]));
}
'
I am using R version 3.0.2 (2013-09-25) in Platform: x86_64-w64-mingw32/x64 (64-bit) and rstan_2.2.0.
Info on the compiler is:
> system("g++ --version")
G__~1.EXE (GCC) 4.6.3 20111208 (prerelease)
Is this really an error in the manual? Or what can I be doing wrong?
Thanks for any guidance.
Edwin
P.S. Explanations for beginners are highly appreciated.