risk_matrix: Computes the (binary) impact or vulnerability matrices

Description Usage Arguments Details Value Examples

View source: R/risk_matrices.R

Description

The function computes an impact or vulnerability matrix given a network of bilateral exposures and a vector of capital buffers.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
risk_matrix(
  exposures,
  buffer,
  binary = FALSE,
  exposure_type = c("assets", "liabilities", "impact", "vulnerability"),
  returns = c("impact", "vulnerability")
)

vulnerability_matrix(
  exposures,
  buffer,
  binary = FALSE,
  exposure_type = c("assets", "liabilities", "impact", "vulnerability")
)

impact_matrix(
  exposures,
  buffer,
  binary = FALSE,
  exposure_type = c("assets", "liabilities", "impact", "vulnerability")
)

Arguments

exposures

an adjacency matrix, (sparse) Matrix or an igraph object with the network of bilateral exposures between vertices. By default, the function expects the exposures in the form of an assets matrix in which A -> B means that A has an asset with B. However, you can change that with the parameter exposure_type. When using a matrix, preferably it should have rows and columns names.

buffer

a numeric vector with the capital buffer for each vertex. Values should be in the same row/column order as the network of bilateral exposures. The buffer is not needed if exposure_type = "vulnerability".

binary

if binary = TRUE the function computes a 'binary' impact or vulnerability matrix. It truncates all values less than 1 to 0 and all values greater than 1 to 1.

exposure_type

character vector indicating the type of the bilateral exposures. It can be an "assets" network (where A -> B means that A has an asset with B), a "liabilities" network (where A -> B means that A has a debt with B), a (binary) "impact" matrix (where A -> B indicates the relative impact of A in B's capital buffer), or a (binary) "vulnerability" matrix (where A -> B indicates the relative impact A suffers from B's default). The default is "assets".

returns

will the function return the impact or the vulnerability matrix? The default is "impact".

Details

The impact matrix represents how much a vertex impacts the capital buffer of another vertex when it defaults.

The vulnerability matrix is just the transpose of the impact matrix. It represents how much a vertex is impacted by the default of another vertex.

Value

The function returns a (binary) impact or vulnerability matrix.

The term V[i,j] of the impact matrix represents the impact of i's default in j's capital buffer.

The term V[i,j] of the vulnerability matrix represents how much i's capital buffer is impacted by j's default.

If binary = TRUE the values less than 1 are truncated to zero.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Creating example data
## Assets Matrix (bilateral exposures)
assets_matrix <- matrix(c(0, 10, 3, 1, 0, 2, 0, 3, 0), ncol = 3)
rownames(assets_matrix) <- colnames(assets_matrix) <- letters[1:3]

## Capital Buffer
buffer <- c(a = 2, b = 5, c = 2)

# Vulnerability matrices
vulnerability_matrix(assets_matrix, buffer, binary = FALSE)
vulnerability_matrix(assets_matrix, buffer, binary = TRUE)

Example output

Loading required package: Matrix
    a   b   c
a 0.0 0.5 0.0
b 2.0 0.0 0.6
c 1.5 1.0 0.0
  a b c
a 0 0 0
b 1 0 0
c 1 1 0

NetworkRiskMeasures documentation built on March 13, 2020, 3:24 a.m.