sim: Simulate ODE or analytical equation

Description Usage Arguments Value See Also Examples

Description

Simulates a specified regimen using ODE system or analytical equation

Usage

1
2
3
4
5
6
7
8
9
sim(ode = NULL, analytical = NULL, parameters = list(), omega = NULL,
  omega_type = "exponential", res_var = NULL, seed = NULL,
  sequence = NULL, n_ind = 1, regimen = NULL, covariates = NULL,
  covariates_table = NULL, covariates_implementation = list(),
  A_init = NULL, only_obs = FALSE, obs_step_size = 1,
  int_step_size = 0.1, t_max = NULL, t_obs = NULL, t_tte = NULL,
  duplicate_t_obs = FALSE, extra_t_obs = TRUE, rtte = FALSE,
  checks = TRUE, verbose = FALSE, return_design = FALSE,
  output_include = list(parameters = FALSE, covariates = FALSE), ...)

Arguments

ode

function describing the ODE system

analytical

analytical equation (function)

parameters

model parameters

omega

vector describing the lower-diagonal of the between-subject variability matrix

omega_type

exponential or normal, specified as vector

res_var

residual variability. Expected a list with arguments 'prop', 'add', and/or 'exp'. NULL by default.

seed

set seed for reproducible results

sequence

if not NULL specifies the pseudo-random sequence to use, e.g. "halton" or "sobol". See 'mvrnorm2' for more details.

n_ind

number of individuals to simulate

regimen

a regimen object created using the regimen() function

covariates

list of covariates (for single individual) created using 'new_covariate()' function

covariates_table

data.frame (or unnamed list of named lists per individual) with covariate values

covariates_implementation

used only for 'covariates_table', a named list of covariate implementation methods per covariate, e.g. 'list(WT = "interpolate", BIN = "locf")'

A_init

vector with the initial state of the ODE system

only_obs

only return the observations

obs_step_size

the step size between the observations

int_step_size

the step size for the numerical integrator

t_max

maximum simulation time, if not specified will pick the end of the regimen as maximum

t_obs

vector of observation times, only output these values (only used when t_obs==NULL)

t_tte

vector of observation times for time-to-event simulation

duplicate_t_obs

allow duplicate t_obs in output? E.g. for optimal design calculations when t_obs = c(0,1,2,2,3). Default is FALSE.

extra_t_obs

include extra t_obs in output for bolus doses? This is only activated when 't_obs' is not specified manually. E.g. for a bolus dose at t=24, if FALSE, PKPDsim will output only the trough, so for bolus doses you might want to switch this setting to TRUE. When set to "auto" (default), it will be TRUE by default, but will switch to FALSE whenever 't_obs' is specified manually.

rtte

should repeated events be allowed (FALSE by default)

checks

perform input checks? Default is TRUE. For calculations where sim_ode is invoked many times (e.g. population estimation, optimal design) it makes sense to switch this to FALSE (after confirming the input is correct) to improve speed.

verbose

show more output

return_design

Useful for iterative functions like estimation. Only prepares the design (event table) for the simulation, does not run the actual simulation.

output_include

list specyfing what to include in output table, with keys 'parameters' and 'covariates'. Both are FALSE by default.

...

extra parameters

Value

a data frame of compartments with associated concentrations at requested times

See Also

sim_ode_shiny

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
## Not run: 
library(ggplot2)
library(PKPDsim)
p <- list(CL = 38.48,
         V  = 7.4,
         Q2 = 7.844,
         V2 = 5.19,
         Q3 = 9.324,
         V3 = 111)

r1 <- new_regimen(amt = 100,
             times = c(0, 24, 36),
             type = "infusion")

dat <- sim_ode (ode = "pk_3cmt_iv",
               par = p,
               regimen = r1)

ggplot(dat, aes(x=t, y=y)) +
 geom_line() +
 scale_y_log10() +
 facet_wrap(~comp)

# repeat with IIV:
omega <- c(0.3,       # IIV CL
          0.1, 0.3)  # IIV V

dat <- sim (ode = "pk_3cmt_iv",
               par = p,
               omega = omega,
               n_ind = 20,
               regimen = r1)

ggplot(dat, aes(x=t, y=y, colour=factor(id), group=id)) +
 geom_line() +
 scale_y_log10() +
 facet_wrap(~comp)

## End(Not run)

ronkeizer/PKPDsim documentation built on May 27, 2019, 1:50 p.m.