as_rvine_structure {rvinecopulib}R Documentation

Coerce various kind of objects to R-vine structures and matrices

Description

as_rvine_structure and as_rvine_matrix are new S3 generics allowing to coerce objects into R-vine structures and matrices (see rvine_structure() and rvine_matrix()).

Usage

as_rvine_structure(x, ...)

as_rvine_matrix(x, ...)

## S3 method for class 'rvine_structure'
as_rvine_structure(x, ..., validate = FALSE)

## S3 method for class 'rvine_structure'
as_rvine_matrix(x, ..., validate = FALSE)

## S3 method for class 'list'
as_rvine_structure(x, ..., is_natural_order = FALSE)

## S3 method for class 'list'
as_rvine_matrix(x, ..., is_natural_order = FALSE)

## S3 method for class 'rvine_matrix'
as_rvine_structure(x, ..., validate = FALSE)

## S3 method for class 'rvine_matrix'
as_rvine_matrix(x, ..., validate = FALSE)

## S3 method for class 'matrix'
as_rvine_structure(x, ..., validate = TRUE)

## S3 method for class 'matrix'
as_rvine_matrix(x, ..., validate = TRUE)

Arguments

x

An object of class rvine_structure, rvine_matrix, matrix or list that can be coerced into an R-vine structure or R-vine matrix (see Details).

...

Other arguments passed on to individual methods.

validate

When 'TRUE“, verifies that the input is a valid rvine-structure (see Details). You may want to suppress this when you know that you already have a valid structure and you want to save some time, or to explicitly enable it if you have a structure that you want to re-check.

is_natural_order

A flag indicating whether the struct_array element of x is assumed to be provided in natural order already (a structure is in natural order if the anti-diagonal is 1, .., d from bottom left to top right).

Details

The coercion to rvine_structure and rvine_matrix can be applied to different kind of objects Currently, rvine_structure, rvine_matrix, matrix and list are supported.

For as_rvine_structure:

For as_rvine_matrix:

Value

Either an object of class rvine_structure or of class rvine_matrix (see rvine_structure() or rvine_matrix()).

See Also

rvine_structure rvine_matrix

Examples

# R-vine structures can be constructed from the order vector and struct_array
rvine_structure(order = 1:4, struct_array = list(
  c(4, 4, 4),
  c(3, 3),
  2
))

# ... or a similar list can be coerced into an R-vine structure
as_rvine_structure(list(order = 1:4, struct_array = list(
  c(4, 4, 4),
  c(3, 3),
  2
)))

# similarly, standard matrices can be coerced into R-vine structures
mat <- matrix(c(4, 3, 2, 1, 4, 3, 2, 0, 4, 3, 0, 0, 4, 0, 0, 0), 4, 4)
as_rvine_structure(mat)

# or truncate and construct the structure
mat[3, 1] <- 0
as_rvine_structure(mat)

# throws an error
mat[3, 1] <- 5
try(as_rvine_structure(mat))

[Package rvinecopulib version 0.6.3.1.1 Index]