mcnode: Build mcnode Objects from Data or other mcnode Objects

Description Usage Arguments Details Value See Also Examples

Description

Creates a mcnode object from a vector, an array or a mcnode.

Usage

1
2
3
4
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 the 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 multivariates nodes. May be "each" (default) if output should be provided for each variates considered independently, "none" for no output or a vector of name of function(s) (as a character string) that will be applied on the variates dimension before any output (ex: "mean", "median", c("min", "max")). The function should have no other arguments and send one value per vector of values (ex. do not use "range"). Note that the outm attribute may be changed at any time using the outm function.

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 of mcnode exists:

Multivariate nodes (i.e. nvariates != 1) should be used for multivariate distributions implemented in mc2d (rmultinomial, rmultinormal, rempiricalD and rdirichlet).

For security, recycling rules are limited to fill the array using data. The general rules is that recycling is only permitted to fill a dimension from 1 to the final size of the dimension.

If the final dimension of the node is (nsv x nsu x nvariates) (with nsv = 1 and nsu = 1 for "0" nodes, nsu = 1 for "V" nodes and nsv = 1 for "U" nodes), mcdata accepts :

mcdatanocontrol is a dangerous version of mcnode which forces the dimension of data to be (nsv x nsu x nvariates) and gives the atributes and the class without any control. This function is useful when your model is tested since it is much more quicker.

Value

An mcnode object.

See Also

mcstoc to build a stochastic mcnode object, mcprobtree to build a stochastic node fro a probability tree.

Ops.mcnode for operations on mcnode objects.

mc to build a Monte-Carlo object.

Informations about an mcnode: is.mcnode, dimmcnode, typemcnode.

To build a correlation structure between mcnode: cornode.

To study mcnode objects: print.mcnode, summary.mcnode, plot.mcnode, converg, hist.mcnode

To modify mcnode objects: NA.mcnode

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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
oldvar <- ndvar()
oldunc <- ndunc()
ndvar(3)
ndunc(5)

(x0 <- mcdata(100, type="0"))
mcdata(matrix(100), type="0")

(xV <- mcdata(1:ndvar(), type="V"))
mcdata(matrix(1:ndvar(), ncol=1), type="V")

(xU <- mcdata(10*1:ndunc(), type="U"))
mcdata(matrix(10*1:ndunc(), nrow=1), type="U")

(xVU <- mcdata(1:(ndvar()*ndunc()), type="VU"))
mcdata(matrix(1:(ndvar()*ndunc()), ncol=5, nrow=3), type="VU")

##Do not use
## Not run: 
mcdata(matrix(1:5, nrow=1), type="VU")

## End(Not run)
##use instead
mcdata(mcdata(matrix(1:ndunc(), nrow=1), type="U"), "VU")
##or
mcdata(matrix(1:ndunc(), nrow=1), type="U") + mcdata(0, "VU")

mcdata(x0, type="0")

mcdata(x0, type="V")
mcdata(xV, type="V")

mcdata(x0, type="U")
mcdata(xU, type="U")

mcdata(x0, type="VU")
mcdata(xU, type="VU")
mcdata(xV, type="VU")

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

(xVM <- mcdata(1:(2*ndvar()), type="V", nvariates=2))
mcdata(1:ndvar(), type="V", nvariates=2)
mcdata(array(1:(2*ndvar()), dim=c(3, 1, 2)), type="V", nvariates=2)

mcdata(1, type="V", nvariates=2)
mcdata(x0, type="V", nvariates=2)
mcdata(x0M, type="V", nvariates=2)
mcdata(xV, type="V", nvariates=2)
mcdata(xVM, type="V", nvariates=2)

(xUM <- mcdata(10*(1:(2*ndunc())), type="U", nvariates=2))
mcdata(array(10*(1:(2*ndunc())), dim=c(1, 5, 2)), type="U", nvariates=2)

mcdata(1, type="U", nvariates=2)
mcdata(x0, type="U", nvariates=2)
mcdata(x0M, type="U", nvariates=2)
mcdata(xU, type="U", nvariates=2)
mcdata(xUM, type="U", nvariates=2)

(xVUM <- mcdata(1:(ndvar()*ndunc()), type="VU", nvariates=2))
mcdata(array(1:(ndvar()*ndunc()), dim=c(3, 5, 2)), type="VU", nvariates=2)

mcdata(1, type="VU", nvariates=2)
mcdata(x0, type="VU", nvariates=2)
mcdata(x0M, type="VU", nvariates=2)
mcdata(xV, type="VU", nvariates=2)
mcdata(xVM, type="VU", nvariates=2)
mcdata(xU, type="VU", nvariates=2)
mcdata(xUM, type="VU", nvariates=2)
mcdata(xVU, type="VU", nvariates=2)
mcdata(xVUM, type="VU", nvariates=2)

ndvar(oldvar)
ndunc(oldunc)

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