Error on reject, need help repairing script

In the function block of my code I have the following line.

    if (sigma<=0)
      reject("sigma<=0; found sigma =", sigma)

This code worked in an older version of RStan from around 4/2020. Now I’m running a newer version (along with a newer version of R), which offers the following error:

Syntax error in 'string', line 8, column 4 to column 6, parsing error:
Ill-formed reject statement. After "reject(", we expect a comma separated list of either expressions or strings, followed by ");".

I was able to get the script to execute with the semi-colon

    if (sigma<=0)
      reject("sigma<=0; found sigma =", sigma);

The strange thing is, now I’m getting different results in my model. I’m also getting some errors from the compiler:

Warning message:
In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :
  '-E' not found

The full script is attached if you want to take a gander.
multi-level.stan (1.4 KB)

1 Like

It appears that the original syntax should not have been allowed, but was OK due to a bug in an earlier compiler (Stan AFAIK expects semicolons everywhere).

The changing results are potentially weird, potentially not. How big is the difference? And in what quantities? Do you get more/less warnings? The Stan’s sampler and math library is evolving - maybe the previous behaviour was a result of a bug that got fixed in the meantime. Also if the geometry of the posterior is somehow weird, minor changes in the sampler could change how it interacts with your posterior.

Are those reject statements actually triggered in your model? Because if yes, then it is quite likely the posterior will be problematic for Stan in any case.