Simulation of Individuals

Sometimes you may want to match the dosing and observations of
individuals in a clinical trial. To do this you will have to create a
data.frame using the RxODE event specification as well as an ID
column to indicate an individual. The RxODE event vignette talks more about
how these datasets should be created.

If you have a NONMEM/Monlix dataset and the package
nlmixr, you can convert the NONMEMdataset to aRxODEcompatible dataset to
use for simulation with thenmDataConvert function.

Instead of using nlmixr for this simple example, I will combine two
RxODE event tables.

Simulation of Clinical Trials

By either using a simple single event table, or data from a clinical
trial as described above, a complete clinical trial simulation can be
performed.

Typically in clinical trial simulations you want to account for the
uncertainty in the fixed parameter estimates, and even the uncertainty
in both your between subject variability as well as the unexplained
variability.

RxODE allows you to account for these uncertainties by simulating
multiple virtual “studies,” specified by the parameter nStud. In a
single virtual study:

A Population effect parameter is sampled from a multivariate normal
distribution with mean given by the parameter estimates and the
variance specified by the named matrix thetaMat.

A between subject variability/covariance matrix is sampled from
either a scaled inverse chi-squared distribution (for the univariate
case) or a inverse Wishart that is parameterized to scale to the
conjugate prior covariance term, as described by
the
wikipedia article. (This
is not the same as
the
scaled inverse Wishart distribution ).
In the case of the between subject variability, the
variance/covariance matrix is given by the 'omega' matrix parameter
and the degrees of freedom is the number of subjects in the
simulation.

Unexplained variability is also simulated from the scaled inverse
chi squared distribution or inverse Wishart distribution with the
variance/covariance matrix given by the 'sigma' matrix parameter and
the degrees of freedom given by the number of observations being
simulated.

The covariance/variance prior is simulated from RxODEs cvPost function.

Note since realizations of omega and sigma were not simulated, $omega.list and
$sigma.list both return NULL.

RxODE multi-threaded solving and simulation

RxODE now supports multi-threaded solving on OpenMP supported
compilers, including linux and windows. Mac OSX can also be supported
but
takes
additional setup.
By default it uses all your available cores for solving as determined
by rxCores(). This may be overkill depending on your system, at a
certain point the speed of solving is limited by things other than
computing power.

You can also speed up simulation by using the multi-cores to generate
random deviates with mvnfast. This is controlled by the nCoresRV
parameter. For example:

The default for this is 1 core since the result depends on the
number of cores and the random seed you use in your simulation.
However, you can always speed up this process with more cores if you
are sure your collaborators have the same number of cores available to
them and have OpenMP thread-capable compile.