I am making my first steps in STAN.
I am trying estimate parameters of non-linear transform during linear regression (fix effects).
My Stan script looks syntactically correct, but I am getting error during compilation using RStan:
Error in stanc(file = file, model_code = model_code, model_name = model_name, : **
** c++ exception (unknown reason)
I assume that it maybe due to computations in the transformed parameters section.
I ran some of my less complex scripts successfully before.
I’d appreciate any ideas.
Please, find my STAN program, R script and data included.
adstock1.stan (1.4 KB)
adstockTest.r (662 Bytes)
OneMediaData.csv (9.2 KB)
No, it is because your Stan program does not parse and you are using the clang4 compiler that mishandles C++ exceptions, rather than the one that comes with Xcode. The problems are
- On line 4, you need to delete the
v is a scalar
- On line 36, you need to delete the
<lower=0> because such constrains cannot be declared in local blocks
- On line 37, the same
- On line 48, change the name of the function from
Hill which is the name of the function you declared
After that, it should parse and compile, but if it throws any C++ exceptions during sampling, it will stop with the
c++ exception (unknown reason) message.
Thank you for your comments.
I switched to another platform and fixed the errors.
Now the program is running, but it is very slow and does not converge.
The Rhat is 1.4, 1.7, 2,5 and 3 for estimated parameters.
The n_eff is less than 10 for 1000 post-warmup draws.
Any suggestions? Should I “vectorize” the program? Change priors?
I would also appreciate any links to useful stuff.
Our generic advice is in the manual chapter on problematic posteriors. It helps if you post revised programs so we know what you mean by fixing errors. Just cut and paste the Stan program into Discourse using three triple back ticks (
```) on the line before and after.