PMXStanModel | R Documentation |
PMXStanModel
objectInitializes an object of class PMXStanModel
with methods for generating and compiling Stan code and
querying model specifications.
PMXStanModel(type = "PK", path = "model_temp", route = "1st_order_abs", solver = NULL, ode = NULL, pk.struct = "2-cmpt", pk.param = "CL_V", obs.state = NULL, theta = NULL, eta = NULL, fixed = NULL, compile = FALSE)
type |
a string to specify the type of model: "PK" (default) or "PKPD". |
path |
a string to specify the path that will be used to store the model, Stan input data, and model fitting and diagnostic results. |
route |
a string to specify mode of drug administration: "1st_order_abs" (default), "IV_bolus", or "IV_infusion". |
solver |
a string to specify which solver to be used for a PK model: "closed_form" (default) or "ODE"; ignored for PKPD models in ODE form. |
ode |
a string to specify equations of the ODE system for a PKPD model; ignored for PK models. |
pk.struct |
a string to specify the PK model structure: "1-cmpt", "2-cmpt" (default), or "3-cmpt"; ignored for PKPD models in ODE form. |
pk.param |
a string to specify the method for PK model parameterization: "CL_V" (default), or "micro_rate"; ignored for PKPD models in ODE form. |
obs.state |
an integer to specify the index of the state variable corresponding to observed data for a PKPD model in ODE form; ignored for PK model with closed-form solution, but required for PKPD models. |
theta |
a string or vector of strings to specify which parameters will be estimated for a PKPD model in ODE form;
ignored for PK model with closed-form solution, but cannot be |
eta |
a string or vector of strings to specify which parameters will have inter-individual variability for a PKPD model
in ODE form; ignored for PK model with closed-form solution, and can be |
fixed |
a vector of strings to specify which parameter values will be fixed at constants for a PKPD model in ODE
form; ignored for PK model with closed-form solution, and can be |
compile |
a logical variable indicating whether to compile the generated Stan code during the initialization
process ( |
PMXStanModel
serves as an interface for practical PK/PD modeling using Stan under a Bayesian framework.
The first step of building such a model is for a user to provide model specifications (for more details on
specification arguments and default values, please refer to the Arguments section). With a proper set of
specifications, a model-specific Stan source code is then generated based on a generic template code for the
associated model type. Users then can choose to compile the auto-generated Stan source code directly
to a self-contained platform-specific executable, or to modify the Stan source code according to their own modeling
strategies before compiling it to an executable.
The template Stan code serves at least two purposes. First, it presents a grammar-corrected ready-to-be-used code
that already takes care of most technical details necessary to build such a model in Stan; secondly, it makes sure
that everything needed for running Stan sampling is internally consistent, from preparing the compatible data list,
interpreting various dosing events and schedule, to calling the appropriate solver. In a template Stan code, model
parameters to be estimated are defined as theta
's and inter-individual variabilities for parameters are defined
as eta
's, to follow the conventions in pharmacometrics practice. All priors are set as non-informative.
It needs to be kept in mind that the code is fully accessible and modifiable by a user; therefore, a user can add
his/her own customized code by changing certain part of the auto-generated code conveniently. The modified Stan code
can be re-compiled at any time as long as the changes made by users comply with standard Stan grammar. It is suggested
that in these cases, a user begins with making small changes and testing the compilation (as well as compatibility with
the input data if necessary) gradually before going to more significant modifications.
A PMXStanModel
object, with the following list of methods:
get.model.specs |
returns model specification. |
generate.stancode |
generates Stan code according to model specification. |
get.state.var |
returns names of state variables in the ODE system. |
get.ode.par |
returns names of parameters in the ODE system. |
get.ntheta |
returns number of parameters to be estimated for an ODE-based PKPD model. |
get.neta |
returns number of inter-individual variabilities set by user for an ODE-based PKPD model. |
get.stan.file |
returns path of the auto-generated Stan file. |
compile.stanmodel |
compiles the Stan file, either auto-generated (default) or with a path specified by user.
This function has a generic form |
get.compile.status |
returns a logical indicator whether the model-associated Stan file has been compiled or not. |
retrieve.stanmodel |
returns the compiled Stan model. |
print.model |
returns the compiling status and the path of the model-associated Stan file, as well as model specifications.
This function has a generic form |
Yuan Xiong and Wenping Wang
The Stan Development Team. Stan Modeling Language User's Guide and Reference Manual. https://mc-stan.org.
prepareInputData
for transformation of a NONMEM-readable dataset to a list compatiable to auto-generated
model-specific Stan code;
PMXStanFit
for how to run the compiled Stan executable for the model, link it with the input data and
generate posterior samples of parameters, and perform model diagnostics;
rstan-stanmodel
for a class specifically referred to the compiled model.
## Not run: ### A population PK model m1 <- PMXStanModel(path = tempfile("pk_m1"), compile = TRUE) print(m1) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.