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 test reports 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   

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

ebts = simulate(ebts,'NumScenarios',5000);   
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.0984      -0.13342         -0.17216           1966          5000         0.95   
       "S&P"       "t(10) 97.5%"     0.975         reject        0.0456      -0.25011         -0.24251           1966          5000         0.95   
       "S&P"       "t(10) 99%"        0.99         reject        0.0104      -0.57396         -0.40089           1966          5000         0.95   

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 Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

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, or quantile.

Data Types: 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.

Introduced in R2017b