Aims: ADVAN-style analytical solutions for 1, 2, 3 compartment linear pharmacokinetic models of intravenous bolus, infusion, and first-order absorption have been derived and published by Abuhelwa et al., 2015 (1). The analytical solutions are used to simulate the time-course of drug amounts in the compartments of a pharmacokinetic models and they “advance” the solution of the model from one time point to the next, allowing for any dose or time-varying covariate factors to be accounted for. The ADVAN-style analytical solutions were coded in the R programming language (2) and have been shown to have speed advantages over solutions using differential equation solvers (1). The aims of this study were to enhance the computational speed of the ADVAN-style analytical functions for faster simulation processing, present the ADVAN-style analytical functions in an R package, “PKADVAN” package, and make them available for the wider audience, and expand the “PKADVAN” package library to include other pharmacokinetic models such as transit first-order absorption and metabolite models.
Methods: ADVAN-style analytical solutions were written in the C++ programming language and were integrated in R using the Rcpp package attributes (3). The integrated R/C++ ADVAN-style analytical functions were built into an open-source R package (“PKADVAN” package). To assess computational speed, simulations for 1000 subjects using three compartment IV bolus, infusion, and first-order absorption models were performed and compared to relative computational speed of the equivalent R-coded functions. For each subject, two doses were simulated with the evaluations performed at 1 hour time intervals for 2 days.
Results: A total of 26 pharmacokinetic models were incorporated into the “PKADVAN” package library including the basic models published by Abuhelwa et al (1). Simulations using the integrated R/C++ ADVAN-style analytical solutions performed substantially faster than the equivalent R-coded functions. The integrated R/C++ functions simulated data for 1000 subjects in ~1 second, which was 8 18 times faster than the equivalent R-coded functions. The relative speed of the integrated R/C++ functions was greater with the more complex models and with more extensive sample time evaluations. For example, simulations from the 3 compartment first-order absorption model using the integrated R/C++ function were ~34 times faster than the R-coded function when the same dosing regimen simulations were extended for 5 days. The “PKADVAN” package is available at GitHub and can be downloaded from the following link ( https://github.com/abuhelwa/PKADVAN_Rpackage ).
Conclusion: A main application for the integrated R/C++ functions is for simulation from stochastic population pharmacokinetic models coded in R and incorporated into reactive Shiny Web applications. The speed of the integrated R/C++ analytical solutions is important here as they allow for simulating larger populations (e.g. 1000 subjects) without compromising the reactivity of the Shiny application. The integrated R/C++ functions could be incorporated into an open-source mixed-effect modelling framework to estimate population parameters where speed is always desirable. With their capacity to handle complex dosing regimens and covariate structures, the “PKADVAN” package is expected to facilitate the investigation of useful open-source software for modelling and simulating pharmacokinetic data.
1. Abuhelwa AY, Foster DJ, Upton RN. 2015. ADVAN-style analytical solutions for common pharmacokinetic models. J Pharmacol Toxicol Methods 73:42-48.
2. R Core Team. 2014. R: A Language and Environment for Statistical Computing R Foundation for Statistical Computing, Vienna, Austria
3. Eddelbuettel D, François R, Allaire J, Chambers J, Bates D, Ushey K. 2011. Rcpp: Seamless R and C++ integration. Journal of Statistical Software 40:1-18.