[R] deSolve question
Thomas Petzoldt
thpe at simecol.de
Fri Jun 12 08:49:29 CEST 2009
insun nam wrote:
> Dear All,
>
> I like to simulate a physiologically based pharmacokinetics model using R
> but am having a problem with the daspk routine.
>
> The same problem has been implemented in Berkeley madonna and Winbugs so
> that I know that it is working. However, with daspk it is not, and the
> numbers are everywhere!
>
> Please see the following and let me know if I am missing something...
>
> Thanks a lot in advance,
> In-Sun
[ ... long example deleted, see original post ...]
Hi In-Sun,
as far as I see the *first* of your problems is your high demand on
precision. Double precision allows 16 digits, so 1e-10 may lead
internally to values that are close to the maximum number of digits in
double precision arithmetics, because you set relative *and* absolute
tolerance of all states to such a small value.
Reduce atol and rtol to reasonable values (e.g. the default of 1e-6) and
it should work (it does on my machine). Another possibility would be to
increase maxsteps, but this will not help if the requested precision is
higher than would be possible with double precision.
If you try the following:
ODE <- as.data.frame(daspk(y = y, times = times, func = Fun_ODE,
parms = pars, atol = 1e-6, rtol = 1e-6))
... then the simulation goes through in a technical sense, however state
variables reach very high values which, again, are beyond what is
possible with double precision arithmetics -- is this what you mean with
"the numbers are everywhere"?
Are you sure that your model formulation is correct? Please check your
equations, especially parentheses and signs.
Thomas Petzoldt
More information about the R-help
mailing list