Skip to contents

Create a new stan model using a template

Usage

new_stan_model(
  parameters,
  parameter_definitions,
  fixed = NULL,
  variable_definitions = NULL,
  ode = NULL,
  covariate_definitions = NULL,
  solver = c("pmx_solve_onecpt", "pmx_solve_twocpt", "pmx_solve_rk45", "pmx_solve_adams",
    "pmx_solve_bdf"),
  template = "template.stan",
  obs_types = NULL,
  obs_cmt = NULL,
  scale = NULL,
  custom_ipred = NULL,
  verbose = FALSE
)

Arguments

parameters

list of parameter values, e.g. list(CL = 5, V = 50).

parameter_definitions

list of parameter definitions. See example below.

fixed

optional, vector of parameters to fix and not sample.

variable_definitions

for models using the analytical solvers, extra variable definitions evaluated at each step through the event table. See busulfan example in vignettes for example.

ode

code for differential equation system, if not the analytic solver is used.

covariate_definitions

list of covariate definitions. See example below.

solver

Torsten solver to use. Starts with pmx_solve_.

template

internal Stan template file to use. Defaults to template.stan

obs_types

vector of observed data types. If NULL, will use "pk".

obs_cmt

observation compartment, or list of observation compartments for each observation type when multiple observation types. E.g. 2 or list(pk = 2, pd = 8).

scale

scale definition. Can be either parameter expression or number.

custom_ipred

list of custom definitions for individual predictions for each observation type. Sometimes this is needed when more flexibility is needed than the scale parameter provides.

verbose

verbosity

Value

filename

Examples


parameters <- list(CL = 5, V1 = 50, Q = 5, V2 = 100)
iiv <- list(CL = 0.27, Q = 0.49, V1 = 0.15, V2 = 1.3)
ruv <- list(add = 1.6, prop = 0.15)

model_file <- new_stan_model(
  parameters = parameters,
  parameter_definitions = list(
   "CL" = "CL * (1.0 + 0.0154 * ((CRCL[j] * 16.6667) - 66.0))",
   "Q"  = "Q",
   "V1" = "V1 * WT[j]",
   "V2" = "V2 * WT[j]",
   "KA" = "0" 
  ),
  covariate_definitions = list(
    "CRCL" = "real", # CrCl in L/hr
    "WT" = "real"    # WT in kg
  ),
  solver = "pmx_solve_twocpt",
  obs_cmt = 2,
  scale = "(V1 * mean(WT))",
  verbose = TRUE
)
#> assuming scale definition (V1 * mean(WT)) for all observation types
#> assuming observation type 2 for all observation types