[Rcpp-devel] Using Rcpp to solve ODEs: LSODE (deSolve) says "Confusion over the length of parms"
Kyle Baron
kyleb at metrumrg.com
Mon Jan 23 19:34:57 CET 2017
Frank -
In the code you provided, it looks like it is "poped.db.compiled.rcpp", not
"poped.db.compiled".
I found that, after making the change to fix the error that Dirk pointed
out, the code appears to work with no error (attached). I don't know if
the results are what you were intending, however.
Also: I would not set up the optimization like this. When you create
the one_comp_oral_ode function with cppFunction and hand that off to
deSolve, you are still passing along an R function to get called. Even if
the calculations are accomplished with Rcpp, it still an R function. So
every step the solver takes, it will have to call an R function. I don't
think this is what you want. When you write the ode function as suggested
by the deSolve package vignette, you pass off the name of a C function and
the solver calls that C function directly as the system advances. It will
be faster than what you are doing with cppFunction.
Finally, I'll ask if you have looked at one of the more-modern simulation
packages for R that are designed for PK/PD work?
I maintain mrgsolve: https://github.com/metrumresearchgroup/mrgsolve
You could also look at RxODE: https://cran.r-project.
org/web/packages/RxODE/index.html
Hope that helps ...
Kyle
On Sun, Jan 22, 2017 at 7:50 PM, Dirk Eddelbuettel <edd at debian.org> wrote:
>
> Frank,
>
> That's a pretty long message and a lot of code. Can you try to distill it
> down to a particular (smaller?) issue?
>
> And FWIW I cannot run. After saving your attachment, and installing PopED,
> I
> get
>
> R> source("/tmp/myExampleODE.compiled.R")
>
> Attaching package: ‘deSolve’
>
> The following object is masked from ‘package:graphics’:
>
> matplot
>
> Elapsed time: 10.425 seconds.
> Error in poped.db$settings$optsw[2] <- opt_xt :
> object 'poped.db.compiled' not found
> R>
>
> I also recommend the rbenchmark and microbenchmark packages over tic() and
> toc().
>
> Sorry that I have no quick fix.
>
> Dirk
>
> --
> http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org
> _______________________________________________
> Rcpp-devel mailing list
> Rcpp-devel at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
--
Kyle Baron
Metrum Research Group
860-735-7043, Ext. 202
kyleb at metrumrg.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20170123/32cf39a0/attachment.html>
More information about the Rcpp-devel
mailing list