subsetvine: Subset a Regular Vine

Description Usage Arguments Details Value Examples

Description

Find the vine connecting a subset of variables from a bigger vine, if it exists. subsetvarray only finds the subset of a vine array.

Usage

1
2
3
4
## S3 method for class 'rvine'
subset(rv, select, justcheck = FALSE)

subsetvarray(G, select, justcheck = FALSE)

Arguments

rv

A regular vine object.

select

Vector of variables to subset, if possible. The order of the variables does not matter.

justcheck

Logical; should this function only check whether or not the subset exists? TRUE if so.

G

A vine array matrix.

Details

Just a technicality: by saying a subset "doesn't have an existing vine", I mean that a vine can't be formed using nodes and edges from the original – not that the joint distribution of the selected variables can't be created from a vine (so as to say, for example, that the simplifying assumption of vines doesn't hold for this distribution).

Value

If justcheck is TRUE, returns TRUE if the requested subset exists, and FALSE if not.

If justcheck is FALSE, returns a vine of the subsetted variables, with variables ordered according to their order in G; or NULL if the subset does not form a vine.

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
## Setup a vine.
G <- AtoG(CopulaModel::Dvinearray(5))
subsetvarray(G, c(2, 4, 3))

copmat <- makeuppertri(c("gum", "mtcj", "gal", "joe",
                         "frk", "gum", "bb7",
                         "bb1", "indepcop",
                         "bb8"), 4, 5, "")
cparmat <- makeuppertri.list(c(3, 2.5, 2, 1.5,
                               1, 1.3, 2, 2,
                               3, 4,
                               5, 0.5),
                               len = c(1,1,1,1,1,1,2,2,0,2),
                               4, 5)
(rv <- rvine(G, copmat, cparmat))

## Subset some variables.
subset(rv, c(2, 4, 3))
subset(rv, 5)
subset(rv, integer(0))

## This subset won't work:
subset(rv, c(4, 1), justcheck = TRUE)
## But it will in a 0-truncated vine:
subset(trunc(rv, 0), c(4, 1), justcheck = TRUE)
subset(trunc(rv, 0), c(4, 1))

## Select variables not present?
subset(rv, c(2, 4, 17))

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