Stan code compiles in RStan but not in CmdStan

Hi
I have the very same Stan code, that I run in RStan and compiles without any problem, but which does not compile in CmdStan. The CmdStan is run through Mathematica, and I checked the installation before with some other example code (runs fine without throwing up any issues).

The specifications are
M3 Max Apple silicone, with MacOS 14.4
cmdstan 2.34.1
GNU Make 3.81
Apple clang version 15.0.0 (clang-1500.1.0.2.5)
Target: arm64-apple-darwin23.4.0

The Stan code (copied) is estimating a coin tossing
//
// This Stan program defines a simple model, with a
// vector of values ‘y’ modeled as normally distributed
// with mean ‘mu’ and standard deviation ‘sigma’.
//
// Learn more about model development with Stan at:
//
// Stan - RStan
// RStan Getting Started · stan-dev/rstan Wiki · GitHub
//

// The input data is a vector ‘y’ of length ‘N’.
data {
int<lower=0> N;
int<lower=0,upper=1> y[N];
}

// The parameters accepted by the model. Our model
// accepts two parameters ‘mu’ and ‘sigma’.
parameters {
real<lower=0, upper=1> theta;
}

// The model to be estimated. We model the output
// ‘y’ to be normally distributed with mean ‘mu’
// and standard deviation ‘sigma’.
model {
theta ~ beta(1, 1);
for (n in 1:N)
y[n] ~ bernoulli(theta);
}

The error message is:

Running: make -C /Users/sts-max/anaconda3/envs/stan/bin/cmdstan/ /private/var/folders/rv/1c7gt1g50_g2qfqv91zpg3w00000gn/T/binomial

— Translating Stan model to C++ code —
bin/stanc
–o=/private/var/folders/rv/1c7gt1g50_g2qfqv91zpg3w00000gn/T/binomial.
hpp /private/var/folders/rv/1c7gt1g50_g2qfqv91zpg3w00000gn/T/binomial.
stan

Syntax error in
‘/private/var/folders/rv/1c7gt1g50_g2qfqv91zpg3w00000gn/T/binomial.
stan’, line 16, column 24 to column 25, parsing error:

14:  data {
15:    int<lower=0> N;
16:    int<lower=0,upper=1> y[N];
                             ^
17:  }
18:  

“;” expected after variable declaration.
make: ***
[/private/var/folders/rv/1c7gt1g50_g2qfqv91zpg3w00000gn/T/binomial.
hpp] Error 1

Any help is much appreciated. Thanks very much in advance!

1 Like

Search is your friend :)

1 Like

Thanks very much Ven! that worked. I searched, but it seems, not as sophisticated as you.

1 Like