MonteCarlo()
SetPoints()
The objective of a probabilistic risk analysis is the quantification of risk from made man-made and natural activities (Vesely and Rasmuson, 1984).
Two major types of uncertainty need to be differentiated:
Modeling uncertainty
Parameter uncertainty
Completeness uncertainty
The parameter is an element of a system that determine the model output.
Parameter uncertainty comes from the model parameters that are inputs to the mathematical model but whose exact values are unknown and cannot be controlled in physical experiments.
y=f(xi)
With four parameters I can fit an elephant, and with five I can make him wiggle his trunk.
-John von Neumann
Mayer J, Khairy K, Howard J. Drawing an elephant with four complex parameters. Am. J. Phys. 78, 648 (2010) https://doi.org/10.1119/1.3254017
Physiological parameters
Cardiac output
Blood flow rate
Tissue volume
Absorption
Absorption fraction, absorption rate, ...
Distribution
Partition coefficient, distribution fraction, ...
Metabolism
Michaelis–Menten kinetics, ...
Elimination
First order elimination rate, ...
Used to: Check possible simulation (under given parameter distributions) results before model calibration
Used to: Posterior analysis, Local/global sensitivity analysis
The MonteCarlo specification gives general information required for the runs: (1) the output file name, (2) the number of runs to perform, and (3) a starting seed for the random number generator. Its syntax is:
MonteCarlo("<OutputFilename>", <nRuns>, <RandomSeed>);
"<OutputFilename>"
The character string
<nRuns>
The number of runs
<RandomSeed>
The seed
Here is an example of use:
MonteCarlo("simmc.out", 50000, 9386);
The specification of distributions for simple Monte Carlo simulations,
Distrib(<parameter identifier>, <distribution-name>, [<shape parameters>]);
Here are some examples:
LogUniform
, with two shape parameters: the minimum and the maximum of the sampling range in natural space.
Uniform
, with two shape parameters: the minimum and the maximum of the sampling range.
Normal_cv,
is the normal distribution with the coefficient of variation instead of the standard deviation as second parameter.
Normal_v,
is also the normal distribution with the variance instead of the standard deviation as second parameter.
LogNormal
takes two reals numbers as parameters: the geometric mean and the geometric standard deviation.
TruncNormal
(truncated normal distribution), takes four real parameters: the mean, the standard deviation, the minimum and the maximum.
## ./mcsim.one.model.R.exe one.mtc.in.R ###### Monte Carlo simulation input file for one compartment modelMonteCarlo ("simmc.out", 10, 95814);Distrib (Ka, Uniform, 0.2, 0.8);Distrib (Ke, Uniform, 0.03, 0.1);Simulation { # 1 OralDose = 100; BW = 60; PrintStep (C_central, 0, 8, 1);}End.
This command specifies an output filename, the name of a text file containing (1) the chosen parameter values, (2) the number of simulations to perform and (3) a list of model parameters to read in. It has the following syntax:
SetPoints("<OutputFilename>", "<SetPointsFilename>", <nRuns>, <parameter identifier>, <parameter identifier>, ...);
"<OutputFilename>"
The character string
"<SetPointsFilename>"
The character string
<nRuns>
should be less or equal to the number of lines (minus one) in the set points file. If a zero is given, all lines of the file are read.
<parameter identifier>
a comma-separated list of the parameters or vectors to be read in the SetPointsFilename.
## ./mcsim.one.model.R.exe one.setpt.in.R ###### Setpoint simulation input file for one compartment model## Use "sim.out" that generated from "one.mtc.in.R"SetPoints ("setpts.out", "simmc.out", 0, Ka, Ke);Simulation { # 1 OralDose = 100; BW = 60; PrintStep (C_central, 0, 8, 1);}End.
"The study of how uncertainty in the output of a model (numerical or otherwise) can be apportioned to different sources of uncertainty in the model input."
Identify the most important factors
Adjust the uncertainty in the model response in experiment design
Identify the least important factors
Simplify the model if it has too many factors
It consequently provides useful insight into which model input contributes most to the variability of the model output
Local (One-at-a-time)
"Local" SA focus on sensitivity at a particular set of input parameters, usually using gradients or partial derivatives
Usually, some people have experience in modeling they have the knowledge in local sensitivity analysis.
This method is very simple. You move one parameter and fix other parameters then check the change of model outputs.
On the other side, some researcher also developed the approach that moves all parameters at a time and checks the change of model output. We call it Global sensitivity analysis or variance-based sensitivity analysis.
Local (One-at-a-time)
"Local" SA focus on sensitivity at a particular set of input parameters, usually using gradients or partial derivatives
Global (All-at-a-time)
"Global" SA calculates the contribution from the variety of all model parameters, including Single parameter effects and Multiple parameter interactions
Usually, some people have experience in modeling they have the knowledge in local sensitivity analysis.
This method is very simple. You move one parameter and fix other parameters then check the change of model outputs.
On the other side, some researcher also developed the approach that moves all parameters at a time and checks the change of model output. We call it Global sensitivity analysis or variance-based sensitivity analysis.
Usually, some people have experience in modeling they have the knowledge in local sensitivity analysis.
This method is very simple. You move one parameter and fix other parameters then check the change of model outputs.
On the other side, some researcher also developed the approach that moves all parameters at a time and checks the change of model output. We call it Global sensitivity analysis or variance-based sensitivity analysis.
First order (Si)
Interaction (Sij)
Total order (ST)
“Local” SA usually only addresses first order effects
“Global” SA can address total effect that include main effect and interaction
A simple but effective way of screening a few important input factors (Morris 1991).
Perform parameter sampling in Latin Hypercube following "One-Step-At-A-Time"
Can compute the importance (μ∗) and interaction (σ) of the effects
⎡⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢ ⎢⎣10000…011000…011100…011110…011111…0⋮⋮⋮⋮⋮⋱⋮11111…1⎤⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥ ⎥⎦⎛⎜ ⎜ ⎜ ⎜⎝b0b1⋮bk⎞⎟ ⎟ ⎟ ⎟⎠=⎛⎜ ⎜ ⎜ ⎜⎝y1y2⋮yk+1⎞⎟ ⎟ ⎟ ⎟⎠
Variance-based method for sensitivity analysis were first employed by chemists (Cukier et al. 1973). The method, known as FAST (Fourier Amplitude Sensitivity Test).
Robust in factor fixing, but had relatively high computational cost than local SA.
Si=V[E(Y|Xi)]V(Y)
Example of parameter 1 for model with three parameters
ST1=S1+S12+S13+S123
S1+S2+S3+S12+S13+S23+S123=1
Identify all model factor (xi) which should be consider in analysis
Characterise the uncertainty for each selected input factor
Generate a sample of a given size from the previously defined probability distribution
Define the variable of interest (yi,t)
Execute the model for each combination of factor
Visualize and interpret the outputs
Estimate the sensitivity measures ("check convergence")
Decision making
A collection of functions for factor screening, global sensitivity analysis and reliability sensitivity analysis. Most of the functions have to be applied on model with scalar output, but several functions support multi-dimensional outputs.
ls(pos = "package:sensitivity")
## [1] "ask" "atantemp.fun" "campbell1D.fun" ## [4] "delsa" "dgumbel.trunc" "dnorm.trunc" ## [7] "fast99" "ishigami.fun" "linkletter.fun" ## [10] "morris" "morris.fun" "morrisMultOut" ## [13] "parameterSets" "pcc" "pgumbel.trunc" ## [16] "PLI" "PLIquantile" "plot3d.morris" ## [19] "plotFG" "pnorm.trunc" "PoincareConstant"## [22] "PoincareOptimal" "qgumbel.trunc" "qnorm.trunc" ## [25] "rgumbel.trunc" "rnorm.trunc" "sb" ## [28] "scatterplot" "sensiFdiv" "sensiHSIC" ## [31] "shapleyPermEx" "shapleyPermRand" "sobol" ## [34] "sobol.fun" "sobol2002" "sobol2007" ## [37] "sobolEff" "sobolGP" "soboljansen" ## [40] "sobolmara" "sobolmartinez" "sobolMultOut" ## [43] "sobolowen" "sobolroalhs" "sobolroauc" ## [46] "sobolSalt" "sobolSmthSpl" "sobolTIIlo" ## [49] "sobolTIIpf" "soboltouati" "src" ## [52] "support" "tell" "template.replace"
f(x)=sin(x1)+asin2(x2)+bx43sin(x1)
set.seed(1111)x <- morris(model = ishigami.fun, factors = c("Factor A", "Factor B","Factor C"), r = 30, binf = -pi, bsup = pi, design = list(type = "oat", levels = 6, grid.jump = 3))par(mfrow = c(1,3))plot(x$X[,1], x$y); plot(x$X[,2], x$y); plot(x$X[,3], x$y)
par(mar=c(4,4,1,1))plot(x, xlim = c(0,10), ylim = c(0,10))abline(0,1) # non-linear and/or non-monotonicabline(0,0.5, lty = 2) # monotonicabline(0,0.1, lty = 3) # almost linearlegend("topleft", legend = c("non-linear and/or non-monotonic", "monotonic", "linear"), lty = c(1:3))
x <- fast99(model = ishigami.fun, factors = 3, n = 400, q = "qunif", q.arg = list(min = -pi, max = pi))par(mfrow = c(1,3))plot(x$X[,1], x$y); plot(x$X[,2], x$y); plot(x$X[,3], x$y)
plot(x)
If model evaluation is computationally burdensome, use the Morris method as an initial screen to remove clearly “non-influential” parameters (Hsieh et al., 2018)
Use the lower error tolerance value to solve the problem in computational error.
Always plot the data. Make sure you do not make any mistake in parameter sampling.
Be aware of the parameter uncertainty. If the sampling range is too broad, try using the log-transformed distribution.
Try Quasi-Monte Carlo (QMC). The QMC method can generate more "uniform" distribution than random MC sampling.
Making sure to check convergence (Sarrazin et al., 2016)
1-compartment model (Based on httk package)
Mutivariate toxicokinetic modeling
MonteCarlo()
SetPoints()
Keyboard shortcuts
↑, ←, Pg Up, k | Go to previous slide |
↓, →, Pg Dn, Space, j | Go to next slide |
Home | Go to first slide |
End | Go to last slide |
Number + Return | Go to specific slide |
b / m / f | Toggle blackout / mirrored / fullscreen mode |
c | Clone slideshow |
p | Toggle presenter mode |
t | Restart the presentation timer |
?, h | Toggle this help |
Esc | Back to slideshow |