| mccut | R Documentation |
‘evalmccut’ evaluates a Two-Dimensional Monte Carlo model using a loop on the uncertainty dimension. Within each loop, it calculates statistics in the variability dimension and stores them for further analysis. It allows evaluation of very high dimension models using time instead of memory.
Builds a ‘mcmodelcut’ object that can be sent to evalmccut.
evalmccut(model, nsv = ndvar(), nsu = ndunc(), seed = NULL, ind = "index")
mcmodelcut(x, is.expr = FALSE)
## S3 method for class 'mccut'
plot(
x,
stat = c("median", "mean"),
lim = c(0.025, 0.25, 0.75, 0.975),
griddim = NULL,
xlab = names(x),
ylab = "Fn(x)",
main = "",
draw = TRUE,
...
)
## S3 method for class 'mccut'
print(x, lim = c(0.025, 0.975), digits = 3, ...)
model |
a ‘mcmodelcut’ object or a valid call including three blocks. |
nsv |
the number of simulations for variability. |
nsu |
the number of simulations for uncertainty. |
seed |
the random seed. If ‘NULL’ the seed is unchanged. |
ind |
the variable name used in ‘model’ to refer to the uncertainty loop index. |
x |
for |
is.expr |
|
stat |
a character string: |
lim |
a vector of quantiles for the uncertainty dimension. For |
griddim |
a vector of two integers specifying the grid layout (rows, columns) for
the plot. If |
xlab |
a vector of x-axis labels, one per node. Defaults to the names of the ‘mccut’ object. |
ylab |
the y-axis label. |
main |
the plot title. |
draw |
logical. If |
... |
additional arguments passed to the print or plot function. |
digits |
number of digits in the print. |
‘x’ (or ‘model’) should be built as three blocks, separated by ‘{’:
The first block is evaluated once (and only once) before the loop. It should evaluate all ‘"V"’, ‘"0"’ and ‘"U"’ nodes.
The second block, which should lead to an ‘mc’ object, is evaluated using ‘nsu=1’. It must end with an expression like ‘mymc <- mc(...)’.
The third block is evaluated on the ‘mc’ object. All resulting statistics are stored. It should build a list of statistics such as ‘summary’, ‘plot’, ‘tornado’ or any function leading to a vector, matrix or list of those.
Steps 2 and 3 are repeated ‘nsu’ times. At each iteration, the loop index (from 1 to ‘nsu’) is assigned to the variable specified in ‘ind’.
An object of class ‘mccut’.
The seed is set at the beginning of the evaluation. Complete similarity of two
evaluations with the same seed is not certain depending on the model structure.
In particular, the results will differ from evalmcmod with the same seed.
Do not use upper case variables in your model to avoid conflicts with internal variables.
evalmcmod, mcmodelcut.
modEC3 <- mcmodelcut({
## First block: evaluates all 0, V and U nodes
{
cook <- mcstoc(rempiricalD, type="V", values=c(0, 1/5, 1/50), prob=c(0.027, 0.373, 0.6))
serving <- mcstoc(rgamma, type="V", shape=3.93, rate=0.0806)
conc <- mcstoc(rnorm, type="U", mean=10, sd=2)
r <- mcstoc(runif, type="U", min=5e-04, max=0.0015)
}
## Second block: evaluates VU nodes, leads to mc object
{
expo <- conc * cook * serving
dose <- mcstoc(rpois, type="VU", lambda=expo)
risk <- 1 - (1 - r)^dose
res <- mc(conc, cook, serving, expo, dose, r, risk)
}
## Third block: statistics
{
list(
sum = summary(res),
plot = plot(res, draw=FALSE),
minmax = lapply(res, range)
)
}
})
x <- evalmccut(modEC3, nsv=101, nsu=101, seed=666)
summary(x)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.