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)
a string to specify the type of the data ("population" or "individual").
the name of an R data frame that serves as the source data. If not provided, the next argument
data.file
will be checked to locate the data in the system.
a string to specify the path of the data file. It will be ignored if the previous argument
data.source
is already provided; but it will be required if data.source
is not provided.
a PMXStanModel
object that will be fitted to the current dataset.
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.
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
obs.vs.pred
and rsd.vs.pred
for a PMXStanFit
object), or both.
The returned list contains four elements:
a string indicating the data type for future reference; the same as the argument data.type
.
a list by itself to be fed into the model-specific Stan code.
a vector of IDs whose observations have been included in standata
above. Note that a proof checking
step has been performed to make sure that every subject included in Stan input data has both valid dosing and
observation records; therefore, this set of ID
's might be the same as those in the original data table,
but it might also be a subset only. The purpose of this step is to avoid errors at the future sampling step due
to lack of dosing records or observations.
a data frame with columns of subject IDs and values for each selected covariates defined by the covar
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.
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.
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.
# NOT RUN {
m <- PMXStanModel(path = tempfile("pk_m1"))
data("examples_data")
dat <- prepareInputData(data.source = d1_nm_poppk, model = m)
str(dat)
# }
Run the code above in your browser using DataLab