mcprobtree: Creates a Stochastic mcnode Object Using a Probability Tree

View source: R/mcprobtree.R

mcprobtreeR Documentation

Creates a Stochastic mcnode Object Using a Probability Tree

Description

Builds an ‘⁠mcnode⁠’ as a mixture of ‘⁠mcnode⁠’ objects.

Usage

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 ‘⁠mcnode⁠’s, ‘⁠mcdata⁠’ calls, or ‘⁠mcstoc⁠’ calls. Each element should be or lead to a compatible ‘⁠mcnode⁠’.

type

the type of ‘⁠mcnode⁠’ to be built. By default, a ‘⁠"V"⁠’ node.

nsv

the number of simulations in the variability dimension.

nsu

the number of simulations in the uncertainty dimension.

nvariates

the number of variates of the final ‘⁠mcnode⁠’.

outm

the default output for multivariate nodes. See outm.

seed

the random seed. If ‘⁠NULL⁠’ the seed is unchanged.

Details

‘⁠mcswitch⁠’ may be either:

  • a vector of weights (need not sum to one, must be nonneg and not all zero). Length must equal the number of elements in ‘⁠mcvalues⁠’.

  • a ‘⁠"0 mcnode"⁠’ to build any type of node.

  • a ‘⁠"V mcnode"⁠’ to build a ‘⁠"V"⁠’ or ‘⁠"VU"⁠’ node.

  • a ‘⁠"U mcnode"⁠’ to build a ‘⁠"U"⁠’ or ‘⁠"VU"⁠’ node.

  • a ‘⁠"VU mcnode"⁠’ to build a ‘⁠"VU"⁠’ node.

Names of elements in ‘⁠mcvalues⁠’ should correspond to values in ‘⁠mcswitch⁠’, specified as character. Elements are evaluated only if needed.

Value

An ‘⁠mcnode⁠’ object.

See Also

mcdata, mcstoc, switch.

Examples

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")
## Equivalent using weights
mcprobtree(c(.75, .20, .05), list("1"=conc1, "2"=conc2, "3"=conc3), type="VU")

mc2d documentation built on Oct. 23, 2026, 1:06 a.m.