mcprobtree: Creates a Stochastic mcnode Object using a Probability Tree

Description Usage Arguments Details Value See Also Examples

View source: R/mcprobtree.R

Description

This function builds an mcnode as a mixture mcnode objects.

Usage

1
2
mcprobtree(mcswitch, mcvalues, type=c("V", "U", "VU", "0"), nsv=ndvar(),
	  nsu=ndunc(), nvariates=1, outm="each", seed=NULL)

Arguments

mcswitch

A vector of probabilities/weights or an mcnode.

mcvalues

A named list of mcnodes, mcdata functions or mcstoc functions, or a combination of those objects. Each element should be or lead to a compatible mcnode (see Details).

type

The type of mcnode to be built. By default, a "V" node. see mcnode for details.

nsv

The number of simulations in the variability dimension of the final node.

nsu

The number of simulations in the uncertainty dimension of the final node.

nvariates

The number of variates of the final mcnode.

outm

The default output of the mcnode for multivariates nodes. see outm.

seed

The random seed used for the evaluation. If NULL the seed is unchanged.

Details

mcswitch may be either:

Each elements of mcvalues may be either:

Their name should correspond to the values in mcswitch, specified as character (See Examples). These elements will be evaluated only if needed : if the corresponding value is not present in mcswitch, the element will not be evaluated.

Value

An mcnode object.

See Also

mcdata, mcstoc, switch.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
## A mixture of normal (prob=0.75), uniform (prob=0.20) and constant (prob=0.05)
conc1 <- mcstoc(rnorm, type="VU", mean=10, sd=2)
conc2 <- mcstoc(runif, type="VU", min=-6, max=-5)
conc3 <- mcdata(0, type="VU")

## Randomly in the cells 
whichdist <- mcstoc(rempiricalD, type="VU", values=1:3, prob= c(.75, .20, .05)) 
mcprobtree(whichdist, list("1"=conc1, "2"=conc2, "3"=conc3), type="VU")
## Which is equivalent to 
mcprobtree(c(.75, .20, .05), list("1"=conc1, "2"=conc2, "3"=conc3), type="VU")
## Not that there is no control on the exact number of occurences.

## Randomly by colums (Uncertainty) 
whichdist <- mcstoc(rempiricalD, type="U", values=1:3, prob= c(.75, .20, .05)) 
mcprobtree(whichdist, list("1"=conc1, "2"=conc2, "3"=conc3), type="VU")

## Randomly by line (Variability) 
whichdist <- mcstoc(rempiricalD, type="V", values=1:3, prob= c(.75, .20, .05)) 
mcprobtree(whichdist, list("1"=conc1, "2"=conc2, "3"=conc3), type="VU")

## The elements of mcvalues may be of various (but compatible) type
conc1 <- mcstoc(rnorm, type="V", mean=10, sd=2)
conc2 <- mcstoc(runif, type="U", min=-6, max=-5)
conc3 <- mcdata(0, type="0")
whichdist <- mcstoc(rempiricalD, type="VU", values=1:3, prob= c(.75, .20, .05))
mcprobtree(whichdist, list("1"=conc1, "2"=conc2, "3"=conc3), type="VU")

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