Description Usage Arguments Value References Examples
Given a matrix of exposures, a vector of buffers and weights (optional) the functions simulates contagion for all the shock vectors provided. You may choose from the implemented propagation contagion method or create you own propagation method. Details on how to create your own method will be provided in a future version.
1 2 3 4 5 6 7 8 9 10 11 |
exposures |
an adjacency |
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 |
shock |
a list with the shock vectors. If |
weights |
default is |
method |
the contagion propagation method. Currently, you should use either "debtrank" for the DebtRank propagation method or "threshold" for the traditional default
cascades. The DebtRank version implemented is the one proposed in Bardoscia et al (2015).
If you want to use the old "single-hit" DebtRank of Battiston et al (2012), simply provide the argument |
... |
other arguments to be passed to the contagion propagation method. |
exposure_type |
character vector indicating the type of the bilateral exposures. It can be
an |
keep.history |
keep all the history of stress levels? This can use a lot of memory, so
the default is |
abs.tol |
the desired accuracy. |
max.it |
the maximum number of iterations. |
verbose |
gives verbose output. Default is |
The function returns an object of class "contagion"
with the results of the simulation.
Bardoscia M, Battiston S, Caccioli F, Caldarelli G (2015) DebtRank: A Microscopic Foundation for Shock Propagation. PLoS ONE 10(6): e0130406. doi: 10.1371/journal.pone.0130406
Battiston, S., Puliga, M., Kaushik, R., Tasca, P., and Caldarelli, G. (2012). DebtRank: Too central to fail? Financial networks, the FED and systemic risk. Scientific reports, 2:541.
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 | # Loads simulated banking data
data("sim_data")
head(sim_data)
# seed for reproducibility
set.seed(15)
# minimum density estimation
# verbose = F to prevent printing
md_mat <- matrix_estimation(sim_data$assets, sim_data$liabilities, method = "md", verbose = FALSE)
# rownames and colnames for the matrix
rownames(md_mat) <- colnames(md_mat) <- sim_data$bank
# DebtRank simulation
contdr <- contagion(exposures = md_mat, buffer = sim_data$buffer, weights = sim_data$weights,
shock = "all", method = "debtrank", verbose = FALSE)
summary(contdr)
plot(contdr)
# Traditional default cascades simulation
contthr <- contagion(exposures = md_mat, buffer = sim_data$buffer, weights = sim_data$weights,
shock = "all", method = "threshold", verbose = FALSE)
summary(contthr)
# simulating shock scenarios 1% to 25% shock in all vertices
s <- seq(0.01, 0.25, by = 0.01)
shocks <- lapply(s, function(x) rep(x, nrow(md_mat)))
names(shocks) <- paste(s*100, "pct shock")
cont <- contagion(exposures = md_mat, buffer = sim_data$buffer, shock = shocks,
weights = sim_data$weights, method = "debtrank", verbose = FALSE)
summary(cont)
plot(cont)
|
Loading required package: Matrix
bank assets liabilities buffer weights
1 b1 0.37490927 9.6317127 5.628295 17.119551
2 b2 0.66805904 0.7126552 2.847072 6.004475
3 b3 0.79064804 0.3089983 3.983451 6.777531
4 b4 0.02420156 0.6562193 5.657779 7.787618
5 b5 0.65294261 0.9153901 4.446595 8.673730
6 b6 0.60766835 0.3007373 2.252369 4.708805
Contagion Simulations Summary
Info:
Propagation Function: debtrank
With parameters:
data frame with 0 columns and 0 rows
Simulation summary (showing 10 of 125 -- decreasing order of additional stress):
Scenario Original Stress Additional Stress Original Losses Additional Losses
b55 0.1102 0.280 58.4 235.8
b28 0.0638 0.182 63.5 99.3
b84 0.0236 0.117 7.6 65.7
b69 0.0133 0.114 13.0 36.6
b75 0.0099 0.113 9.6 30.5
b33 0.0243 0.088 27.4 33.6
b120 0.0099 0.077 8.4 18.1
b77 0.0067 0.065 9.4 8.9
b74 0.0161 0.064 14.4 27.9
b101 0.0070 0.060 9.3 17.1
Additional Defaults
17
8
2
2
2
2
2
1
3
2
Contagion Simulations Summary
Info:
Propagation Function: threshold
With parameters:
data frame with 0 columns and 0 rows
Simulation summary (showing 10 of 125 -- decreasing order of additional stress):
Scenario Original Stress Additional Stress Original Losses Additional Losses
b55 0.1102 0.273 58.4 221.1
b28 0.0638 0.167 63.5 88.4
b84 0.0236 0.098 7.6 62.0
b69 0.0133 0.096 13.0 34.1
b75 0.0099 0.095 9.6 28.1
b120 0.0099 0.075 8.4 17.0
b27 0.0173 0.059 20.5 18.8
b74 0.0161 0.056 14.4 26.1
b101 0.0070 0.052 9.3 15.6
b80 0.0084 0.051 9.2 7.5
Additional Defaults
16
7
2
2
2
2
3
3
2
1
Contagion Simulations Summary
Info:
Propagation Function: debtrank
With parameters:
data frame with 0 columns and 0 rows
Simulation summary (showing 10 of 25 -- decreasing order of additional stress):
Scenario Original Stress Additional Stress Original Losses
23 pct shock 0.23 0.25 182
22 pct shock 0.22 0.25 174
21 pct shock 0.21 0.25 166
24 pct shock 0.24 0.25 190
20 pct shock 0.20 0.25 158
25 pct shock 0.25 0.25 198
19 pct shock 0.19 0.25 150
18 pct shock 0.18 0.25 142
17 pct shock 0.17 0.24 134
16 pct shock 0.16 0.24 127
Additional Losses Additional Defaults
179 14
173 13
167 12
185 15
161 11
191 16
155 10
149 10
142 10
136 10
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.