Hi all, I am trying to get familiar with RStan. I tried examples from Stan reference guide for “target+=” and it worked. But, in my code I got the error while compiling. The code within model block as follows:
You are at least missing a couple of semicolons, one after uniform(0.1,0.5) and one after the second integral. Not sure why it it complains about line 1.
SAMPLING FOR MODEL ‘843c6ba9cfaa3c4c0a9a5e81d15f0e98’ NOW (CHAIN 1).
Chain 1: Unrecoverable error evaluating the log probability at the initial value.
Chain 1: Exception: Error in function tanh_sinh::integrate: The tanh_sinh quadrature evaluated your function at a singular point and got nan. Please narrow the bounds of integration or check your function for singularities. (in ‘model18943bc16ebd_843c6ba9cfaa3c4c0a9a5e81d15f0e98’ at line 85)
Te likelihood is defined only when x>0 so maybe one t is \leq 0? Actually, your likelihood looks like a log-normal? Stan has a builtin lognormal CDF if that’s what you’re after.
Oh, wait, you do define t[1]=50 and so on. Those aren’t the problem.
However, the uniform prior on mu and sigma is. If they are parameters you need to declare the bounds.
Hello Niko, I have again back to my code for working with. Thank you for the above comments and I have done modifications as you suggested. But, again I am having this error message,
Chain 1: Unrecoverable error evaluating the log probability at the initial value.
Chain 1: Exception: vector[uni] assign range: accessing element out of range. index 0 out of range; expecting index to be between 1 and 3
“error occurred during calling the sampler; sampling not done”
Is this saying the error in vector defined line? or some other else? I would like to have your suggestions?
I will be most grateful for your time and comments here.
Thanks for your suggestions. I found an error in indexing and hope that it’s okay now. But, I am struggling with some other errors so then tried to solve those in various ways, but again I am failed.
Got this error message;
SAMPLING FOR MODEL ‘02bf6148d01d0edcb8aa3daa9e2c762f’ NOW (CHAIN 1).
Chain 1: Rejecting initial value:
Chain 1: Log probability evaluates to log(0), i.e. negative infinity.
Chain 1: Stan can’t start sampling from this initial value.
But, because of above issue so then I decided to add “ïnit” with "stan() as follows;
inits via list: Set inital values by providing a list equal in length to the number of chains. The elements of this list should themselves be named lists, where each of these named lists has the name of a parameter and is used to specify the initial values for that parameter for the corresponding chain.
@Bob_Carpenter@nhuurre I added init values for my stan() as this:
stan(model_code, data, warmup = 250, iter = 500, chains = 2, init = list(list(mu=4.5),list(sigma2=0.05))
But, no luck. It gives me this error message,
SAMPLING FOR MODEL ‘02bf6148d01d0edcb8aa3daa9e2c762f’ NOW (CHAIN 1).
Chain 1: Rejecting initial value:
Chain 1: Log probability evaluates to log(0), i.e. negative infinity.
Chain 1: Stan can’t start sampling from this initial value.
I don’t know what is the reason for it, Do I need to define a function to generate initial values that can
be fed to function stan’s argument init as the example mentioned under this link “https://mc-stan.org/rstan/reference/stan.html#examples”.