prepareInputData | R Documentation |
Prepares input data (a list) for the model-specific Stan code from a conventional PK/PD dataset for NONMEM (usually a table in .txt or .csv format).
prepareInputData(data.type = "population", data.source = NULL, data.file = NULL, model = NULL, inits = NULL, covar = NULL)
data.type |
a string to specify the type of the data ("population" or "individual"). |
data.source |
the name of an R data frame that serves as the source data. If not provided, the next argument
|
data.file |
a string to specify the path of the data file. It will be ignored if the previous argument
|
model |
a |
inits |
a string providing the colume name of initial values of the observed state variable for each individual in the current dataset, or a numerical vector of initial values for each individual. |
covar |
a string or a vector of strings providing colume name(s) of covariate(s) in the current dataset,
which needs to be used either in model building or post-processing (e.g. goodness-of-fit plotting
|
prepareInputData
rewrites a table consisting of relevant columns according to NONMEM conventions to a list
consisting of named vectors compatible to the auto-generated model-specific Stan code. It also allows users to specify
column names for initial values of the observed state variable for an ODE system, and column names for relevant
covariates that will be explored more through modeling or post-processing.
Currently, prepareInputData
takes two different formats (.txt or .csv) of a NONMEM data file. The minimally
required columns in this data file are: TIME
, DV
, AMT
,and EVID
. If data.type
is set
to "population", a column ID
is also required. If the route of drug administration is set to "IV_infusion"
(through argument route
for PMXStanModel
), a column RATE
is also required.
For more details on the data structure of the returned list, please see Value section.
The returned list contains four elements:
data.type |
a string indicating the data type for future reference; the same as the argument |
standata |
a list by itself to be fed into the model-specific Stan code. |
ID |
a vector of IDs whose observations have been included in |
d.cov |
a data frame with columns of subject IDs and values for each selected covariates defined by the |
A special consideration should be noted when handling data from a single subject, i.e. when data.type
is set to
"individual". Due to the strict requirement with data type specification in Stan grammar and the underlying mechanisms
how C++ handles different data types, to avoid the comlexity caused by data from a single subject, a "dummy" subject
has been attached in these cases, with a single dose of 0 and the initial observation set the same as the real subject.
Yuan Xiong and Wenping Wang
list
for general information on R
lists;
PMXStanModel
for the initialization of a PMXStanModel
object;
PMXStanFit
for the generation of a PMXStanFit
object, running a model-specific Stan executable
and linking to an input data list to generate posterior samples of parameters.
m <- PMXStanModel(path = tempfile("pk_m1")) data("examples_data") dat <- prepareInputData(data.source = d1_nm_poppk, model = m) str(dat)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.