Two questions: ①Rejecting initial value but still sampling. ②regarding divergent transitions

The warning was triggered by the computed value for proc not matching the constraint. Unlike for parameters which are fully controlled by the sampler and satisfy the constraints by construction, for transformed parameters the bounds are just a check - which tends to be useful to prevent bugs in your code. So for some paramter values U[j]+B[j]*log_A[t-1,j] can be larger then log_max. This doesn’t seem surprising as if I read the model correctly there is no reason why both U and B should avoid values that would lead to proc exceeding the bounds.

If the check for constraints fails, the sample is rejected (i.e. taken as having 0 posterior density) and the sampler tries to continue.

Regarding divergent transitions, see Divergent transitions - a primer

As a general advice, this looks like a quite complex model. I would suggest you start with a simpler version (e.g. without the linear predictors for everything) and get that working first. Debugging such complex models is IMHO almost impossible even for very experienced Stan users.

Hope that helps!

2 Likes