bgoodri:
One is to put print statements into your code, such as
print("x is ", x);
in which case it will send that line to the screen. However, it does so every time the log-posterior kernel function is evaluated (if you put the print statement in the transformed parameters or model block), in which case you are going to get thousands of such lines each with a different value of x.
When I am having trouble with a model, I usually just put in print statements anywhere I think there could be a problem, compile with -O0 (for compilation speed), and then evaluate the likelihood once using some crude manipulations of the rstan objects:
I’ve found that sometimes I have simple errors in my code that can be hard to debug from the error thrown in the sampling command. Additionally, it can be hard to profile the code using sampling since there is a lot going on with the HMC sampler.
It’s not really clear how to get the log prob value from the stan model, but I was able to come up with this. I was following the rstan thread, and wanted to share this here in case anyone wants to use it, and also in hopes that this sort of thing woul…
1 Like