reorder: Reorder a Vine, If Possible

Description Usage Arguments Value Examples

View source: R/reorder.R

Description

These functions reorder a vine according to a user-specified order. reordervarray reorders a vine array only, whereas reorder.rvine reorders an "rvine" object.

Usage

1
2
3
4
reordervarray(G, ord)

## S3 method for class 'rvine'
reorder(rv, ord)

Arguments

G

Vine array matrix

ord

Vector consisting of the variables in G or rv, in the order you want them to be in.

rv

Object of type "rvine"

Value

Returns NULL if the vine cannot be re-ordered in the requested manner. Otherwise, the re-ordered vine array (reordervarray) or "rvine" object (reorder.rvine) is returned.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## reordervarray:
G <- AtoG(CopulaModel::Dvinearray(5))
reordervarray(G, 5:1)
reordervarray(truncvarray(G, c(0, 1, 2, 1, 3)), c(3, 2, 4, 1, 5))
reordervarray(G, c(5, 1, 4, 2, 3)) # NULL
reordervarray(G, c(5:1, 87)) # Error


## reorder.rvine:
copmat <- makevinemat("a", c("b","c"), letters[4:6], letters[7:10], zerocol=T)
cparmat <- makevinemat(1, 2:3, 4:6, 7:10, zerocol=T)
rv <- rvine(G, copmat, cparmat)
reorder(rv, 5:1)
reorder(rv, c(3, 2, 4, 1, 5))
reorder(rv, c(5, 1, 4, 2, 3)) # NULL
reorder(rv, c(5:1, 87)) # Error

## Trivial cases:
reordervarray(matrix(0,1,0), integer(0))
reorder(rvine(matrix(5)), 5)

vincenzocoia/copsupp documentation built on Aug. 23, 2020, 7:37 a.m.