On Friday, August 5, 2016 at 8:46:54 AM UTC-4, Charles Margossian wrote:
> I agree with you that Torsten should be broken up, especially since many of its features appear to be extendable to fields other than pharmacometrics. The initial idea was to take a set of functions present in NONMEM and BUGS, and see if we could implement them in Stan. Fitting everything into one function was meant to meet a desired and expected simplicity for the user. I believe one of Torsten's strengths is how accessible and convenient it is for pharmacometricians.
That's ultimately a great approach to an interface for scientists. I'm only suggesting making some under-the-hood changes to make that layer thinner and less specialized.
> Evidently, there seems to be a more ambitious and better approach.
My suggestion is to go for something less ambitious first. The Stan development process for bringing in small well-specified chunks of functionality is pretty clear and well greased at this point. At the same time I'm not sure I've ever seen a big ambitious set of changes that went in smoothly. Maybe Bob/Daniel will just work their magic and see how to integrate all this but
> They are not really pharma-specific in the sense that other modeling could use them (e.g.-geochemical systems).
>
> I'm trying to learn about ODE based models in other fields. Right now, my focus in on system biology, but if you have any papers or documents on geochemistry, I am very interested. My hope is to get a better sense of what is pharma specific and what is generalizable in Torsten.
Bob has some examples in Stan----I can't find them at the moment but maybe he'll pipe up. I only did some thesis stuff by simulation as an undergrad (it's on floppies somewhere...) so I'm out of touch there. The other uses I'm familiar with are compartmental models in hydrology and SIR-type compartmental models in infectious disease but again it's not my speciality.
> Someday it might be nice to have a library of pre-implemented ODE's for a variety of model types like this
>
>
> Agreed. It might even be possible to code the gradients by hand for certain models, and I want to try it out with the one and two compartment models.
>
> The GeneralCptModel_* functions seem like they are just adapters to use ODE systems with the NONMEM data format---is that right or do they serve another function?
>
>
> I think you have the right idea.
>
> It seems like having helper functions to turn NONMEM data into a more ODE-compatible format could live separately from the code required to deal with multiple solver restarts associate with events.
>
>
> An "internal format", to use Sebastian's term, would indeed be the way to go to make the code more general, and is what has been implemented in Sebastian's code. We should keep in mind that some components of the event schedule could also be parameters. So we would need a wrapper at both ends of the process, one that converts NONEM into the internal format, and one that converts the result back into NONMEM format.
>
> So if I'm mostly correct here, my advice would be to break these things out more if they are going to stand a chance of getting integrated into Stan (even as libraries). Maybe something like:
> 1) Some constructs to make it more convenient to use the Stan ODE solvers with multiple restarts (associated with events in your terminology).
> 2) Some functions to handle converting NONMEM data into whatever more generic format is required by 1)
> 3) A library of ODE's that implement pharma-specific models and accept data in the NONMEM format.
>
>
> This strikes me as a very sensible approach.
>
>
> (1) would be the "Event Handler" -- currently the pred function in Torsten -- which augments the event schedule and sequentially applies to each event the "solution operator" (to use another very good term Sebastian coins in his ReadMe). It might be a good idea to split pred into two functions that individually handle (i) augmenting the data and (ii) applying the solution operator; mostly because (i) often only involves data and could thus happen in the transformed data block for efficiency purposes.
>
>
> I would like to find an easy way for the user to specify the solution operator, by letting him:
> (a) write the operator in the function block of Stan
> (b) write out an ODE system and pick an ODE integrator
> (c) call a built-in analytical operator -- currently pred1_one, pred1_two, predSS_one, and predSS_two in Torsten. I am not sure whether these should work with NONMEM data or the internal format in order for them to work with the Event Handler.
>
>
> Currently, Torsten handles (b) and (c), but it constrains the user to pass in NONMEM data.
All of this makes sense and I'm looking forward to the meeting next week. I'll give Sebastien's code a better read as well.
>
> As is all three seem to be packaged together and that might be hard for the development process to swallow.
>
>
> I would agree with you, though in the end, I think it comes down to only testing 4 functions (currently finishing up unit tests for OneCptModel). Though admittedly, I am not sure on that one.
So far Stan is tested all the way down to the math library so I'm pretty sure we'll need tests for all the pieces here.
Krzysztof