Systemic Risk
Editor's Note: This file was selected as MATLAB Central Pick of the Week
Systemic Risk
This framework calculates, analyses and compares the following systemic risk measures:
-
BUBBLES DETECTION MEASURES
BUB (Bubbles Flag)
BMPH (Boom Phases Flag)
BRPH (Burst Phases Flag)
BC (Bubbling Capitalization)
BCP (Bubbling Capitalization Percentage)
- References: Phillips et al. (2015), Phillips & Shi (2018), Phillips & Shi (2019), Brunnermeier et al. (2020)
-
COMPONENT MEASURES
-
AR (Absorption Ratio)
by Kritzman et al. (2010) -
CATFIN
by Allen et al. (2012) -
CS (Correlation Surprise)
by Kinlaw & Turkington (2012) -
TI (Turbulence Index)
by Kritzman & Li (2010) Principal Component Analysis
-
-
CONNECTEDNESS MEASURES
DCI (Dynamic Causality Index)
CIO ("In & Out" Connections)
CIOO ("In & Out - Other" Connections)
Network Centralities: Betweenness, Degree, Closeness, Clustering, Eigenvector & Katz
- References: Billio et al. (2011)
-
CROSS-ENTROPY MEASURES
JPoD (Joint Probability of Default)
FSI (Financial Stability Index)
PCE (Probability of Cascade Effects)
DiDe (Distress Dependency)
SI (Systemic Importance)
SV (Systemic Vulnerability)
CoJPoDs (Conditional Joint Probabilities of Default)
- References: Segoviano & Goodhart (2009), Radev (2012), Segoviano & Espinoza (2017), Cortes et al. (2018)
-
CROSS-QUANTILOGRAM MEASURES
Full Cross-Quantilograms
Partial Cross-Quantilograms
- References: Han et al. (2016)
-
CROSS-SECTIONAL MEASURES
Idiosyncratic Metrics: Beta, Value-at-Risk & Expected Shortfall
-
CAViaR (Conditional Autoregressive Value-at-Risk)
by White et al. (2015) -
CoVaR & Delta CoVaR (Conditional Value-at-Risk)
by Adrian & Brunnermeier (2008) -
MES (Marginal Expected Shortfall)
by Acharya et al. (2010) -
SES (Systemic Expected Shortfall)
by Acharya et al. (2010) -
SRISK (Conditional Capital Shortfall Index)
by Brownlees & Engle (2010)
-
DEFAULT MEASURES
-
D2C (Distance To Capital)
by Chan-Lau & Sy (2007) -
D2D (Distance To Default)
by Vassalou & Xing (2004) -
DIP (Distress Insurance Premium)
by Black et al. (2012) -
SCCA (Systemic Contingent Claims Analysis)
by Jobst & Gray (2013)
-
-
LIQUIDITY MEASURES
-
ILLIQ (Illiquidity Measure)
by Amihud (2002) -
RIS (Roll Implicit Spread)
by Hasbrouck (2009) Classic Indicators: Hui-Heubel Liquidity Ratio, Turnover Ratio & Variance Ratio
-
-
REGIME-SWITCHING MEASURES
2-States Model: High & Low Volatility
3-States Model: High, Medium & Low Volatility
4-States Model: High & Low Volatility With Corrections
AP (Average Probability of High Volatility)
JP (Joint Probability of High Volatility)
- References: Billio et al. (2010), Abdymomunov (2011)
-
SPILLOVER MEASURES
SI (Spillover Index)
Spillovers From & To
Net Spillovers
- References: Diebold & Yilmaz (2008), Diebold & Yilmaz (2012), Diebold & Yilmaz (2014)
-
TAIL DEPENDENCE MEASURES
-
ACHI (Average Chi)
by Balla et al. (2014) -
ADR (Asymptotic Dependence Rate)
by Balla et al. (2014) -
FRM (Financial Risk Meter)
by Mihoci et al. (2020)
-
Some of the aforementioned models have been improved or extended according to the methodologies described in the V-Lab Documentation, which represents a great source of systemic risk measurement.
The project has been published in "MATLAB Digest | Financial Services | May 2019"
.
If you found it useful to you, please consider making a donation to support its maintenance and development:
Requirements
The minimum required MATLAB
version is R2014b
. In addition, the following products and toolboxes must be installed in order to properly execute the script:
- Computer Vision System Toolbox
- Curve Fitting Toolbox
- Econometrics Toolbox
- Financial Toolbox
- Image Processing Toolbox
- Optimization Toolbox
- Parallel Computing Toolbox
- Statistics and Machine Learning Toolbox
- System Identification Toolbox
Usage
- Create a properly structured database (see the section below).
- Execute one of the following scripts (they can be edited following your needs and criteria):
-
run.m
to perform the computation of systemic risk measures; -
analyze.m
to analyze previously computed systemic risk measures.
-
Dataset
Datasets must be built following the structure of default ones included in every release of the framework (see Datasets
folder). Below a list of the supported Excel sheets and their respective content:
-
Shares: prices or returns expressed in logarithmic scale of the benchmark index (the column can be labeled with any desired name and must be placed just after observation dates) and the firms, with daily frequency.
-
Volumes: trading volume of the firms expressed in currency amount, with daily frequency.
-
Capitalizations: market capitalization of the firms, with daily frequency.
-
CDS: the risk-free rate expressed in decimals (the column must be called
RF
and must be placed just after observation dates) and the credit default swap spreads of the firms expressed in basis points, with daily frequency. -
Balance Sheet Components: the balance sheet components of the firms expressed in omogeneous observations frequency, currency and scale, structured as below:
- Assets: the book value of assets.
- Equity: the book value of equity.
- Separate Accounts: the separate accounts of insurance firms.
-
State Variables: systemic state variables, with daily frequency.
-
Groups: group definitions are based on three-value tuples where the
Name
field represents the group names, theShort Name
field represents the group acronyms and theCount
field represents the number of firms to include in the group. The sum of theCount
fields must be equal to the number of firms. For example, the following groups definition:Firms in the Shares Sheet: A, B, C, D, E, F, G, H
Insurance Companies: 2
Investment Banks: 2
Commercial Banks: 3
Government-sponsored Enterprises: 1produces the following outcome:
"Insurance Companies" contains A and B
"Investment Banks" contains C and D
"Commercial Banks" contains E, F and G
"Government-sponsored Enterprises" contains H -
Crises: crises can be defined using two different approaches:
-
By Events: based on two-value tuples where the
Date
field represents the event dates and theName
field represents the event names; every dataset observation matching an event date is considered to be associated to a distress occurrence. -
By Ranges: based on three-value tuples where the
Name
field represents the crisis names, theStart Date
field represents the crisis start dates and theEnd Date
field represents the crisis end dates; every dataset observation falling inside a crisis range is considered to be part of a distress period.
-
By Events: based on two-value tuples where the
Notes
-
The minimum allowed dataset must include the
Shares
sheet with a benchmark index and at least3
firms. Observations must have a daily frequency and, in order to run consistent calculations, their minimum required amount is253
for prices (which translates into a full business year plus an additional observation at the beginning of the time series, lost during the computation of returns) or252
for logarithmic returns. They must have been previously validated and preprocessed by:- discarding illiquid series (unless necessary);
- detecting and removing outliers;
- removing rows with NaNs or filling the gaps through interpolation.
-
It is not mandatory to include financial time series used by unwanted measures. Optional financial time series used by included measures can be omitted, as long as their contribution isn't necessary. Below a list of required and optional time series for each category of measures:
-
Bubbles Detection Measures:
- Required: shares (prices).
- Optional: none.
-
Component Measures:
- Required: shares (any).
- Optional: none.
-
Connectedness Measures:
- Required: shares (any).
- Optional: groups.
-
Cross-Entropy Measures:
- Required: shares (any), cds.
- Optional: capitalizations, balance sheet, groups.
-
Cross-Quantilogram Measures:
- Required: shares (any).
- Optional: state variables.
-
Cross-Sectional Measures:
- Required: shares (any), capitalizations, balance sheet.
- Optional: separate accounts, state variables.
-
Default Measures:
- Required: shares (any), capitalizations, cds, balance sheet.
- Optional: none.
-
Liquidity Measures:
- Required: shares (prices), volumes, capitalizations.
- Optional: state variables.
-
Regime-Switching Measures:
- Required: shares (any).
- Optional: none.
-
Spillover Measures:
- Required: shares (any).
- Optional: none.
-
Tail Dependence Measures:
- Required: shares (any).
- Optional: state variables.
-
Bubbles Detection Measures:
-
Firms whose time series value is constantly equal to
0
in the tail, for a span that includes a customizable percentage of total observations (by default5%
), are considered to bedefaulted
. Firms whoseEquity
value is constantly negative in the tail, for a span that includes a customizable percentage of total observations (by default5%
), are considered to beinsolvent
. This allows the scripts to exclude them from computations starting from a certain point in time onward; defaulted firms are excluded by all the measures, insolvent firms are excluded only bySCCA
default measures. -
Once a dataset has been parsed, the script stores its output in the form of a
.mat
file; therefore, the parsing process is executed only during the first run. The file last modification date is taken into account by the script and the dataset is parsed once again if theExcel
spreadsheet is modified. -
The dataset parsing process might present issues related to version, bitness and regional settings of the
OS
,Excel
and/orMATLAB
. Due to the high number of users asking for help, support is no more guaranteed; the guidelines below can help solving the majority of problems:- A bitness mismatch between the
OS
andExcel
may cause errors that are difficult to track. Using the same bitness for both is recommended. - An
Excel
locale other thanEnglish
may produce wrong outputs related to date formats, text values and numerical values with decimals and/or thousands separators. A locale switch is recommended. - Both
Excel 2019
andExcel 365
may present compatibility issues withMATLAB
versions prior toR2019b
. In later versions, the built-in functionreadtable
may still not handle someExcel
spreadsheets properly. A downgrade toExcel 2016
is recommended. - Some
Excel
spreadsheets might contain empty but defined cells in columns or rows located far away from the area in which data is stored. Those cells extend the range being read by the parser, producing false positives when checking for missing values. - The dataset parsing process takes place inside the
ScriptsDataset\parse_dataset.m
function. It is important to check the correctness of the arguments being passed to the function call. Error messages thrown by the aforementioned function are pretty straightforward and a debugging session should be enough to find the underlying causes and fix datasets and/or internal functions accordingly. - If the dataset parsing process is too slow, the best way to speed it up is to provide a standard
Excel
spreadsheet (.xlsx
) with no filters and styles, or a binaryExcel
spreadsheet (.xlsb
).
- A bitness mismatch between the
-
Some scripts may take very long time to finish in presence of huge datasets and/or extreme parametrizations. The performance of calculations may vary depending on the CPU processing speed and the number of CPU cores available for parallel computing.
Example Datasets
The Datasets
folder includes many premade datasets. The main one (Example_Large.xlsx
), based on the US financial sector, defines the following entities and data over a period of time ranging from 2002
to 2019
(both included):
Benchmark Index: S&P 500
Financial Institutions (20):
-
Group 1: Insurance Companies (5)
- American International Group Inc. (AIG)
- The Allstate Corp. (ALL)
- Berkshire Hathaway Inc. (BRK)
- MetLife Inc. (MET)
- Prudential Financial Inc. (PRU)
-
Group 2: Investment Banks (6)
- Bank of America Corp. (BAC)
- Citigroup Inc. (C)
- The Goldman Sachs Group Inc. (GS)
- J.P. Morgan Chase & Co. (JPM)
- Lehman Brothers Holdings Inc. (LEH)
- Morgan Stanley (MS)
-
Group 3: Commercial Banks (7)
- American Express Co. (AXP)
- Bank of New York Mellon Corp. (BK)
- Capital One Financial Corp. (COF)
- PNC Financial Services Inc. (PNC)
- State Street Corp. (STT)
- US Bancorp (USB)
- Wells Fargo & Co. (WFC)
-
Group 4: Government-sponsored Enterprises (2)
- Federal Home Loan Mortgage Corp / Freddie Mac (FMCC)
- Federal National Mortgage Association / Fannie Mae (FNMA)
Risk-Free Rate: 3M Treasury Bill Rate
State Variables (8):
- FFR: the effective federal funds rate.
- TBILL_DELTA: the percent change in the 3M treasury bill rate.
- CREDIT_SPREAD: the difference between the BAA corporate bond rate and the 10Y treasury bond rate.
- LIQUIDITY_SPREAD: the difference between the 3M GC repo rate and the 3M treasury bill rate.
- TED_SPREAD: the difference between the 3M USD LIBOR rate and the 3M treasury bill rate.
- YIELD_SPREAD: the difference between the 10Y treasury bond rate and the 3M treasury bond rate.
- DJ_CA_EXC: the excess returns of the DJ US Composite Average with respect to the S&P 500.
- DJ_RESI_EXC: the excess returns of the DJ US Select Real Estate Securities Index with respect to the S&P 500.
- VIX: the implied volatility index.
Screenshots
Cite As
Tommaso Belluzzo (2024). Systemic Risk (https://github.com/TommasoBelluzzo/SystemicRisk/releases/tag/v3.6.0), GitHub. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
- Computational Finance > Econometrics Toolbox >
- Computational Finance > Financial Toolbox > Financial Data Analytics >
- Computational Finance > Risk Management Toolbox >
- Computational Finance >
Tags
Acknowledgements
Inspired: Cross Quantilogram Matrix
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
ScriptsData
ScriptsDataset
ScriptsMeasures
ScriptsModels
ScriptsPlotting
ScriptsUtilities
Versions that use the GitHub default branch cannot be downloaded
Version | Published | Release Notes | |
---|---|---|---|
3.6.0.0 | See release notes for this release on GitHub: https://github.com/TommasoBelluzzo/SystemicRisk/releases/tag/v3.6.0 |
||
3.5.0 | See release notes for this release on GitHub: https://github.com/TommasoBelluzzo/SystemicRisk/releases/tag/v3.5.0 |
||
3.4.0 | See release notes for this release on GitHub: https://github.com/TommasoBelluzzo/SystemicRisk/releases/tag/v3.4.0 |
||
3.3.0 | See release notes for this release on GitHub: https://github.com/TommasoBelluzzo/SystemicRisk/releases/tag/v3.3.0 |
||
3.2.1 | See release notes for this release on GitHub: https://github.com/TommasoBelluzzo/SystemicRisk/releases/tag/v3.2.1 |
||
3.2.0 | See release notes for this release on GitHub: https://github.com/TommasoBelluzzo/SystemicRisk/releases/tag/v3.2.0 |
||
3.1.1 | See release notes for this release on GitHub: https://github.com/TommasoBelluzzo/SystemicRisk/releases/tag/v3.1.1 |
||
3.1.0 | See release notes for this release on GitHub: https://github.com/TommasoBelluzzo/SystemicRisk/releases/tag/v3.1.0 |
||
3.0.0 | See release notes for this release on GitHub: https://github.com/TommasoBelluzzo/SystemicRisk/releases/tag/v3.0.0 |
||
2.9.0 | See release notes for this release on GitHub: https://github.com/TommasoBelluzzo/SystemicRisk/releases/tag/v2.9.0 |
||
2.8.0 | See release notes for this release on GitHub: https://github.com/TommasoBelluzzo/SystemicRisk/releases/tag/v2.8.0 |
||
2.7.1 | See release notes for this release on GitHub: https://github.com/TommasoBelluzzo/SystemicRisk/releases/tag/v2.7.1 |
||
2.7.0 | See release notes for this release on GitHub: https://github.com/TommasoBelluzzo/SystemicRisk/releases/tag/v2.7.0 |
||
2.6.0 | See release notes for this release on GitHub: https://github.com/TommasoBelluzzo/SystemicRisk/releases/tag/v2.6.0 |
||
2.5.1 | See release notes for this release on GitHub: https://github.com/TommasoBelluzzo/SystemicRisk/releases/tag/v2.5.1 |
||
2.5.0 | See release notes for this release on GitHub: https://github.com/TommasoBelluzzo/SystemicRisk/releases/tag/v2.5.0 |
||
2.4.0 | See release notes for this release on GitHub: https://github.com/TommasoBelluzzo/SystemicRisk/releases/tag/v2.4.0 |
||
2.3.0 | See release notes for this release on GitHub: https://github.com/TommasoBelluzzo/SystemicRisk/releases/tag/v2.3.0 |
||
2.2.7 | Minor fixes and improvements. |
|
|
2.2.6 | New features, major rework. |
|
|
2.2.5 | Minor fixes and improvements. |
|
|
2.2.4 | Minor fixes and improvements. |
|
|
2.2.3 | Minor fixes and improvements. |
|
|
2.2.2 | Minor fixes and improvements. |
|
|
2.2.1 | New features, major reworks. |
|
|
2.2.0 | New features. |
|
|
2.1.9 | New features. |
|
|
2.1.8 | Minor fixes and improvements. |
|
|
2.1.7 | Major rework. |
|
|
2.1.6 | Minor fixes and improvements. |
|
|
2.1.5 | New features. |
|
|
2.1.4 | Improved description. |
|
|
2.1.3 | New features. |
|
|
2.1.2 | Minor fixes and improvements. |
|
|
2.1.1 | Minor fixes and improvements. |
|
|
2.1.0 | Major rework. |
|
|
2.0.3 | Minor fixes and improvements. |
|
|
2.0.2 | Minor fixes and improvements. |
|
|
2.0.1 | Minor fixes and improvements. |
|
|
2.0.0 | Major release. |
|
|
1.7.1 | Minor fixes and improvements. |
|
|
1.7.0 | Minor fixes and improvements. |
|
|
1.6.9 | Minor fixes and improvements. |
|
|
1.6.8 | Improved description. |
|
|
1.6.7 | Improved description. |
|
|
1.6.6 | New features. |
|
|
1.6.5 | Minor fixes and improvements. |
|
|
1.6.4 | Minor fixes and improvements. |
|
|
1.6.3 | Minor fixes and improvements. |
|
|
1.6.2 | Minor fixes and improvements. |
|
|
1.6.1 | Minor fixes and improvements. |
|
|
1.6.0 | Major refactoring, performance improvements, minor improvements and fixes. |
|
|
1.5.0 | Major refactoring, performance improvements, minor improvements and fixes. |
|
|
1.4.2 | Improved description. |
|
|
1.4.1 | Improved description. |
|
|
1.4.0 | Major refactoring, performance improvements, minor improvements and fixes. |
|
|
1.3.1 | Minor fixes and improvements. |
|
|
1.3.0 | Improved description. |
|
|
1.2.9 | Minor fixes and improvements. |
|
|
1.2.8 | Minor fixes and improvements. |
|
|
1.2.7 | Minor fixes and improvements. |
|
|
1.2.6 | Minor fixes and improvements. |
|
|
1.2.5 | Minor fixes and improvements. |
|
|
1.2.4 | Minor fixes and improvements. |
|
|
1.2.3 | Minor fixes and improvements. |
|
|
1.2.2 | Minor fixes and improvements. |
|
|
1.2.1 | Minor fixes and improvements. |
|
|
1.2.0 | Minor fixes and improvements. |
|
|
1.1.9 | Improved description. |
|
|
1.1.8 | Minor fixes and improvements. |
|
|
1.1.7 | Improved description. |
|
|
1.1.6 | Minor fixes and improvements. |
|
|
1.1.5 | Minor fixes and improvements. |
|
|
1.1.4 | Updated details concerning compatibility & requirements. |
|
|
1.1.3 | Minor fixes and improvements. |
|
|
1.1.2 | Minor fixes and improvements. |
|
|
1.1.1 | Project website. |
|
|
1.1.0 | Target release. |
|
|
1.0.9 | Improved tags. |
|
|
1.0.8 | Improved tags. |
|
|
1.0.7 | Improved tags. |
|
|
1.0.6 | Improved description. |
|
|
1.0.5 | Improved description. |
|
|
1.0.4 | Improved description. |
|
|
1.0.3 | Added screenshot. |
|
|
1.0.2 | Minor fixes and improvements. |
|
|
1.0.1 | Added details concerning compatibility & requirements. |
|
|
1.0.0.0 | Description
|
|