Generate multiple data sets and Fit using Simple PopPK Model
The tutorial example above generates a single data set from user specified true f[X] values. In PoPy it is possible to generalise this approach and sample true f[X] values multiple times to create multiple data sets. Then fit the same model to each data set.
In this section we walk through how to generate multiple data sets using a MTut Script, using the same simple one compartment model as shown in fig_simple_popkp_diagram_tut.
Running the MTut Script
This multi tutorial example makes use of a single script file, c:\PoPy\examples\mtut_example1.pyml
PoPy Terminal to setup the PoPy environment in the folder c:\PoPy\examples\
With the PoPy environment enabled, you can call popy run on the MTut Script from the command line:-
popy run mtut_example1.pyml
to run the script.
Running a MTut Script can take a considerable amount of time, as it is equivalent to running a Tut Script multiple times.
However in this toy example we only run the fit/gen cycle 30 times and only a small number of the f[X] parameters are estimated.
Syntax of MTut Script
The MTut Script specifies the number of populations to sample as follows:-
OUTPUT_OPTIONS: {n_pop_samples: 30}
The MTut Script encodes both the data generation and fitting in the GEN_EFFECTS and FIT_EFFECTS sections, like a Tut Script. The syntax is the same. In this example the GEN_EFFECTS section is as follows:-
GEN_EFFECTS:
POP: |
c[AMT] = 100.0
# f[KE] = 0.1
f[KE] ~ unif(0.05,0.15)
# f[PNOISE] = 0.05
f[PNOISE] ~ unif(0.02,0.08)
# f[KE_isv] = 0.03
f[KE_isv] ~ unif(0.01,0.05)
ID: |
c[ID] = sequential(20)
t[DOSE] = 1.0
t[OBS] ~ unif(1.0, 50.0; 5)
r[KE] ~ norm(0, f[KE_isv])
And the FIT_EFFECTS section is as follows:-
FIT_EFFECTS:
POP: |
# f[KE] ~ unif(0.001, 100) 0.05
f[KE] ~ P 0.1
# f[PNOISE] ~ unif(0.001, 100) 0.1
f[PNOISE] ~ P 0.05
# f[KE_isv] ~ unif(0.001, 100) 0.1
f[KE_isv] ~ P 0.03
ID: |
r[KE] ~ norm(0, f[KE_isv])
Here the generated values of f[KE], f[PNOISE] and f[KE_isv] are sampled from uniform distributions. The fitting process is initialised with (constant) values in the centre of the uniform distribution, used to sample the generating fixed effect values.
Summary of MTut Results
The MTut Script should generate an output folder containing three new scripts:-
mtut_example1.pyml_output/
mtut_example1_mgen.pyml
mtut_example1_mfit.pyml
mtut_example1_mcomp.pyml
The purpose of each of theses scripts is as follows:-
Script |
Purpose |
Documentation |
|---|---|---|
*_mgen.pyml |
Generate multiple synthetic data sets from model |
|
*_mfit.pyml |
Fit model to multiple synthetic data sets |
|
*_mcomp.pyml |
Compare gen model and fit model |
The MGen Script is very similar to the Gen Script described in Syntax of Tut Script and the MFit Script is very similar to the Fit Script described in Fitting a Simple PopPK Model using PoPy. See Files Generated by MTut Script for more info.
Here we mainly discuss the MComp Script outputs, which processes the results of MGen Script and MFit Script. The simplest output is a visual comparison of the true and fitted f[X] values as shown in Table 28.
In Table 28 the blue dots are a scatter plot of fitted f[X] vs true f[X]. The green dots are initial f[X] vs true f[X]. For example in the case of f[KE] the true values are sampled as follows:-
f[KE] ~ unif(0.05,0.15)
i.e. the true values are uniformly sampled in the range [0.05,0.15]. The fitted f[KE] parameters are modelled as follows:-
f[KE] ~ P0.1
The initial values for f[KE] are always 0.1, see green dots in a horizontal line on the left graph in Table 28. The ‘P’ specifies that the fitting value of f[KE] is restricted to positive numbers. The final fitting values are the blue dots on the left graph in Table 28. For f[KE] the blue dots are clustered along the black 45 degree line. Hence fitting for f[KE] works well, this agrees with the initial findings in Fitting a Simple PopPK Model using PoPy. The blue dots for f[KE_isv] and f[PNOISE] (centre and right graphs in Table 28) are not as tightly clustered around the 45 degree line, indicating these parameters are harder to identify than f[KE]. However both f[KE_isv] and f[PNOISE] show a reasonable correlation between the true and fitted values.
Note it might well be possible to carry out a more statistical analysis of correlation between the true and fitted f[X], for example finding a line of best fit through the scatter plot data. The MComp Script outputs are all saved to .csv files, see Files Generated by MComp Script, which could easily be loaded into R or other statistical packages for further analysis.