mcmodel: Monte Carlo model

Description Usage Arguments Details Value See Also Examples

View source: R/mcmodel.R

Description

Specify a mcmodel, without evaluating it, for a further evaluation using evalmcmod.

Usage

1
mcmodel(x, is.expr=FALSE)

Arguments

x

An R call or an expression.

is.expr

FALSE to send a call, TRUE to send an expression (see Examples)

Details

The model should be put between { and the last line should be of the form mc(...). Any reference to the number of simulation in the dimension of variability should be done via ndvar() or (preferred) nsv. Any reference to the number of simulations in the dimension of uncertainty should be done via ndunc() or (preferred) nsu.

Value

an R expression, with class mcmodel

See Also

expression.

evalmcmod to evaluate the model.

mcmodelcut to evaluate high Dimension Monte Carlo Model in a loop.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
modEC1 <- mcmodel({
 conc <- mcdata(10, "0")
 cook <- mcstoc(rempiricalD, values=c(0, 1/5, 1/50), prob=c(0.027, 0.373, 0.600))
 serving <- mcstoc(rgamma, shape=3.93, rate=0.0806)
 expo <- conc * cook * serving
 dose <- mcstoc(rpois, lambda=expo)
 risk <- 1-(1-0.001)^dose
 mc(conc, cook, serving, expo, dose, risk)
 })
evalmcmod(modEC1, nsv=100, nsu=100)

Example output

Loading required package: mvtnorm

Attaching package: 'mc2d'

The following objects are masked from 'package:base':

    pmax, pmin

     node    mode nsv nsu nva variate    min    mean  median     max Nas type
1    conc numeric   1   1   1       1 10.000 10.0000 10.0000  10.000   0    0
2    cook numeric 100   1   1       1  0.020  0.0866  0.0200   0.200   0    V
3 serving numeric 100   1   1       1  4.079 51.3032 46.8543 166.752   0    V
4    expo numeric 100   1   1       1  0.816 41.8933 14.6412 193.617   0    V
5    dose numeric 100   1   1       1  0.000 41.1900 14.5000 195.000   0    V
6    risk numeric 100   1   1       1  0.000  0.0392  0.0144   0.177   0    V
  outm
1 each
2 each
3 each
4 each
5 each
6 each

mc2d documentation built on July 5, 2021, 5:09 p.m.