|
1 | 1 | --- |
2 | 2 | title: "Upgrading to the new ODE interface" |
3 | 3 | author: "Ben Bales & Sebastian Weber" |
4 | | -date: "19 July 2020" |
| 4 | +date: "26 July 2020" |
5 | 5 | output: html_document |
6 | 6 | --- |
7 | 7 |
|
8 | 8 | # Introduction |
9 | 9 |
|
10 | 10 | Cmdstan 2.24 introduces a new ODE interface intended to make it easier to |
11 | | -specify the ODE RHS by avoiding packing and unpacking schemes required with |
| 11 | +specify the ODE system function by avoiding packing and unpacking schemes required with |
12 | 12 | the old interface. |
13 | 13 |
|
14 | 14 | Stan solves for $y(t, \theta)$ at a sequence of times $t_1, t_2, \cdots, t_N$ |
@@ -276,18 +276,28 @@ output is an array of vectors (`vector[]`). |
276 | 276 |
|
277 | 277 | ```{stan, output.var = "", eval = FALSE} |
278 | 278 | transformed parameters { |
279 | | - vector<lower=0>[4] y[N_t] = ode_rk45(simple_SIR, y0, t0, t, beta, kappa, gamma, xi, delta); |
| 279 | + vector<lower=0>[4] y[N_t] = ode_rk45(simple_SIR, y0, t0, t, |
| 280 | + beta, kappa, gamma, xi, delta); |
| 281 | +} |
| 282 | +``` |
| 283 | + |
| 284 | +The `ode_rk45_tol` function can be used to specify tolerances manually: |
| 285 | + |
| 286 | +```{stan, output.var = "", eval = FALSE} |
| 287 | +transformed parameters { |
| 288 | + vector<lower=0>[4] y[N_t] = ode_rk45_tol(simple_SIR, y0, t0, t, |
| 289 | + 1e-6, 1e-6, 1000, |
| 290 | + beta, kappa, gamma, xi, delta); |
280 | 291 | } |
281 | 292 | ``` |
282 | 293 |
|
283 | 294 | ### Full Model |
284 | 295 |
|
285 | | -The full model with the new interface can be found |
286 | | -[here](https://github.com/stan-dev/stat_comp_benchmarks/blob/feature/variadic-odes/benchmarks/sir/sir.stan); |
287 | | -the full model with the old interface can be found |
288 | | -[here](https://github.com/stan-dev/stat_comp_benchmarks/blob/master/benchmarks/sir/sir.stan), |
289 | | -and the data can be found |
290 | | -[here](https://github.com/stan-dev/stat_comp_benchmarks/blob/master/benchmarks/sir/sir.data.R). |
| 296 | +The full model with the new interface is |
| 297 | +[here](https://github.com/stan-dev/stat_comp_benchmarks/blob/master/benchmarks/sir/sir.stan) and the data is [here](https://github.com/stan-dev/stat_comp_benchmarks/blob/master/benchmarks/sir/sir.data.R). |
| 298 | + |
| 299 | +The full model with the old interface is |
| 300 | +[here](https://github.com/stan-dev/stat_comp_benchmarks/blob/64b6597cd17de77e91dcfb1a9977758407017d20/benchmarks/sir/sir.stan), and the data is [here](https://github.com/stan-dev/stat_comp_benchmarks/blob/64b6597cd17de77e91dcfb1a9977758407017d20/benchmarks/sir/sir.data.R). |
291 | 301 |
|
292 | 302 | ## PKPD Model |
293 | 303 |
|
@@ -373,14 +383,26 @@ In the new interface the arguments are simply passed at the end of the |
373 | 383 |
|
374 | 384 | ```{stan, output.var = "", eval = FALSE} |
375 | 385 | transformed parameters { |
376 | | - vector[1] C[N_t] = ode_bdf(one_comp_mm_elim_abs, C0, t0, times, k_a, K_m, V_m, D, V); |
| 386 | + vector[1] mu_C[N_t] = ode_bdf(one_comp_mm_elim_abs, C0, t0, times, |
| 387 | + k_a, K_m, V_m, D, V); |
| 388 | +} |
| 389 | +``` |
| 390 | + |
| 391 | +The `ode_bdf_tol` function can be used to specify tolerances manually: |
| 392 | + |
| 393 | +```{stan, output.var = "", eval = FALSE} |
| 394 | +transformed parameters { |
| 395 | + vector[1] mu_C[N_t] = ode_bdf_tol(one_comp_mm_elim_abs, C0, t0, times, |
| 396 | + 1e-8, 1e-8, 1000, |
| 397 | + k_a, K_m, V_m, D, V); |
377 | 398 | } |
378 | 399 | ``` |
| 400 | + |
379 | 401 | ### Full Model |
380 | 402 |
|
381 | | -The full model with the new interface can be found |
382 | | -[here](https://github.com/stan-dev/stat_comp_benchmarks/blob/feature/variadic-odes/benchmarks/one_comp_mm_elim_abs/one_comp_mm_elim_abs.stan); |
383 | | -the full model with the old interface can be found |
384 | | -[here](https://github.com/stan-dev/stat_comp_benchmarks/blob/master/benchmarks/pkpd/one_comp_mm_elim_abs.stan), |
385 | | -and the data can be found |
386 | | -[here](https://github.com/stan-dev/stat_comp_benchmarks/blob/master/benchmarks/pkpd/one_comp_mm_elim_abs.data.R). |
| 403 | +The full model with the new interface is |
| 404 | +[here](https://github.com/stan-dev/stat_comp_benchmarks/blob/master/benchmarks/one_comp_mm_elim_abs/one_comp_mm_elim_abs.stan) and the data is [here](https://github.com/stan-dev/stat_comp_benchmarks/blob/master/benchmarks/one_comp_mm_elim_abs/one_comp_mm_elim_abs.data.R). |
| 405 | + |
| 406 | +The full model with the old interface is |
| 407 | +[here](https://github.com/stan-dev/stat_comp_benchmarks/blob/64b6597cd17de77e91dcfb1a9977758407017d20/benchmarks/pkpd/one_comp_mm_elim_abs.stan) and the data is [here](https://github.com/stan-dev/stat_comp_benchmarks/blob/64b6597cd17de77e91dcfb1a9977758407017d20/benchmarks/pkpd/one_comp_mm_elim_abs.data.R). |
| 408 | + |
0 commit comments