";" expected after variable declaration

I having been running in circles with this same issues for hours today, to no avail. Forums have not led me anywhere in terms of getting closer to resolving (what should be) a very simple issue (see stan below). I am getting the “;” expected after variable declaration (referenced to y[N]; on line 4). I have tried everything from reinstalling mingw32 and cmdstan, to creating different stans w/o the y[N] line. The latter does work, but y[N] should work, as I have seen them applied in several examples online. If I trying having minwg32 make the stan (as a forum suggested) I get the same error, along with an error that says:

‘cut’ is not recognized as an internal or external command,
operable program or batch file.
‘cut’ is not recognized as an internal or external command,
operable program or batch file.
process_begin: CreateProcess(NULL, expr >= 8, …) failed.
The system cannot find the file specified.
stan/lib/stan_math/make/compiler_flags:174: make/ucrt: No such file or directory
INFO: Could not find files for the given pattern(s).
‘— Translating Stan model to C++ code —’

I am super frustrated and hoping someone knows what I have done wrong and how (whether) I can fix this? Thanks.

data {
  int<lower=0> N; // Number of observations
  int<lower=1> K; // Number of categories in the outcome variable
  int<lower=1, upper=K> y[N]; // Altitude sickness category for each observation
  matrix[N, 4] X; // Predictor matrix: elevation, oxy_sat, HRV, acclimatization
parameters {
  matrix[4, K-1] beta; // Coefficients for predictors (K-1 because one category is a baseline)
model {
  // Assuming a standard normal prior for simplicity
  for (j in 1:(K-1)) {
    beta[:, j] ~ normal(0, 5);
  // Multinomial logistic regression
  y ~ categorical_logit(X * beta);

I encountered the same problem yesterday. For your int<lower=1, upper=K> y[N]; in the data block, the latest syntax should be array[N] int<lower=1, upper=K> y.

You are a true godsend! It worked. I could not find a solution to this ANYWHERE. Thanks a ton.

a search of the forums for this error message brings a few recent topics with this issue and the above solution:


where did you look first?

is it possible to update the RStan docs without having to do a whole new CRAN release?

@mitzimorris maybe it’s worth temporarily pinning a topic (or this post?) in the forums with the title of the error since it keeps comming up and it might make it easier for people to find.

This has to have been CmdStanR

How about adding to sections “Data Types and Declarations” and “Data Types and Declarations” something like

Stan version before x.yy allowed declaring arrays of integers as int N<size>;. This is not supported since Stan version x.yy. See Array data types for the current syntax.

And maybe add in the end of page “Data Types and Declarations” a subsection “Compiler error messages” with something like

Compiler syntax error messages

";" or plain assignment expected after variable declaration.

  • the code is missing ; or
  • the code is using the old array syntax, see the current syntax in Section “Array data types” Data Types and Declarations

Maybe then eventually search for this syntax error will point to the Stan manual. There will be code examples with old syntax for many years.


The next release will feature an improved message in this case


I’m running into the same error, though it does not involve an mis-specified integer array (at least I do not think it does). Any help is greatly appreciated. Th error is:

Compiling Stan program…
Syntax error in ‘/var/folders/m7/zgrjwxmj76vcyj3w0shwp5p00000gn/T/Rtmp7upG1r/model-5bd433ab8474.stan’, line 23, column 15 to column 16, parsing error:

21:  vector<lower=0>[J] varphi_int;
22:  array[T] vector[J] varphi;
23:  vector<lower=0>[J] nxi;

} 25:

“;” expected after variable declaration.

make: *** [/var/folders/m7/zgrjwxmj76vcyj3w0shwp5p00000gn/T/Rtmp7upG1r/model-5bd433ab8474.hpp] Error 1

Error: An error occured during compilation! See the message above for more information.

data {

int<lower=1> H;
int<lower=1> J;
int<lower=1> T;
int<lower=0> T0;
vector[J] ln_lq[H];
vector[J] lw_lP[H];
row_vector[H] weight;
array[H] int<lower=1,upper=T> year;

// hyperparameters
vector[J] mu_xi;
vector[J] sigma_xi;


parameters {

cholesky_factor_corr[J] L_Omega;
vector<lower=0>[J] L_sigma;
vector<lower=0>[J] varphi_int;
array[T] vector[J] varphi;
vector<lower=0>[J] nxi;


transformed parameters {

vector[J] fe_int[T];
vector[J] ln_lq_hat[H];	
matrix[J,J] L_Sigma;
vector[J] phi;

phi = 1 ./ (-nxi - 1);

L_Sigma = diag_pre_multiply(L_sigma, L_Omega);

for(t in 1:T){
fe_int[t] = varphi_int .* varphi[t];

for(h in 1:H){
ln_lq_hat[h] = lw_lP[h] .* phi + fe_int[year[h]];


model {

// - xi
nxi ~ lognormal(mu_xi,sigma_xi);

// Var/Covar Objects
L_Omega ~ lkj_corr_cholesky(4);
L_sigma ~ cauchy(0, 2.5);

// Fixed effect terms
for(t in 1:T){
varphi[t] ~ normal(0,1);

for(h in 1:H){
target += multi_normal_cholesky_lpdf(ln_lq[h] | ln_lq_hat[h], L_Sigma) .* weight[h];


generated quantities{

vector[J] xi;
vector[J] alpha;
array[T0,J] real year_fe; 
array[H,J] real zeta;

xi = - nxi;
alpha = exp((phi-1) .* fe_int[1]) ./ (1+exp((phi-1) .* fe_int[1]));

// Fixed effects less reduced form intercept common to all years
for(t in 2:T){
year_fe[t-1] = fe_int[t] - fe_int[1];

// Productivities by agent, including common, fixed-effect components
for(h in 1:H){
zeta[h] = exp(- (ln_lq_hat[h] - lw_lP[h] .* phi - fe_int[1]) .* phi .* xi);


These lines in your data block seem to be the issue - they’re also using the removed array syntax and need to be array[H] vector... instead. I get a different error message than you that points me to these lines when I try to compile your model

1 Like