Rejecting initial value

This is not unusual for ODE models we’ve seen in the past.

First, yes it’s OK to reject and keep going. This is what’ll happen if you start with something like x ~ exp(1) where x is declared to be real—it’ll keep generating values until it gets a positive one from which it can start. Same thing in ODEs—it’ll keep going until it finds one it can process.

You can help that along two ways.

The crude way to do it is to provide initial values.

The better approach is to reparameterize. For example, fi you have a variable that is in the (-0.001, 0.001) range and values of 1 or -1 screw things up, you can recode as:

parameters {
  real theta_raw;

transformed parameters {
  real theta = theta_raw * 0.001;

Then, when theta_raw is initialized in (-2, 2), theta will be initialized in in (-0.002, 0.002).

We’re going to roll out direct support for this kind of linear transform in 2.19.