Main Content

simulate

Simulate expected shortfall (ES) test statistics

Description

example

ebts = simulate(ebts) performs a simulation of ES test statistics. The simulate function simulates portfolio outcomes according to the distribution assumptions indicated in the esbacktestbysim object, and calculates all the supported test statistics under each scenario. The simulated test statistics are used to estimate the significance of the ES backtests.

example

ebts = simulate(ebts,Name,Value) adds optional name-value pair arguments.

Examples

collapse all

Create an esbacktestbysim object and run a simulation of 1000 scenarios.

load ESBacktestBySimData
rng('default'); % for reproducibility
ebts = esbacktestbysim(Returns,VaR,ES,"t",...
       'DegreesOfFreedom',10,...
       'Location',Mu,...
       'Scale',Sigma,...
       'PortfolioID',"S&P",...
       'VaRID',["t(10) 95%","t(10) 97.5%","t(10) 99%"],...
       'VaRLevel',VaRLevel);

The unconditional and minBiasAbsolute tests report 1000 scenarios (see the Scenarios column in the report).

unconditional(ebts) 
ans=3×10 table
    PortfolioID        VaRID        VaRLevel    Unconditional    PValue    TestStatistic    CriticalValue    Observations    Scenarios    TestLevel
    ___________    _____________    ________    _____________    ______    _____________    _____________    ____________    _________    _________

       "S&P"       "t(10) 95%"        0.95         accept        0.093       -0.13342         -0.16252           1966          1000         0.95   
       "S&P"       "t(10) 97.5%"     0.975         reject        0.031       -0.25011          -0.2268           1966          1000         0.95   
       "S&P"       "t(10) 99%"        0.99         reject        0.008       -0.57396         -0.38264           1966          1000         0.95   

minBiasAbsolute(ebts)
ans=3×10 table
    PortfolioID        VaRID        VaRLevel    MinBiasAbsolute    PValue    TestStatistic    CriticalValue    Observations    Scenarios    TestLevel
    ___________    _____________    ________    _______________    ______    _____________    _____________    ____________    _________    _________

       "S&P"       "t(10) 95%"        0.95          accept         0.062      -0.0014247       -0.0015578          1966          1000         0.95   
       "S&P"       "t(10) 97.5%"     0.975          reject         0.029      -0.0026674       -0.0023251          1966          1000         0.95   
       "S&P"       "t(10) 99%"        0.99          reject         0.005      -0.0060982       -0.0039004          1966          1000         0.95   

Run a second simulation with 5000 scenarios using the simulate function. Rerun the unconditional and minBiasAbsolute tests using the updated esbacktestbysim object. Notice that the tests now show 5,000 scenarios along with updated p-values and critical values.

ebts = simulate(ebts,'BlockSize',10000,'NumScenarios',5000,'TestList',["conditional","unconditional","quantile","minBiasAbsolute","minBiasRelative"]);   
unconditional(ebts) 
ans=3×10 table
    PortfolioID        VaRID        VaRLevel    Unconditional    PValue    TestStatistic    CriticalValue    Observations    Scenarios    TestLevel
    ___________    _____________    ________    _____________    ______    _____________    _____________    ____________    _________    _________

       "S&P"       "t(10) 95%"        0.95         accept        0.0952      -0.13342         -0.17352           1966          5000         0.95   
       "S&P"       "t(10) 97.5%"     0.975         reject        0.0456      -0.25011         -0.24318           1966          5000         0.95   
       "S&P"       "t(10) 99%"        0.99         reject         0.009      -0.57396         -0.38608           1966          5000         0.95   

minBiasAbsolute(ebts,"TestLevel",0.99)
ans=3×10 table
    PortfolioID        VaRID        VaRLevel    MinBiasAbsolute    PValue    TestStatistic    CriticalValue    Observations    Scenarios    TestLevel
    ___________    _____________    ________    _______________    ______    _____________    _____________    ____________    _________    _________

       "S&P"       "t(10) 95%"        0.95          accept         0.0622     -0.0014247       -0.0021797          1966          5000         0.99   
       "S&P"       "t(10) 97.5%"     0.975          accept          0.026     -0.0026674       -0.0032702          1966          5000         0.99   
       "S&P"       "t(10) 99%"        0.99          reject          0.006     -0.0060982       -0.0054814          1966          5000         0.99   

Input Arguments

collapse all

esbacktestbysim (ebts) object, which contains a copy of the given 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 esbacktestbysim object, see esbacktestbysim.

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: ebts = simulate(ebts,'NumScenarios',1000000,'BlockSize',10000,'TestList','conditional')

Number of scenarios to simulate, specified using the comma-separated pair consisting of 'NumScenarios' and a positive integer.

Data Types: double

Number of scenarios to simulate in a single simulation block, specified using the comma-separated pair consisting of 'BlockSize' and a positive integer.

Data Types: double

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 conditional, unconditional, quantile, minBiasAbsolute or minBiasRelative.

Data Types: char | cell | string

Output Arguments

collapse all

esbacktestbysim (ebts), returned as an updated object. After running simulate, the updated esbacktestbysim object stores the simulated test statistics, which are used to calculate p-values and generate test results.

For more information on an esbacktestbysim object, see esbacktestbysim.

More About

collapse all

Simulation of Test Statistics and Significance of the Tests

The VaR and ES models assume that for each period t, the portfolio outcomes Xt have a cumulative probability distribution Pt.

Under the assumption that the distributions Pt are correct (the null hypothesis), test statistics are simulated by:

  • Simulating M scenarios of N observations each, for example, Xs=(X1s,...,Xts,...,XNs), with Xts~Pt, t = 1,…,N, and s = 1,…,M.

  • For each simulated scenario Xs, compute the test statistic of interest Zs = Z(Xs), s = 1,…,M.

  • The resulting M simulated test statistic values Z1,…,ZM from a distribution of the test statistic assuming the probability distributions Pt are correct.

The p-value is defined as the proportion of scenarios for which the simulated test statistic is smaller than the test statistic evaluated at the observed portfolio outcomes: Zobs=Z(X1,...XN):

Pvalue=1Ms=1MI(ZsZobs)

where I(ZsZobs) is an indicator function with a value of 1 if ZsZobs, and 0 otherwise. If Ptest is 1 minus the test confidence level, the test result is to 'reject' if Pvalue<Ptest.

The critical value is defined as the minimum simulated test statistic Zcritwith a p-value greater than or equal to Ptest.

References

[1] Acerbi, C., and B. Szekely. Backtesting Expected Shortfall. MSCI Inc. December, 2014.

Version History

Introduced in R2017b