Hello, I am relatively new to Stan and I keep getting in circles with a syntax error within my Stan model which is the following:
For reference here is the model and the error seems to be due to the simplex line, I am using python 3.11.2 and using PyStan 3.9.1
data {
int<lower=0> N;
int<lower=0> S;
matrix[N, S] entries;
vector[N * S] exits;
}
parameters {
vector[(S-1) * S] raw_alpha;
vector[S] intercept;
real<lower=0> sigma; // common standard deviation for exits
}
model {
// Priors for raw alpha parameters
raw_alpha ~ normal(0, 1); // prior on the full raw_alpha vector
// Simplex vector definition
simplex[S-1] alpha[S];
// Populating the alpha array using portions of raw_alpha
for (int s = 1; s <= S; ++s) {
alpha[s] = softmax(segment(raw_alpha, (s-1)*(S-1) + 1, S-1));
}
// Model exits using the transformed parameters
for (int n = 1; n <= N; ++n) {
vector[S] exits_mu;
for (int s = 1; s <= S; ++s) {
exits_mu[s] = dot_product(entries[n], alpha[s]) + intercept[s];
}
exits[(n-1)*S + 1 : n*S] ~ normal(exits_mu, sigma);
}
}
After compiling I get this error
Building: Syntax error:
-------------------------------------------------
18:
19: // Define a simplex vector inside the model block
20: simplex[S-1] alpha[S];
^
21:
22: // Populate the alpha array using portions of raw_alpha
-------------------------------------------------
Variable declaration, statement or "}" expected.
Anyone knows how to resolve the issue?
Thanks