How to debug initialization failures

Hi,
After upgrading to rstan 2.18 I can’t run my model any more. How to debug it? Which of the parameters fails to initialize?
All I am getting is
SAMPLING FOR MODEL ‘SGT’ NOW (CHAIN 1).
Chain 1: Initialization between (-2, 2) failed after 100 attempts.
[1] “Error in sampler$call_sampler(args_list[[i]]) : Initialization failed.”
[1] “error occurred during calling the sampler; sampling not done”

Regards,
Slawek

Everything that ran in 2.17 should run in 2.18. Can you include the model and data that have different behavior?

Initialization fails when the log density can’t be initialized within support.

you should be getting more of a report from this. Are you running it in one chain? Is this R?

In general, the way to debug initilalization is to find out where the rejection or negative infinity increment in the log density arise. One way to do this is put a print statement after each statement, print(1, target()), then print(2, target()), etc., which will show you how far you get with finite values.

Hi Bob,
Thank you for the prompt answer.
Yes, it is R, rstan, one chain on Windows 10.
I had a lot of problems installing it (2.18), I thought I have overcome them, but maybe not. Let me check if my package works on Linux or Mac.

Regards,
Slawek

I don’t think the behavior you’re seeing could come from an install issue. I just installed 2.18.1 and can verify that it’s broken. I ran this

> stan(model_code = "parameters { real x; } model { reject("foo"); }", chains=1, iter=10)

and after a ton of warning messages, it ends with this:

SAMPLING FOR MODEL '61b0f66ecff6751e01f0b5e389249dfd' NOW (CHAIN 1).
Chain 1: Initialization between (-2, 2) failed after 100 attempts. 
[1] "Error in sampler$call_sampler(args_list[[i]]) : Initialization failed."
error occurred during calling the sampler; sampling not done

What it should be doing is spitting out the rejection message “foo”. I filed an issue:

Thanks again for reporting.

Hi,
Thank you very much for checking!

Regards,
Slawek

We’ve gotten to the bottom of the bug so it’ll get fixed in the next release, which will probably be soon to clear up this and a few other issues.

Thank you!