ODE Examples for Testing

86 views
Skip to first unread message

Michael Betancourt

unread,
Mar 22, 2016, 5:00:53 PM3/22/16
to stan development mailing list
Per Ben’s request I’ve attached two example ODE models (program, data, and true values)
for testing the CVODE. Note that these use the old ODE solver — to update them just
change “integrate_ode” to “integrate_ode_covode” and add three more arguments equaling
“…,1e-10, 1e-10, 1e6)”.

Let me know if they work as advertised.

ode_examples.zip

Ben Goodrich

unread,
Mar 29, 2016, 3:41:08 PM3/29/16
to stan development mailing list

I ran one of these on Windows, specifically sir.stan after changing the solver. It went okay, but there are some issues. Aside from a few overflows, there was one error code of -4 and one where the rate parameter to the poisson log-PDF came out negative. I think the results might be okay

                 mean se_mean      sd     2.5%      25%      50%      75%    97.5% n_eff Rhat
beta            
1.01    0.00    0.04     0.93     0.98     1.01     1.04     1.10   250 1.00
gamma            
0.20    0.00    0.01     0.18     0.19     0.20     0.21     0.22   245 1.00
xi              
10.50    0.04    0.67     9.21    10.04    10.47    10.99    11.72   348 1.00
delta            
0.36    0.00    0.03     0.31     0.34     0.35     0.37     0.41   184 1.00
...

but I couldn't understand the format of sir.truth.data. The full output is below.

Ben

> test <- stan("C:/Users/Stan/Downloads/ode_examples/ode_examples/sir.stan", data = dat, chains = 1)
DIAGNOSTIC(S) FROM PARSER:
Warning (non-fatal): assignment operator <- deprecated; use = instead.
Warning (non-fatal): assignment operator <- deprecated; use = instead.
Warning (non-fatal): assignment operator <- deprecated; use = instead.
Warning (non-fatal): assignment operator <- deprecated; use = instead.
Warning (non-fatal): assignment operator <- deprecated; use = instead.
Warning (non-fatal): assignment operator <- deprecated; use = instead.
Warning (non-fatal): assignment operator <- deprecated; use = instead.
Warning (non-fatal): assignment operator <- deprecated; use = instead.
Warning (non-fatal): assignment operator <- deprecated; use = instead.
Warning (non-fatal): assignment operator <- deprecated; use = instead.
Warning (non-fatal): assignment operator <- deprecated; use = instead.
Warning (non-fatal): assignment operator <- deprecated; use = instead.
Warning (non-fatal): assignment operator <- deprecated; use = instead.
Warning (non-fatal): assignment operator <- deprecated; use = instead.
Warning (non-fatal): assignment operator <- deprecated; use = instead.
Warning (non-fatal): assignment operator <- deprecated; use = instead.


SAMPLING FOR MODEL 'sir' NOW (CHAIN 1).

Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:
Exception thrown at line 68: integrate_ode_cvode: parameter vector[1] is 1.#INF, but must be finite!
If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,

but if this warning occurs often then your model may be either severely ill-conditioned or misspecified.

Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:
Exception thrown at line 68: integrate_ode_cvode: parameter vector[1] is 1.#INF, but must be finite!
If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,

but if this warning occurs often then your model may be either severely ill-conditioned or misspecified.

Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:
Exception thrown at line 68: CVode failed with error flag -4
If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,

but if this warning occurs often then your model may be either severely ill-conditioned or misspecified.

Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:
Exception thrown at line 68: CVode failed with error flag -1
If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,

but if this warning occurs often then your model may be either severely ill-conditioned or misspecified.

Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:
validate transformed params: y[k0__][k1__] is -2.31061e-011, but must be greater than or equal to 0
If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,

but if this warning occurs often then your model may be either severely ill-conditioned or misspecified.

Chain 1, Iteration:    1 / 2000 [  0%]  (Warmup)
Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:
Exception thrown at line 68: integrate_ode_cvode: parameter vector[1] is 1.#INF, but must be finite!
If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,

but if this warning occurs often then your model may be either severely ill-conditioned or misspecified.

Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:
Exception thrown at line 68: integrate_ode_cvode: parameter vector[1] is 1.#INF, but must be finite!
If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,

but if this warning occurs often then your model may be either severely ill-conditioned or misspecified.

Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:
Exception thrown at line 81: stan::math::poisson_log: Rate parameter is -0.0144557, but must be >= 0!
If this warning occurs sporadically, such as for highly constrained variable types like covariance matrices, then the sampler is fine,

but if this warning occurs often then your model may be either severely ill-conditioned or misspecified.

Chain 1, Iteration:  200 / 2000 [ 10%]  (Warmup)
Chain 1, Iteration:  400 / 2000 [ 20%]  (Warmup)
Chain 1, Iteration:  600 / 2000 [ 30%]  (Warmup)
Chain 1, Iteration:  800 / 2000 [ 40%]  (Warmup)
Chain 1, Iteration: 1000 / 2000 [ 50%]  (Warmup)
Chain 1, Iteration: 1001 / 2000 [ 50%]  (Sampling)
Chain 1, Iteration: 1200 / 2000 [ 60%]  (Sampling)
Chain 1, Iteration: 1400 / 2000 [ 70%]  (Sampling)
Chain 1, Iteration: 1600 / 2000 [ 80%]  (Sampling)
Chain 1, Iteration: 1800 / 2000 [ 90%]  (Sampling)
Chain 1, Iteration: 2000 / 2000 [100%]  (Sampling)
 Elapsed Time: 243.117 seconds (Warm-up)
               209.296 seconds (Sampling)
               452.413 seconds (Total)


Michael Betancourt

unread,
Apr 5, 2016, 9:28:03 AM4/5/16
to stan...@googlegroups.com
The warnings about y being negative are fine, but they should be seen only in warmup.
The infinity warnings are more pathological, but they could simply be an indication of
poor warmup. The -4 CVODE error is failed convergence of the linear step in the solver,
which is fine, especially given the pathological states you’re seeing. On my laptop I don’t
see such extreme pathologies, but I also ran with an initial step size of 0.001 and might
have and a better random seed.

sir_truth.stan is the true evolution of the SIR states in columns of time, y1, y2, y3, and y4.
The true vales are

beta = 1
gamma = 0.2
xi = 10
delta = 0.333

consistent with your fit. So I would say that the implementation is fine.
> --
> You received this message because you are subscribed to the Google Groups "stan development mailing list" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to stan-dev+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages