This example script is intended to illustrate how to use the 'ddmore' R package to perform a M&S workflow using the DDMoRe Standalone Execution Environment (SEE).
The following steps are implemented in this workflow:
To run a task, select wiht the coursor any code lines you wish to execute and press CTRL+R+R in your keyboard. An HTML file containing the commands in this file and associated output will be provided to allow the user to compare the results
Clear workspace and set working directory under 'UsesCasesDemo' project
rm(list=ls(all=F))
mydir <- file.path(Sys.getenv("MDLIDE_WORKSPACE_HOME"),"UseCasesDemo")
setwd(mydir)
Create a working directory under 'models' folder where results are stored
uc<-"UseCase4_3"
datafile <- "warfarin_infusion_oral.csv"
mdlfile <- paste0(uc,".mdl")
Create a new folder to be used as working directory and where results will be stored
wd <- file.path(mydir,uc)
dir.create(wd)
## Warning in dir.create(wd):
## 'D:\SEE-Prod5_RC4\MDL_IDE\workspace\UseCasesDemo\UseCase4_3' already
## exists
Copy the dataset and the .mdl file available under “models” into the working directory
file.copy(file.path(mydir,"models", datafile),wd)
## [1] TRUE
file.copy(file.path(mydir,"models",mdlfile),wd)
## [1] TRUE
Set the working directory.
setwd(file.path(mydir,uc))
The working directory needs to be set differently when knitr R package is used to spin the file
library(knitr)
opts_knit$set(root.dir = file.path(mydir,uc))
List files available in working directory
list.files()
## [1] "GOF_MLX.pdf" "GOF_NM_FOCEI.pdf"
## [3] "Monolix" "NONMEM_FOCEI"
## [5] "UseCase4_3.mdl" "UseCase4_3.xml"
## [7] "UseCase4_3_FOCEI.mdl" "UseCase4_3_tr.txt"
## [9] "UseCase4_3_VPC.mdl" "UseCase4_3_VPC.pdf"
## [11] "VPC" "warfarin_infusion_oral.csv"
mlx <- estimate(mdlfile, target="MONOLIX", subfolder="Monolix")
## -- Thu Aug 18 08:14:08 2016
## New
## Submitted
## Job 8a809baf-1f2a-4aa8-a394-bb0f6ae97a88 progress:
## Running [ ......... ]
## Importing Results
## Copying the result data back to the local machine for job ID 8a809baf-1f2a-4aa8-a394-bb0f6ae97a88...
## From C:\Users\zparra\AppData\Local\Temp\RtmpSKgKTU\DDMORE.job1dec29ad20c2 to D:/SEE-Prod5_RC4/MDL_IDE/workspace/UseCasesDemo/UseCase4_3/Monolix
## Done.
##
##
## The following main elements were parsed successfully:
## ToolSettings
## RawResults
## Estimation::PopulationEstimates::MLE
## Estimation::PrecisionPopulationEstimates::MLE
## Estimation::IndividualEstimates::Estimates
## Estimation::IndividualEstimates::RandomEffects
## Estimation::Residuals::ResidualTable
## Estimation::Predictions
## Estimation::OFMeasures::IndividualContribToLL
## Estimation::OFMeasures::InformationCriteria
## Estimation::OFMeasures::LogLikelihood
##
## Completed
## -- Thu Aug 18 08:17:15 2016
slotNames(mlx)
## [1] "ToolSettings" "RawResults" "TaskInformation"
## [4] "Estimation" "ModelDiagnostic" "Simulation"
## [7] "OptimalDesign" ".pathToSourceXML"
The ddmore “LoadSOObj” reads and parsed existing Standardise Output Objects
# mlx <- LoadSOObject("Monolix/UseCase4_3.SO.xml")
The ddmore function “getPopulationParameters” extracts the Population Parameter values from an R object of (S4) class “StandardOutputObject” and returns the estimates. See documentation for getPopulationParameters to see other arguments and settings for this function.
parameters_mlx <- getPopulationParameters(mlx, what="estimates")
print(parameters_mlx)
## $MLE
## POP_V BETA_V_WT POP_KA POP_CL BETA_CL_WT POP_TLAG
## 7.98883 1.00000 0.35758 0.10082 0.75000 1.00247
## POP_FORAL PPV_V PPV_KA PPV_CL PPV_TLAG PPV_FORAL
## 0.99160 0.12470 0.07619 0.11930 0.10000 0.32991
## CORR_CL_V RUV_ADD RUV_PROP
## 0.03330 0.00000 0.12281
print(getPopulationParameters(mlx, what="precisions"))
## $MLE
## Parameter MLE SE RSE
## 1 BETA_CL_WT 0.75000 0.00000 0.00
## 2 BETA_V_WT 1.00000 0.00000 0.00
## 3 CORR_CL_V 0.03330 0.18907 567.86
## 4 POP_CL 0.10082 0.00222 2.21
## 5 POP_FORAL 0.99160 0.01030 1.04
## 6 POP_KA 0.35758 0.01258 3.52
## 7 POP_TLAG 1.00247 0.02850 2.84
## 8 POP_V 7.98883 0.18518 2.32
## 9 PPV_CL 0.11930 0.01583 13.27
## 10 PPV_FORAL 0.32991 16.10903 4882.78
## 11 PPV_KA 0.07619 0.04729 62.07
## 12 PPV_TLAG 0.10000 0.00000 0.00
## 13 PPV_V 0.12470 0.01684 13.51
## 14 RUV_ADD 0.00000 0.02167 5739954.00
## 15 RUV_PROP 0.12281 0.00458 3.73
print(getEstimationInfo(mlx))
## $OFMeasures
## $OFMeasures$LogLikelihood
## $OFMeasures$LogLikelihood[[1]]
## [1] -1336.86
##
##
## $OFMeasures$IndividualContribToLL
## Subject ICtoLL
## 1 1 -34.19
## 2 2 -36.09
## 3 3 -27.25
## 4 4 -46.05
## 5 5 -43.52
## 6 6 -46.11
## 7 7 -37.45
## 8 8 -42.92
## 9 9 -34.60
## 10 10 -59.68
## 11 11 -42.45
## 12 12 -41.58
## 13 13 -49.62
## 14 14 -44.32
## 15 15 -48.82
## 16 16 -42.70
## 17 17 -39.41
## 18 18 -45.19
## 19 19 -41.56
## 20 20 -46.66
## 21 21 -40.62
## 22 22 -36.42
## 23 23 -51.37
## 24 24 -45.40
## 25 25 -43.13
## 26 26 -45.22
## 27 27 -39.98
## 28 28 -37.67
## 29 29 -32.96
## 30 30 -33.57
## 31 31 -45.91
## 32 32 -34.42
##
## $OFMeasures$InformationCriteria
## $OFMeasures$InformationCriteria$AIC
## [1] 2697.72
##
## $OFMeasures$InformationCriteria$BIC
## [1] 2715.31
##
##
##
## $Messages
## list()
Use 'ddmore' function as.xpdb() to create an Xpose database object from the Standardised Output object, regardless of target software used for estimation.
mlx.xpdb<-as.xpdb(mlx,datafile)
##
## Removed dose rows in rawData slot of SO to enable merge with Predictions data.
We can then call Xpose functions referencing this mlx.xpdb object as the input. Perform some basic goodness of fit
print(basic.gof(mlx.xpdb))
print(ind.plots(mlx.xpdb))
Export results to PDF file
pdf("GOF_MLX.pdf")
print(basic.gof(mlx.xpdb))
print(ind.plots(mlx.xpdb))
dev.off()
## rj.GD
## 2
MDL Objects can be manipulated from R to change for example the estimation algorithm
myTaskProperties <- getTaskPropertiesObjects(mdlfile)[[1]]
myNewTaskProperties <- myTaskProperties
myNewTaskProperties@ESTIMATE$algo <- "focei"
Assembling the new MOG. Note that we reuse the data and model from the previous run.
myNewerMOG <- createMogObj(dataObj = getDataObjects(mdlfile)[[1]],
parObj = getParameterObjects(mdlfile)[[1]],
mdlObj = getModelObjects(mdlfile)[[1]],
taskObj = myNewTaskProperties)
We can then write the MOG back out to an .mdl file.
mdlfile.FOCEI <- paste0(uc,"_FOCEI.mdl")
writeMogObj(myNewerMOG,mdlfile.FOCEI)
Test estimation using this new MOG in NONMEM.
NM.FOCEI <- estimate(mdlfile.FOCEI, target="PsN", subfolder="NONMEM_FOCEI")
## -- Thu Aug 18 08:17:46 2016
## New
## Submitted
## Job 369c0c57-4369-4b5c-b0b5-04f26b9eb072 progress:
## Running [ ................................................................................................................................................................................................... ]
## Importing Results
## Copying the result data back to the local machine for job ID 369c0c57-4369-4b5c-b0b5-04f26b9eb072...
## From C:\Users\zparra\AppData\Local\Temp\RtmpSKgKTU\DDMORE.job1dec106b13ef to D:/SEE-Prod5_RC4/MDL_IDE/workspace/UseCasesDemo/UseCase4_3/NONMEM_FOCEI
## Done.
##
##
## The following main elements were parsed successfully:
## RawResults
## Estimation::PopulationEstimates::MLE
## Estimation::IndividualEstimates::Estimates
## Estimation::IndividualEstimates::RandomEffects
## Estimation::Residuals::ResidualTable
## Estimation::Predictions
## Estimation::OFMeasures::Deviance
##
## The following WARNINGs were raised during the job execution:
## estimation_successful: 0
## zero_gradients: 14
## final_zero_gradients: 9
## estimate_near_boundary: 1
##
## The following MESSAGEs were raised during the job execution:
## covariance_step_run: 0
## rounding_errors: 0
## hessian_reset: 0
## s_matrix_singular: 0
## nmoutput2so_version: This SOBlock was created with nmoutput2so version 4.5.27
##
## Completed
## -- Thu Aug 18 09:23:05 2016
Load previous results
# NM.FOCEI <- LoadSOObject("NONMEM_FOCEI/UseCase4_3_FOCEI.SO.xml")
Results from NONMEM should be comparable to previous results
print(getPopulationParameters(NM.FOCEI, what="estimates"))
## $MLE
## POP_CL POP_V POP_KA POP_TLAG POP_FORAL RUV_PROP
## 8.20411e-02 8.64035e+00 4.61000e-03 5.02600e-02 9.99463e-01 3.47970e-01
## RUV_ADD BETA_CL_WT BETA_V_WT PPV_CL CORR_CL_V PPV_V
## 1.11745e-03 7.50000e-01 1.00000e+00 3.14913e-01 5.25171e-01 1.77034e-01
## PPV_KA PPV_TLAG PPV_FORAL
## 4.66552e+02 1.00000e-01 1.00000e-03
nmfocei.xpdb<-as.xpdb(NM.FOCEI,datafile)
##
## Removed dose rows in rawData+Predictions slot of SO to enable merge with Residuals data.
##
## Residuals data does not currently contain dose rows in output from Nonmem executions.
Basic diagnostics for NONMEM fit.
print(basic.gof(nmfocei.xpdb))
Export graphs to a PDF file
pdf("GOF_NM_FOCEI.pdf")
print(basic.gof(nmfocei.xpdb))
dev.off()
## rj.GD
## 2
Before running the VPC with PsN we must update the (initial) values in the MDL Parameter Object MLE estimates from previous step can be used
structuralPar <- getPopulationParameters(NM.FOCEI, what="estimates",block='structural')$MLE
variabilityPar <- getPopulationParameters(NM.FOCEI, what="estimates",block='variability')$MLE
Update the parameter object using the ddmore “updateParObj” function. This function updates an R object of (S4) class “parObj”. The user chooses which block to update, what items within that block, and what to replace those items with. NOTE: that updateParObj can only update attributes which ALREADY EXIST in the MDL Parameter Object for that item. This ensures that valid MDL is preserved.
myParObj <- getParameterObjects(mdlfile)[[1]]
myParObjUpdated <- updateParObj(myParObj,block="STRUCTURAL",
item=names(structuralPar),
with=list(value=structuralPar))
myParObjUpdated <- updateParObj(myParObjUpdated,block="VARIABILITY",
item=names(variabilityPar),
with=list(value=variabilityPar))
Check that the appropriate initial values have been updated to the MLE values from the previous fit.
print(myParObjUpdated@STRUCTURAL)
## $POP_CL
## $POP_CL$value
## [1] "0.0820411"
##
## $POP_CL$lo
## [1] "0.001"
##
##
## $POP_V
## $POP_V$value
## [1] "8.64035"
##
## $POP_V$lo
## [1] "0.001"
##
##
## $POP_KA
## $POP_KA$value
## [1] "0.00461"
##
## $POP_KA$lo
## [1] "0.001"
##
##
## $POP_TLAG
## $POP_TLAG$value
## [1] "0.05026"
##
## $POP_TLAG$lo
## [1] "0.001"
##
##
## $BETA_CL_WT
## $BETA_CL_WT$value
## [1] "0.75"
##
## $BETA_CL_WT$fix
## [1] "true"
##
##
## $BETA_V_WT
## $BETA_V_WT$value
## [1] "1"
##
## $BETA_V_WT$fix
## [1] "true"
##
##
## $POP_FORAL
## $POP_FORAL$value
## [1] "0.999463"
##
## $POP_FORAL$lo
## [1] "0.001"
print(myParObjUpdated@VARIABILITY)
## $PPV_CL
## $PPV_CL$value
## [1] "0.314913"
##
##
## $PPV_V
## $PPV_V$value
## [1] "0.177034"
##
##
## $PPV_KA
## $PPV_KA$value
## [1] "466.552"
##
##
## $PPV_TLAG
## $PPV_TLAG$value
## [1] "0.1"
##
## $PPV_TLAG$fix
## [1] "true"
##
##
## $PPV_FORAL
## $PPV_FORAL$value
## [1] "0.001"
##
##
## $CORR_CL_V
## $CORR_CL_V$value
## [1] "0.525171"
##
##
## $RUV_PROP
## $RUV_PROP$value
## [1] "0.34797"
##
## $RUV_PROP$lo
## [1] "0"
##
##
## $RUV_ADD
## $RUV_ADD$value
## [1] "0.00111745"
##
## $RUV_ADD$lo
## [1] "1.0E-4"
Assembling the new MOG. Note that we reuse the data and model from the previous run.
myVPCMOG <- createMogObj(dataObj = getDataObjects(mdlfile)[[1]],
parObj = myParObjUpdated,
mdlObj = getModelObjects(mdlfile)[[1]],
taskObj = getTaskPropertiesObjects(mdlfile)[[1]])
We can then write the MOG back out to an .mdl file.
mdlfile.VPC <- paste0(uc,"_VPC.mdl")
writeMogObj(myVPCMOG,mdlfile.VPC)
Similarly as above, ddmore “VPC.PsN” function can be used to run a VPC using PsN as target tool
vpcFiles <- VPC.PsN(mdlfile.VPC,samples=20, seed=12345,
vpcOptions ="-n_simulation=10",
subfolder="VPC", plot=TRUE)
## -- Thu Aug 18 09:23:28 2016
## New
## Submitted
## Job 33a409c8-a4ba-432d-af49-c5228f1fbc72 progress:
## Running [ .... ]
## Importing Results
## Copying the result data back to the local machine for job ID 33a409c8-a4ba-432d-af49-c5228f1fbc72...
## From C:\Users\zparra\AppData\Local\Temp\RtmpSKgKTU\DDMORE.job1dec1fb434aa to D:/SEE-Prod5_RC4/MDL_IDE/workspace/UseCasesDemo/UseCase4_3/VPC
## Done.
##
##
## The following main elements were parsed successfully:
## RawResults
##
## The following ERRORs were raised during the job execution:
## Parsing error: Outputfile not parsed successfully, error message: It seems there was an error before NONMEM started, messages are:
## Warning:
## Found STANDARD/CORRELATION/CHOLESKY in $OMEGA.
## This is not yet supported by PsN. Errors will be introduced when
## updating initial estimates to final estimates from previous run
## and sumo output will be wrong.
## Warning:
## Found STANDARD/CORRELATION/CHOLESKY in $OMEGA.
## This is not yet supported by PsN. Errors will be introduced when
## updating initial estimates to final estimates from previous run
## and sumo output will be wrong.
## Starting 11 NONMEM executions. 2 in parallel.
## S:1 .. S:2 .. Warning:
## Found STANDARD/CORRELATION/CHOLESKY in $OMEGA.
## This is not yet supported by PsN. Errors will be introduced when
## updating initial estimates to final estimates from previous run
## and sumo output will be wrong.
## Warning:
## Found STANDARD/CORRELATION/CHOLESKY in $OMEGA.
## This is not yet supported by PsN. Errors will be introduced when
## updating initial estimates to final estimates from previous run
## and sumo output will be wrong.
## S:3 .. Warning:
## Found STANDARD/CORRELATION/CHOLESKY in $OMEGA.
## This is not yet supported by PsN. Errors will be introduced when
## updating initial estimates to final estimates from previous run
## and sumo output will be wrong.
## Warning:
## Found STANDARD/CORRELATION/CHOLESKY in $OMEGA.
## This is not yet supported by PsN. Errors will be introduced when
## updating initial estimates to final estimates from previous run
## and sumo output will be wrong.
## S:4 .. Warning:
## Found STANDARD/CORRELATION/CHOLESKY in $OMEGA.
## This is not yet supported by PsN. Errors will be introduced when
## updating initial estimates to final estimates from previous run
## and sumo output will be wrong.
## Warning:
## Found STANDARD/CORRELATION/CHOLESKY in $OMEGA.
## This is not yet supported by PsN. Errors will be introduced when
## updating initial estimates to final estimates from previous run
## and sumo output will be wrong.
## S:5 .. Warning:
## Found STANDARD/CORRELATION/CHOLESKY in $OMEGA.
## This is not yet supported by PsN. Errors will be introduced when
## updating initial estimates to final estimates from previous run
## and sumo output will be wrong.
## Warning:
## Found STANDARD/CORRELATION/CHOLESKY in $OMEGA.
## This is not yet supported by PsN. Errors will be introduced when
## updating initial estimates to final estimates from previous run
## and sumo output will be wrong.
## S:6 .. Warning:
## Found STANDARD/CORRELATION/CHOLESKY in $OMEGA.
## This is not yet supported by PsN. Errors will be introduced when
## updating initial estimates to final estimates from previous run
## and sumo output will be wrong.
## Warning:
## Found STANDARD/CORRELATION/CHOLESKY in $OMEGA.
## This is not yet supported by PsN. Errors will be introduced when
## updating initial estimates to final estimates from previous run
## and sumo output will be wrong.
## S:7 .. Warning:
## Found STANDARD/CORRELATION/CHOLESKY in $OMEGA.
## This is not yet supported by PsN. Errors will be introduced when
## updating initial estimates to final estimates from previous run
## and sumo output will be wrong.
## Warning:
## Found STANDARD/CORRELATION/CHOLESKY in $OMEGA.
## This is not yet supported by PsN. Errors will be introduced when
## updating initial estimates to final estimates from previous run
## and sumo output will be wrong.
## S:8 .. Warning:
## Found STANDARD/CORRELATION/CHOLESKY in $OMEGA.
## This is not yet supported by PsN. Errors will be introduced when
## updating initial estimates to final estimates from previous run
## and sumo output will be wrong.
## Warning:
## Found STANDARD/CORRELATION/CHOLESKY in $OMEGA.
## This is not yet supported by PsN. Errors will be introduced when
## updating initial estimates to final estimates from previous run
## and sumo output will be wrong.
## S:9 .. Warning:
## Found STANDARD/CORRELATION/CHOLESKY in $OMEGA.
## This is not yet supported by PsN. Errors will be introduced when
## updating initial estimates to final estimates from previous run
## and sumo output will be wrong.
## Warning:
## Found STANDARD/CORRELATION/CHOLESKY in $OMEGA.
## This is not yet supported by PsN. Errors will be introduced when
## updating initial estimates to final estimates from previous run
## and sumo output will be wrong.
## S:10 .. Warning:
## Found STANDARD/CORRELATION/CHOLESKY in $OMEGA.
## This is not yet supported by PsN. Errors will be introduced when
## updating initial estimates to final estimates from previous run
## and sumo output will be wrong.
## Warning:
## Found STANDARD/CORRELATION/CHOLESKY in $OMEGA.
## This is not yet supported by PsN. Errors will be introduced when
## updating initial estimates to final estimates from previous run
## and sumo output will be wrong.
## S:11 .. Warning:
## Found STANDARD/CORRELATION/CHOLESKY in $OMEGA.
## This is not yet supported by PsN. Errors will be introduced when
## updating initial estimates to final estimates from previous run
## and sumo output will be wrong.
## Warning:
## Found STANDARD/CORRELATION/CHOLESKY in $OMEGA.
## This is not yet supported by PsN. Errors will be introduced when
## updating initial estimates to final estimates from previous run
## and sumo output will be wrong.
## Waiting for all NONMEM runs to finish:
## F:9 .. Warning:
## Found STANDARD/CORRELATION/CHOLESKY in $OMEGA.
## This is not yet supported by PsN. Errors will be introduced when
## updating initial estimates to final estimates from previous run
## and sumo output will be wrong.
## Warning:
## Found STANDARD/CORRELATION/CHOLESKY in $OMEGA.
## This is not yet supported by PsN. Errors will be introduced when
## updating initial estimates to final estimates from previous run
## and sumo output will be wrong.
## F:11 .. done
## Reading and formatting DV data. This can take a while...
## File C:\Users\zparra\AppData\Local\Temp\mifshare\33a409c8-a4ba-432d-af49-c5228f1fbc72\rundir\m1\vpc_original.npctab.dta
## with table output for original data does not exist. It is recommended to check lst-file C:\Users\zparra\AppData\Local\Temp\mifshare\33a409c8-a4ba-432d-af49-c5228f1fbc72\rundir\modelfit_dir1\/NM_run1/psn-1.lst for NONMEM error messages. at D:/SEE-PR~1/perl/bin/..\site\lib\PsN_4_4_8/tool/npc.pm line 2345.
## File error: vpc results file "rundir\vpc_results.csv" does not exist
##
## The following MESSAGEs were raised during the job execution:
## nmoutput2so_version: This SOBlock was created with nmoutput2so version 4.5.27
##
## Failed
## -- Thu Aug 18 09:24:52 2016
## Warning in VPC.PsN(mdlfile.VPC, samples = 20, seed = 12345, vpcOptions =
## "-n_simulation=10", : vpc failed, could not find vpctab file for plotting.
## Check error messages in
## D:/SEE-Prod5_RC4/MDL_IDE/workspace/UseCasesDemo/UseCase4_3/VPC/UseCase4_3_VPC.psn.log
To replay the visualisation using information from the VPC SO file
pdf(paste0(uc,"_VPC.pdf"))
print(xpose.VPC(vpc.info= file.path("./VPC",vpcFiles@RawResults@DataFiles$PsN_VPC_results$path),
vpctab= file.path("./VPC",vpcFiles@RawResults@DataFiles$PsN_VPC_vpctab$path),
main="VPC warfarin"))
## Error in print(xpose.VPC(vpc.info = file.path("./VPC", vpcFiles@RawResults@DataFiles$PsN_VPC_results$path), : error in evaluating the argument 'x' in selecting a method for function 'print': Error in if (!is.readable.file(vpc.file)) { :
## missing value where TRUE/FALSE needed
dev.off()
## rj.GD
## 2
The mlxR package has been developed to visualize and explore models that are encoded in MLXTRAN or PharmML. The ddmore function as.PharmML translates an MDL file (extension .mdl) to its PharmML representation. The output file (extension .xml) is saved in the working directory.
myPharmML <- as.PharmML(mdlfile)
Use parameter values from the FOCEI estimation
parValues <- getPopulationParameters(NM.FOCEI,what="estimates")$MLE
Simulate for the typical weight of 70. Recall that logtWT = log(WT/70).
p <- c(parValues,logtWT=0)
Parameter values used in simulation
print(p)
## POP_CL POP_V POP_KA POP_TLAG POP_FORAL RUV_PROP
## 8.20411e-02 8.64035e+00 4.61000e-03 5.02600e-02 9.99463e-01 3.47970e-01
## RUV_ADD BETA_CL_WT BETA_V_WT PPV_CL CORR_CL_V PPV_V
## 1.11745e-03 7.50000e-01 1.00000e+00 3.14913e-01 5.25171e-01 1.77034e-01
## PPV_KA PPV_TLAG PPV_FORAL logtWT
## 4.66552e+02 1.00000e-01 1.00000e-03 0.00000e+00
Simulate for a dose of 100 mg given at time 0 into the CENTRAL (iv administration) and a dose of 150 mg given to the CENTRAL (iv dose). Note that we are using COMPARMTMENTS for dosing processes, which translate to PK macros, and therefore the type option needs to be used
adm1 <- list(type=2, time = 0, amount=100, rate=100) #iv dose
adm2 <- list(type=1, time = 168, amount=150) #oral dose
Simulate PK parameters for individuals
ind <- list(name = c('CL','V'))
Simulate predicted (CC) and observed concentration values (Y)
f <- list( name = c('CC'), time = seq(0,to=300,by=1))
y <- list( name = c('Y'), time = c(0, 0.5, 1, 4, 8, 12, 24, 36, 48,120,
168,168.5,170,171,174,180,192,216,240,288))
Simulate 12 subjects
g <- list( size = 12, level = 'individual')
Call simulx
res <- simulx(model = myPharmML,
parameter = p,
group = g,
treatment = list(adm1,adm2),
output = list(ind,f,y))
Simulated parameter values for each individual
print(res$parameter)
## id CL V
## 1 1 0.12683253 9.448497
## 2 2 0.10258911 11.964061
## 3 3 0.10754486 8.644903
## 4 4 0.07249488 9.904171
## 5 5 0.06997531 6.256064
## 6 6 0.05903103 8.839452
## 7 7 0.13875072 12.792151
## 8 8 0.08334258 9.305366
## 9 9 0.06678852 10.020900
## 10 10 0.09093290 9.357694
## 11 11 0.10568773 10.135776
## 12 12 0.05778949 9.126651
Plot simulated results
plot(ggplot() +
geom_line(data=res$CC, aes(x=time, y=CC, colour=id)) +
geom_point(data=res$Y, aes(x=time, y=Y, colour=id)) +
xlab("time (h)") + ylab("concentration") )
## Warning in loop_apply(n, do.ply): Removed 432 rows containing missing
## values (geom_path).
## Warning in loop_apply(n, do.ply): Removed 28 rows containing missing
## values (geom_point).
Simulate 1000 subjects - with simulx this is a QUICK process!
g <- list( size = 1000, level = 'individual')
Call simulx
res.1000 <- simulx(model = myPharmML,
parameter = p,
group = g,
treatment = list(adm1,adm2),
output = list(ind,f,y))
Plot prediction intervals with prctilemlx
. band
defines the percentile bands displayed:
print(prctilemlx(res.1000$Y,band=list(number=9, level=90)))
Table of the same information
print(prctilemlx(res.1000$Y,band=list(number=10, level=100), plot=FALSE)$y)
## time 0% 10% 20% 30%
## 1 0.0 -0.0024752840 -0.001251522 -0.0007023355 -0.0004271392
## 2 0.5 -0.5433787250 2.545481999 3.3604557003 4.0842525044
## 3 1.0 2.4971566169 6.795950497 8.7289017500 9.7215160693
## 4 4.0 1.7899140436 5.925782814 7.7004907655 8.3863693808
## 5 8.0 3.0171491483 5.648627279 8.1747198834 8.8453640994
## 6 12.0 1.3942685679 5.091387584 6.8590046662 8.0229005867
## 7 24.0 1.7131631047 5.109783438 6.6173944705 7.2985057472
## 8 36.0 1.3564375992 3.784045392 5.4747317519 6.4919259341
## 9 48.0 0.7035966210 3.222751356 4.7935801565 5.4196392401
## 10 120.0 -0.6971192328 1.547843820 2.2291754932 2.7120760270
## 11 168.0 0.6652577415 1.088404789 1.3534188514 1.7451760551
## 12 168.5 -0.0001146221 0.846957322 1.2009584121 1.6081842423
## 13 170.0 -0.0002343185 0.931681603 1.1906115951 1.6213192589
## 14 171.0 0.0016877333 0.929558730 1.3751944511 1.5905349223
## 15 174.0 -0.0002789691 0.755966887 1.2432671320 1.5272979314
## 16 180.0 -0.0009758202 0.515147515 0.8027079244 1.2885273201
## 17 192.0 0.0018988527 0.654051829 0.8314843758 0.9990331225
## 18 216.0 0.0007065797 0.404506595 0.6366616460 0.8755189981
## 19 240.0 0.0001063043 0.337914658 0.5015596223 0.7632453259
## 20 288.0 -0.0003577241 0.203302091 0.3213118310 0.4427781789
## 40% 50% 50% 60% 70%
## 1 -0.0002090029 -8.059241e-05 -8.059241e-05 1.907106e-04 3.544606e-04
## 2 4.9847723289 5.432424e+00 5.432424e+00 5.932388e+00 6.607089e+00
## 3 10.5012371588 1.154600e+01 1.154600e+01 1.247430e+01 1.450654e+01
## 4 9.4713034235 1.080843e+01 1.080843e+01 1.183299e+01 1.261882e+01
## 5 9.4483235546 1.073934e+01 1.073934e+01 1.173404e+01 1.242686e+01
## 6 8.8920882567 9.943650e+00 9.943650e+00 1.138316e+01 1.247684e+01
## 7 8.3000731028 8.948292e+00 8.948292e+00 9.712658e+00 1.081606e+01
## 8 7.1911660672 7.974915e+00 7.974915e+00 9.184113e+00 1.056388e+01
## 9 6.0649859814 7.026649e+00 7.026649e+00 7.695877e+00 8.477404e+00
## 10 3.0724598531 3.691068e+00 3.691068e+00 4.033756e+00 4.690041e+00
## 11 2.1370267901 2.269340e+00 2.269340e+00 2.720495e+00 3.203535e+00
## 12 1.7942541573 2.145634e+00 2.145634e+00 2.617258e+00 3.110097e+00
## 13 1.9301891717 2.165496e+00 2.165496e+00 2.369395e+00 3.005933e+00
## 14 1.7887188173 2.084796e+00 2.084796e+00 2.267679e+00 2.834869e+00
## 15 1.8512699670 2.202445e+00 2.202445e+00 2.723676e+00 2.865416e+00
## 16 1.7062122112 2.134012e+00 2.134012e+00 2.380916e+00 2.675854e+00
## 17 1.3666259508 1.787700e+00 1.787700e+00 2.068202e+00 2.333921e+00
## 18 1.1516211486 1.341374e+00 1.341374e+00 1.653625e+00 2.158037e+00
## 19 0.8803014572 1.136315e+00 1.136315e+00 1.293877e+00 1.835593e+00
## 20 0.5123159913 6.363271e-01 6.363271e-01 8.393673e-01 1.069854e+00
## 80% 90% 100%
## 1 7.073705e-04 0.001578259 0.002112662
## 2 7.154654e+00 8.280334103 16.808990042
## 3 1.574380e+01 17.767295141 22.247193295
## 4 1.377083e+01 16.363970350 22.284897229
## 5 1.357413e+01 15.020837501 19.479021456
## 6 1.346773e+01 15.115919000 22.138061322
## 7 1.157801e+01 12.911735871 18.144150288
## 8 1.150404e+01 12.524174570 19.425883746
## 9 9.862396e+00 11.115770659 14.442537032
## 10 5.554729e+00 7.093155003 10.654314066
## 11 3.847160e+00 4.800201742 6.511349803
## 12 3.666611e+00 4.780223311 38.369533408
## 13 4.453256e+00 6.477201508 24.679382525
## 14 3.828913e+00 4.952273557 33.478764319
## 15 3.389765e+00 5.104112020 26.125358603
## 16 3.471382e+00 6.139305571 30.732758530
## 17 3.359064e+00 6.536447885 22.746553439
## 18 2.815614e+00 5.232564974 27.044325942
## 19 2.658744e+00 4.883076366 9.744047396
## 20 1.637149e+00 3.288697930 12.643560066