We're about to roll out CVODES in Stan 2.10, which should be
both more robust and faster. See below for some details.
> On Apr 9, 2016, at 12:59 PM, idontgetoutmuch <
idontge...@gmail.com> wrote:
>
> I have this working too. The accuracy of the results are
> impressive. Good job Stan devs! I have some questions.
>
> 1. I generated some data with known parameters. What integrator is being
> used and what error control?
Adams Moulton. See
https://computation.llnl.gov/casc/sundials/description/description.html#descr_cvode
The original solver was an RK45 version from Boost.
> I'm assuming RK4 but neither was I able
> to see anything in the documentation and nor did searching the repo
>
https://github.com/stan-dev/stan for RK4 yield any results. I tried
> another solver (RKf45) in a stand-alone program but got sufficiently
> different results to make me feel I didn't understand enough of what
> Stan was doing under the covers. If I get time I will try a pure RK4
> but I feel I'm shooting in the dark a bit until I know what Stan
> *actually* uses.
>
> 2. It's imperative to use
>
> ```
> ./examples/pkpdmodel/pkpdmodel sample algorithm=hmc stepsize=0.001 data file=examples/pkpdmodel/pkpdmodel.data.R init=0.25
> ```
>
> If you don't specify the stepsize and the init then the running the model produces
>
> ```
> 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 50: integrate_ode_cvode: parameter vector[2] is 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.
> ```
>
> and nothing further (in a reasonable time).
>
> I assume that the stepsize is specified as 0.001 as the parameters
> being estimated are of that order? I was unable to find any clues as
> to why init needs set to 0.25 in this case though.
It takes steps in stepsize * gradient, and that needs to be small enough
to follow curvature in the posterior.
init=0.25 means that parameters are randomly initialized in (-0.25, 0.25)
on the unconstrained scale. All parameters are transformed to being
unconstrained (details in the manual).
>
> 3. The estimation took
>
> ```
> Warmup took (469) seconds, 7.8 minutes total
> Sampling took (717) seconds, 12 minutes total
> ```
>
> Is this to be expected? It seems quite quite big to me given the state
> update (solving the ODE) should really be quite cheap.
CVODES should be faster. These runs can be slow because either the
solver hits a stiff region it can't deal with or because the posterior
parameter density is complicated, and we need small step sizes in the HMC
algorithm. The algorithms and adaptations are also described in the manual.
- Bob