if (FALSE) {
model <- pkmodel(
numComp = 1,
absorption = "Extravascular",
ID = "Subject",
Time = "Act_Time",
CObs = "Conc",
Aa = "Amount",
data = pkData,
modelName = "PkModel",
workingDir = tempdir()
)
host <- hostParams(
sharedDirectory = tempdir(),
parallelMethod = "NONE",
hostName = "local",
numCores = 1
)
job <- fitmodel(model = model,
hostPlatform = host)
finalModelVPC <- copyModel(model,
acceptAllEffects = TRUE,
modelName = "model_VPC",
workingDir = tempdir())
# View the model
print(finalModelVPC)
# Set up VPC arguments to have PRED outputted to simulation output dataset "predout.csv"
vpcSetup <- NlmeVpcParams(outputPRED = TRUE)
# Run VPC using the default host, default values for the relevant NLME engine arguments
finalVPCJob <- vpcmodel(model = finalModelVPC, vpcParams = vpcSetup, hostPlatform = host)
# the same as:
# finalVPCJob <- vpcmodel(model = finalModelVPC, outputPRED = TRUE)
# Observed dataset predcheck0.csv
dt_ObsData <- finalVPCJob$predcheck0
# Simulation output dataset predout.csv
dt_SimData <- finalVPCJob$predout
# Add PRED from REPLICATE = 0 of simulation output dataset to observed input dataset
dt_ObsData$PRED <- dt_SimData[REPLICATE == 0]$PRED
# tidyvpc package VPC example:
# library(tidyvpc)
# library(magrittr)
# Create a regular VPC plot with binning method set to be "jenks"
# binned_VPC <- observed(dt_ObsData, x = IVAR, yobs = DV) %>%
# simulated(dt_SimData, ysim = DV) %>%
# binning(bin = "jenks") %>%
# vpcstats()
# plot_binned_VPC <- plot(binned_VPC)
# Create a pcVPC plot with binning method set to be "jenks"
# binned_pcVPC <- observed(dt_ObsData, x = IVAR, yobs = DV) %>%
# simulated(dt_SimData, ysim = DV) %>%
# binning(bin = "jenks") %>%
# predcorrect(pred = PRED) %>%
# vpcstats()
# plot_binned_pcVPC <- plot(binned_pcVPC)
}
Run the code above in your browser using DataLab