simulate
Description
performs a simulation of the Du-Escanciano (DE) [1] expected shortfall (ES) test
statistics. ebtde
= simulate(ebtde
)simulate
simulates scenarios and calculates the
supported test statistics for each scenario. The function uses the simulated
test statistics to estimate the significance of the ES backtests when the
CriticalValueMethod
name-value pair argument for
unconditionalDE
or conditionalDE
is set to 'simulation'
.
specifies options using one or more name-value pair arguments in addition to the
input argument in the previous syntax.ebtde
= simulate(___,Name,Value
)
Examples
Create an esbacktestbyde
Object and Run a Simulation
Create an esbacktestbyde
object for a t model with 10 degrees of freedom. First, run a conditionalDE
test based on 1000 scenarios and then use the simulate
function to run a second simulation with 5000 scenarios.
load ESBacktestDistributionData.mat rng('default'); % For reproducibility % Constructor runs simulation with 1000 scenarios ebtde = esbacktestbyde(Returns,"t",... 'DegreesOfFreedom',T10DoF,... 'Location',T10Location,... 'Scale',T10Scale,... 'PortfolioID',"S&P",... 'VaRID',["t(10) 95%","t(10) 97.5%","t(10) 99%"],... 'VaRLevel',VaRLevel); % Run conditionalDE tests conditionalDE(ebtde,'CriticalValueMethod','simulation')
ans=3×13 table
PortfolioID VaRID VaRLevel ConditionalDE PValue TestStatistic CriticalValue AutoCorrelation Observations CriticalValueMethod NumLags Scenarios TestLevel
___________ _____________ ________ _____________ ______ _____________ _____________ _______________ ____________ ___________________ _______ _________ _________
"S&P" "t(10) 95%" 0.95 reject 0.003 15.285 3.2822 0.088175 1966 "simulation" 1 1000 0.95
"S&P" "t(10) 97.5%" 0.975 reject 0.006 16.177 3.9304 0.090711 1966 "simulation" 1 1000 0.95
"S&P" "t(10) 99%" 0.99 reject 0.037 6.9975 4.1995 0.05966 1966 "simulation" 1 1000 0.95
The tests report 1000 scenarios, see the Scenarios
column.
Run a second simulation with 5000 scenarios
ebtde = simulate(ebtde,'NumScenarios',5000); conditionalDE(ebtde,'CriticalValueMethod','simulation')
ans=3×13 table
PortfolioID VaRID VaRLevel ConditionalDE PValue TestStatistic CriticalValue AutoCorrelation Observations CriticalValueMethod NumLags Scenarios TestLevel
___________ _____________ ________ _____________ ______ _____________ _____________ _______________ ____________ ___________________ _______ _________ _________
"S&P" "t(10) 95%" 0.95 reject 0.0016 15.285 3.2535 0.088175 1966 "simulation" 1 5000 0.95
"S&P" "t(10) 97.5%" 0.975 reject 0.0046 16.177 3.7668 0.090711 1966 "simulation" 1 5000 0.95
"S&P" "t(10) 99%" 0.99 reject 0.0362 6.9975 3.8144 0.05966 1966 "simulation" 1 5000 0.95
The tests show 5000 scenarios and updated p-values and critical values.
Input Arguments
ebtde
— esbacktestbyde
object
object
esbacktestbyde
object, which contains a copy of the
data (the PortfolioData
, VarData
,
ESData
, and Distribution
properties) and all combinations of portfolio ID, VaR ID, and VaR levels
to be tested. For more information on creating an
esbacktestbyde
object, see esbacktestbyde
.
Name-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN
, where Name
is
the argument name and Value
is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Before R2021a, use commas to separate each name and value, and enclose
Name
in quotes.
Example: ebtde =
simulate(ebtde,'NumLags',10,'NumScenarios',1000000,'BlockSize',10000,'TestList','conditionalDE')
NumLags
— Number of lags in the conditionalDE
test statistic
5
(default) | positive integer
Number of lags in the conditionalDE
test
statistic, specified as the comma-separated pair consisting of
'NumLags'
and a positive integer. The
simulated test statistics are stored for all lags from
1
to NumLags
, so that the
conditionalDE
test results are available for any
number of lags between 1
and
NumLags
after running the
simulate
function.
Data Types: double
NumScenarios
— Number of scenarios to simulate
1000
(default) | scalar positive integer
Number of scenarios to simulate, specified using the
comma-separated pair consisting of 'NumScenarios'
and a scalar positive integer.
Data Types: double
BlockSize
— Number of scenarios to simulate in single simulation block
1000
(default) | scalar positive integer
Number of scenarios to simulate in a single simulation block,
specified using the comma-separated pair consisting of
'BlockSize'
and a scalar positive
integer.
Data Types: double
TestList
— Indicator for which test statistics to simulate
["conditionalDE","unconditionalDE"]
(default) | character vector with a value of
'conditionalDE'
or
'unconditionalDE'
| string with a value of "conditionalDE"
or
"unconditionalDE"
Indicator for which test statistics to simulate, specified as the
comma-separated pair consisting of 'TestList'
and
a cell array of character vectors or a string array with the value
'conditionalDE'
,
'unconditionalDE'
.
Data Types: cell
| string
Output Arguments
ebtde
— Updated esbacktestbyde
object
object
ebtde
is returned as an updated
esbacktestbyde
object. After you run
simulate
, the updated
esbacktestbyde
object stores the simulated test
statistics, which unconditionalDE
uses to calculate
p-values and generate test results.
For more information on the esbacktestbyde
object,
see esbacktestbyde
.
More About
Simulation of Test Statistics
The simulation of test statistics requires simulating scenarios of returns, assuming the distribution of returns Xt ~ Pt is correct (null hypothesis), and computing the corresponding tests statistics for each scenario.
More specifically, the following steps describe the simulation process. The description uses the conditional test statistic CES for concreteness, but the same steps apply to the unconditional test statistic UES.
Simulate M scenarios of returns as
Compute the corresponding test statistic as
Define PC as the empirical distribution of the simulated test statistic values as
where I(.) is the indicator function.
To compute the test statistic in step 2, the ranks or mapped returns
Ut =
Pt(Xt)
need to be computed (see the definition of the test statistics for unconditionalDE
and conditionalDE
). Assuming that the model distribution is correct,
the ranks Ut are
always uniformly distributed in the unit interval. Therefore, in practice,
directly simulating ranks is more efficient than simulating returns and then
transforming the returns into ranks.
The simulate
function implements the simulation process
more efficiently as follows:
Simulated M scenarios of returns as
Compute the corresponding test statistic CES using the simulated ranks Us as
Define PC as the empirical distribution of the simulated test statistic values as
After you determine the empirical distribution of the test statistic
PC in step 3,
the significance of the test follows the descriptions provided for unconditionalDE
and conditionalDE
. The same steps apply to the unconditional test
statistic UES and
its distribution function
PU.
References
[1] Du, Z., and J. C. Escanciano. "Backtesting Expected Shortfall: Accounting for Tail Risk." Management Science. Vol. 63, Issue 4, April 2017.
[2] Basel Committee on Banking Supervision. "Minimum Capital Requirements for Market Risk". January 2016 (https://www.bis.org/bcbs/publ/d352.pdf).
Version History
Introduced in R2019b
See Also
esbacktestbyde
| summary
| runtests
| unconditionalDE
| conditionalDE
| esbacktestbysim
Topics
- Workflow for Expected Shortfall (ES) Backtesting by Du and Escanciano
- Rolling Windows and Multiple Models for Expected Shortfall (ES) Backtesting by Du and Escanciano
- Expected Shortfall Estimation and Backtesting
- Overview of Expected Shortfall Backtesting
- ES Backtest Using Du-Escanciano Method
- Comparison of ES Backtesting Methods
Open Example
You have a modified version of this example. Do you want to open this example with your edits?
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)