Hello, I am quite new to stan. I mainly want to use Rstan to conduct MCMC or Bayes works.
Here is a toy MCMC example. Unfortunately, I haven’t able fix it.
(BTW, I am quite sure that the installation is OK, because I have run a couple of examples on the internet which worked well.)
sleep_model <- "
parameters {
real m;
real<lower=0, upper=200> s;
}
data {
int<lower=0> J;
real y[J];
}
model {
y ~ normal(m, s); // likelihood function
m ~ normal(50, 25) ; // prior distribution for m
s ~ uniform(0,200); // prior distribution for s
}
"
set.seed(10)
sleep_sim_stan <- stan(model_code=sleep_model, data = list(J=18 ,y=sleep_study$diff_3),
chains=4,iter= 5000*2)
Here the variable y = [71 -18 33 -36 33 75 16 -11 29 34 19 -1 30 125 6 15 12 41].
The error message states:
“Error in stanc(file = file, model_code = model_code, model_name = model_name, :
c++ exception (unknown reason)”
Yeah the order of the blocks matters, but like @wds15 said you should see a better error message. I think some information that should be printed isn’t getting printed. Can you share what operating system you are using and what version of R and RStan you have? That will help us look into it why it just says “unknown reason”.
Thanks for sharing that info, that’s interesting. I have Catalina also but I have R 4.0.2 instead of 3.6.4. When I try to parse your Stan program I get
PARSER FAILED TO PARSE INPUT COMPLETELY
STOPPED AT LINE 6:
data {
int<lower=0> J;
real y[J];
}
which, to be honest, isn’t the best error message (it doesn’t mention the order of the blocks) but at least it points to the line number where the error is. I wonder if for some reason this message is getting suppressed in older versions of R.