Currently when a comma is missing in the arguments to a function call the Stan parser throws a confusing warning: ‘PARSER EXPECTED: “(”’, could we make it say ‘PARSER EXPECTED: “,”’ instead? Didn’t file an issue b/c I’m not sure how hard this is.
--- Translating Stan model to C++ code ---
Model name=delay_model_l1_model
Input file=/Users/krzysztof/projekty/delay-analysis-thailand-build/models/delay-model-l1.stan
Output file=/Users/krzysztof/projekty/delay-analysis-thailand-build/models/delay-model-l1.hpp
SYNTAX ERROR, MESSAGE(S) FROM PARSER:
ERROR at line 292
290: province_index, district_index, subdistrict_index, delivery_index);
291:
292: vector[n_obs] delta = construct(1, 0, n_obs,
^
293: scaling[4], delta_0 + offset[4]
PARSER EXPECTED: "("
make[3]: *** [/Users/krzysztof/projekty/delay-analysis-thailand-build/models/delay-model-l1.hpp] Error 253
make[2]: *** [models/delay-model-l1] Error 2
make[1]: *** [models/CMakeFiles/compiled-delay-model.dir/all] Error 2
make: *** [all] Error 2
Please don’t let difficulty of solving something hold you back from filing an issue.
We can fix this if we have a minimal reproducible example (preferably less than 300 lines long). I couldn’t actually tell where you thought the comma was missing from in this example.
This misleading error message is still around.
Here is a reproducible example:
functions{
real fun_mre(real x, real y, real z ){
return(x + y + z);
}
real fun_mre1( real x, real y, real z ){
real total;
total = fun_mre(x,
y;
z);
return(total);
}
}
data{}
model{}
When I try to parse it I get:
SYNTAX ERROR, MESSAGE(S) FROM PARSER:
error in 'model2892f772215_mre' at line 11, column 23
-------------------------------------------------
9: real fun_mre1( real x, real y, real z ){
10: real total;
11: total = fun_mre(x,
^
12: y;
-------------------------------------------------
PARSER EXPECTED: "("
Error in stanc(filename, allow_undefined = TRUE) :
failed to parse Stan model 'mre' due to the above error.
I am pleased to say that putting this example together enabled to find what was causing the rouble in my own code.
Hey all. Just to let you know I observed this same error just now when I mistakenly included an extra , in the function call.
E.g.
functions{
real fun_mre(real x, real y, real z ){
return(x + y + z);
}
real fun_mre1( real x, real y, real z ){
real total;
total = fun_mre(x,
y,,
z);
return(total);
}
}
data{}
model{}
Your data block compiles fine for me with the latest CmdStanR:
library(cmdstanr)
file <- write_stan_tempfile(
"
data{
int LENGTH;
matrix[LENGTH,2] RT;
int NUM_CHOICES;
}
"
)
# compiles with no error
mod <- cmdstan_model(file)
Oh…no luck for me on windows, I changed the version because of I was unable to get the output with rstan version 2.19.3 and then got the suggestion to change it. So then, better option is to install CmdStanR interface on windows, not in Linux?
Not you, I am confused myself. I haven’t installed linux in my laptop, but as you recommend it is possible to install CmdStanR interface on windows 10.
No problem. Yeah it should be possible to use CmdStanR with Windows10.
That said, if you want to give RStan on Windows another try I just saw that @bgoodri just edited this post Rstan on Windows with new links to install a potentially fixed version RStan. I’m not sure if it will be fixed for you, but it might be.
erandi@DESKTOP-O9FUKUT MSYS ~
$ pacman -Sy mingw-w64-x86_64-make
:: Synchronizing package databases…
mingw32 is up to date
mingw64 is up to date
warning: mingw-w64-x86_64-make-4.2.1-2 is up to date – reinstalling
resolving dependencies…
looking for conflicting packages…
Packages (1) mingw-w64-x86_64-make-4.2.1-2
Total Installed Size: 1.33 MiB
Net Upgrade Size: 0.00 MiB
:: Proceed with installation? [Y/n] Y
(1/1) checking keys in keyring [####################################################################] 100%
(1/1) checking package integrity [####################################################################] 100%
(1/1) loading package files [####################################################################] 100%
(1/1) checking for file conflicts [####################################################################] 100%
(1/1) checking available disk space [####################################################################] 100%
:: Processing package changes…
(1/1) reinstalling mingw-w64-x86_64-make [####################################################################] 100%
erandi@DESKTOP-O9FUKUT MSYS ~
$
Then I tried to given three lines on cmd, but it gave me the error of
‘g++’ is not recognized as an internal or external command, operable program or batch file
Please kindly guide me in this regard. I wanna give a try for CmdStanR as I am having earlier mentioned an error with rstan 2.21.0.
One more thing, I failed when running with more than one chain, do you have an idea for that?