Compilation error when using complex transformed parameters

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)

Thank you,
VP

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

  1. On line 4, you need to delete the [i] because v is a scalar
  2. On line 36, you need to delete the <lower=0> because such constrains cannot be declared in local blocks
  3. On line 37, the same
  4. On line 48, change the name of the function from HillTrans to 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.

Hello Ben,

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.

Thank you,
VP

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.