Learn R Programming

PKPDsim

PKPDsim is a library for numerical integration of ODE systems, in particular pharmacokinetic-pharmacodynamic (PK-PD) mixed-effects models.

Installation

The development version of PKPDsim always has the most up-to-date improvements and bug fixes. We aim to release PKPDsim on CRAN at least once a year, depending on the number and impact of updates made to the development version.

The CRAN version of PKPDsim can be installed using:

install.packages("PKPDsim")

The development version of PKPDsim can be installed using:

devtools::install_github("InsightRX/PKPDsim")

A number of models from the literature have been made available for use in PKPD simulations. To see which models are available for installation, run:

available_default_literature_models()

You can install these models as packages using the following commands:

# To install a single model:
install_default_literature_model("pk_busulfan_mccune")
# To install all supplied models:
install_default_literature_model("all")

Contributing

We welcome input from the community:

on the GitHub page. Please include a reproducible example of the unexpected behavior.

you have a fix or updates that would improve the package. If you're not sure if your proposed changes are useful or within scope of the package, feel free to contact one of the authors of this package.

Disclaimer

The functionality in this R package is provided "as is". While its authors adhere to software development best practices, the software may still contain unintended errors.

InsightRX Inc. and the authors of this package can not be held liable for any damages resulting from any use of this software. By the use of this software package, the user waives all warranties, expressed or implied, including any warranties to the accuracy, quality or suitability of InsightRX for any particular purpose, either medical or non-medical.

Copy Link

Version

Install

install.packages('PKPDsim')

Monthly Downloads

730

Version

1.4.0

License

MIT + file LICENSE

Issues

Pull Requests

Stars

Forks

Maintainer

Ron Keizer

Last Published

August 19th, 2024

Functions in PKPDsim (1.4.0)

TwoCompOral

First-order absorption- 2 compartment
calc_auc_analytic

Convenience function to calculate the AUC based on PK model parameters at any given moment, for linear iv models.
available_default_literature_models

See models from the literature available for installation
advan_process_infusion_doses

Add column RATEALL to ADVAN-style dataset to handle infusions
calc_ss_analytic

Returns the state of a linear PK system at steady state (trough) using analytics equations (so for linear PK systems only).
add_ruv

Add residual variability to the dependent variable
calculate_parameters

Calculate model-specific variables using a dummy call to sim_ode()
calc_dydP

Calculate derivative
bioavailability_to_R_code

Transforms bioavailability specs into appropriate R code
covariate_last_obs_only

Use only last observed covariate values
covariates_table_to_list

Convert covariate table specified as data.frame
apply_duration_scale

Apply infusion duration scale to a regimen
check_mixture_model

Check that mixture model is specified in right format and within constraints (1 parameter, 2 groups)
get_fixed_parameters

Get fixed parameters from model definition.
compile_sim_cpp

Compile ODE model to c++ function
get_ode_model_size

Get the number of states in the ODE from the code code C++ code for model
f_cov

covariate function builder
create_event_table

Create an event table
detect_ode_syntax

Auto-detect the syntax for the ODE code
get_model_info

Functions for getting information about a model
apply_lagtime

Apply lagtime to a regimen
check_obs_input

Checks obs input for valid combinations of cmt, var, scale
ifelse0

ifelse function but then based on whether value is NULL or not
get_parameters_from_code

Get model parameters from code
is_positive_definite

Is matrix positive definite
install_default_literature_model

Install default literature model
na_locf

Fill in NAs with the previous non-missing value
model_from_api

Load model definition from API, and compile to R library
model_library

Model library
is_newer_package

Check if package number is different from currently installed, and provide some messaging.
mvrnorm2

More powerful multivariate normal sampling function
analytical_eqn_wrapper

Wrapper for using analytical equations with PKPD regimens
check_iov_specification

Checks that IOV was specified appropriately
create_obs_data

Create obs data
lower_triangle_mat_size

Size of the lower triangle of the matrix
join_cov_and_par

Combines covariates and parameters into a single list, useful for reparametrization of the model.
join_regimen

Join two dosing regimens
nm_to_regimen

Create a regimen from NONMEM data
new_covariate_model

covariate model function
new_ode_model

Create new ODE model
print.regimen

Print function for PKPDsim regimen
get_t_obs_from_regimen

Extract sensible default observation times from a specified regimen
get_var_y

Get expected variance/sd/ci of dependent variable based on PKPDsim model, parameters, and regimen
new_adherence

Probabilistically model adherence
cv_to_omega

Create lower-diagonal omega matrix from CV for parameter estimates
search_replace_in_file

Find string and replace in file
reparametrize

Reparametrize model parameters using a reparametrization defined within the model.
nlmixr_parse_parameters

Function to parse parameters for a model into a structure used by nlmixr
new_regimen

Dose regimen for sim_ode
new_covariate

New covariate
read_model_json

Read model definition from JSON
merge_regimen

Merge two regimens together.
pkdata

PK dataset
print.PKPDsim

Print function for PKPDsim simulation function
parse_obs_types

Parse observation types to simulation code
define_tdm_init_model

defines C code for TDM before dose conditions
table_to_list

Convert a table to a list
pop_regimen

Remove n doses (from tail) of PKPDsim regimen
triangle_to_full

Convert triangle omega matrix to full omega matrix
vector_to_R_code

Transform a vector into a string that evaluates to the same vector
pkpdsim_to_nlmixr

Convert a model generated with PKPDsim to an object for nlmixr
print_list

Return a list in R syntax
sim_ode

Deprecated function, renamed to sim()
test_model

Test a model
sim_ode_shiny

Simulate ODE and create a Shiny app
sim_core

Only core function of the simulation function, always just returns observations. Mostly useful for estimations / optimal design. Has no checks (for speed)!
sim

Simulate ODE or analytical equation
print.covariate

Print function for PKPDsim covariate object
regimen_to_nm

Convert PKPDsim regimen to NONMEM table (doses only)
shift_regimen

Remove n doses (from start) of PKPDsim regimen
shift_state_indices

R starts counting vector indices at 1, c++ starts at 0, so reduce all state numbers in the Cpp function definition by 1
test_pointer

Test if model still in memory
now_utc

Current time in UTC
translate_ode

Translate a model from/to various PKPD simulators
ThreeCompIVinfusionMetab

3-compartment IV infusion with first-order metabolite formation
add_quotes

Put vector values in quotes
add_ruv_to_quantile

Calculate the increase in a specific quantile for a distribution on y when residual variability is added
adherence_markov

Markov adherence model
adherence_binomial

Binomial adherence
ThreeCompIVinfusion

IV infusion- 3 compartment
OneCompIVbolus

ADVAN-style equations
ThreeCompIVbolus

IV bolus- 3 compartment
TwoCompIVbolus

IV bolus- 2 compartment
PKPDsim-package

PKPDsim package
TwoCompIVinfusion

IV infusion- 2 compartment
OneCompOral

first-order absorption 1 compartment
ThreeCompOralMetab

first-order absorption- 3 compartment-Metabolite
OneCompIVinfusion

IV infusion- 1 compartment
ThreeCompOral

first-order absorption- 3 compartment
advan

ADVAN-style functions to calculate linear PK systems
advan_create_data

Create ADVAN-style dataset
advan_parse_output

Internal function to parse the raw output from ADVAN-style functions