mcnode: Build mcnode Objects from Data

mcnodeR Documentation

Build mcnode Objects from Data

Description

Creates a ‘⁠mcnode⁠’ object from a vector, an array or another ‘⁠mcnode⁠’.

‘⁠mcdatanocontrol⁠’ is a fast but unchecked version of mcdata which forces the dimension of data to be ‘⁠(nsv x nsu x nvariates)⁠’ and sets the attributes and class without any validation. Useful when your model is tested and speed is important.

Usage

mcdata(
  data,
  type = c("V", "U", "VU", "0"),
  nsv = ndvar(),
  nsu = ndunc(),
  nvariates = 1,
  outm = "each"
)

mcdatanocontrol(
  data,
  type = c("V", "U", "VU", "0"),
  nsv = ndvar(),
  nsu = ndunc(),
  nvariates = 1,
  outm = "each"
)

Arguments

data

the numeric/logical vector/matrix/array of data or a ‘⁠mcnode⁠’ object.

type

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

nsv

the variability dimension (‘⁠type="V"⁠’ or ‘⁠type="VU"⁠’) of the node. By default: the current value in mc.control.

nsu

the uncertainty dimension (‘⁠type="U"⁠’ or ‘⁠type="VU"⁠’) of the node. By default: the current value in mc.control.

nvariates

the number of variates. By default: 1.

outm

the output of the ‘⁠mcnode⁠’ for multivariate nodes. May be ‘⁠"each"⁠’ (default), ‘⁠"none"⁠’, or a vector of function names applied on the variates dimension before any output.

Details

A ‘⁠mcnode⁠’ object is the basic element of a mc object. It is an array of dimension ‘⁠(nsv x nsu x nvariates)⁠’. Four types exist:

‘⁠"V" mcnode⁠’

for "Variability", arrays of dimension ‘⁠(nsv x 1 x nvariates)⁠’. The variability of the data should reflect parameter variability.

‘⁠"U" mcnode⁠’

for "Uncertainty", arrays of dimension ‘⁠(1 x nsu x nvariates)⁠’. The variability reflects parameter uncertainty.

‘⁠"VU" mcnode⁠’

for "Variability and Uncertainty", arrays of dimension ‘⁠(nsv x nsu x nvariates)⁠’.

‘⁠"0" mcnode⁠’

for "Neither Variability nor Uncertainty", arrays of dimension ‘⁠(1 x 1 x nvariates)⁠’.

Multivariate nodes (‘⁠nvariates != 1⁠’) should be used for multivariate distributions (rmultinomial, rmultinormal, rempiricalD, rdirichlet).

Recycling rules are limited: recycling is only permitted to fill a dimension from 1 to the final size of the dimension.

Value

An ‘⁠mcnode⁠’ object.

See Also

mcstoc to build a stochastic ‘⁠mcnode⁠’ object. mc to build a Monte-Carlo object. is.mcnode, dimmcnode, typemcnode.

Examples

oldvar <- ndvar()
oldunc <- ndunc()
ndvar(3)
ndunc(5)

(x0 <- mcdata(100, type = "0"))
(xV <- mcdata(1:ndvar(), type = "V"))
(xU <- mcdata(10 * 1:ndunc(), type = "U"))
(xVU <- mcdata(1:(ndvar() * ndunc()), type = "VU"))

## Multivariates
(x0M <- mcdata(1:2, type = "0", nvariates = 2))
(xVM <- mcdata(1:(2 * ndvar()), type = "V", nvariates = 2))

ndvar(oldvar)
ndunc(oldunc)

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