Ops.mcnode: Operations on mcnode Objects

Description Usage Arguments Details Value See Also Examples

View source: R/Ops.mcnode.R

Description

This function alters the way operations are performed on mcnode objects for a better consistancy of the theory.

Usage

1
2
## S3 method for class 'mcnode'
Ops(e1, e2)

Arguments

e1

An mcnode object, a vector or an array.

e2

An optionnal mcnode object, a vector or a matrix with at least one of both objects as an mcnode.

Details

This method will be used for any of the Group Ops functions.

The rules are as following (illustrated with a + function and ignoring the nvariates dimension):

A vector or an array may be combined with an mcnode of size (nsv x nsu) if an mcnode of this dimension may be built from this vector/array using the mcdata function. See mcdata for the rules.

The outm attribute is transferred as following: each + each = each; none + other = other; other1 + other2 = other1. The outm attribute of the resulting node may be changed using the outm function.

For multivariate nodes, a recycling on the nvariates dimension is done if a (nsu x nsv x nvariates) node is combined with a (nsu x nsv x 1) node.

Value

The results as a mcnode object.

See Also

mcdata, mcstoc

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
oldvar <- ndvar()
oldunc <- ndunc()
ndvar(30)
ndunc(20)

## Given
x0 <- mcdata(3, type="0")
xV <- mcdata(1:ndvar(), type="V")
xU <- mcdata(1:ndunc(), type="U")
xVU <- mcdata(1:(ndunc()*ndvar()), type="VU")
x0M <- mcdata(c(5, 10), type="0", nvariates=2)
xVM <- mcdata(1:(2*ndvar()), type="V", nvariates=2)
xUM <- mcdata(1:(2*ndunc()), type="U", nvariates=2)
xVUM <- mcdata(1:(2*(ndunc()*ndvar())), type="VU", nvariates=2)

## All possible combinations
## "0"
-x0
x0 + 3

## "V"
-xV
3 + xV
xV * (1:ndvar())
xV * x0
xV - xV

## "U"
-xU
xU + 3
(1:ndunc()) * xU
xU * x0
xU - xU

## Watch out the resulting type
xV + xU
xU + xV

## "VU"
-xVU
3 + xVU
(1:(ndunc()*ndvar())) * xVU
xVU + xV
x0 + xVU
xU + xVU
xVU - xVU

## Some Multivariates
x0M+3
xVM * (1:ndvar())
xVM - xV
xUM - xU
xVUM - xU

mc2d documentation built on May 31, 2017, 5:01 a.m.

Search within the mc2d package
Search all R packages, documentation and source code