Main Content

runtests

Run all tests in varbacktest

Description

TestResults = runtests(vbt) runs all the tests in the varbacktest object. runtests reports only the final test result. For test details such as likelihood ratios, run individual tests:

  • tl — Traffic light test

  • bin — Binomial test

  • pof — Proportion of failures

  • tuff — Time until first failure

  • cc — Conditional coverage mixed

  • cci — Conditional coverage independence

  • tbf — Time between failures mixed

  • tbfi — Time between failures independence

example

TestResults = runtests(vbt,Name,Value) adds an optional name-value pair argument for TestLevel.

example

Examples

collapse all

Create a varbacktest object.

load VaRBacktestData
vbt = varbacktest(EquityIndex,Normal95)
vbt = 
  varbacktest with properties:

    PortfolioData: [1043x1 double]
          VaRData: [1043x1 double]
             Time: [1043x1 double]
      PortfolioID: "Portfolio"
            VaRID: "VaR"
         VaRLevel: 0.9500

Generate the TestResults report for all VaR backtests.

TestResults = runtests(vbt,'TestLevel',0.99)
TestResults=1×11 table
    PortfolioID    VaRID    VaRLevel     TL       Bin       POF       TUFF       CC       CCI       TBF       TBFI 
    ___________    _____    ________    _____    ______    ______    ______    ______    ______    ______    ______

    "Portfolio"    "VaR"      0.95      green    accept    accept    accept    accept    accept    reject    reject

Generate the TestResults report for all VaR backtests using the name-value argument for 'ShowDetails' to display the test confidence level.

TestResults = runtests(vbt,'TestLevel',0.99,"ShowDetails",true)
TestResults=1×12 table
    PortfolioID    VaRID    VaRLevel     TL       Bin       POF       TUFF       CC       CCI       TBF       TBFI     TestLevel
    ___________    _____    ________    _____    ______    ______    ______    ______    ______    ______    ______    _________

    "Portfolio"    "VaR"      0.95      green    accept    accept    accept    accept    accept    reject    reject      0.99   

Use the varbacktest constructor with name-value pair arguments to create a varbacktest object and run all tests.

load VaRBacktestData
    vbt = varbacktest(EquityIndex,...
       [Normal95 Normal99 Historical95 Historical99 EWMA95 EWMA99],...
       'PortfolioID','Equity',...
       'VaRID',{'Normal95' 'Normal99' 'Historical95' 'Historical99' 'EWMA95' 'EWMA99'},...
       'VaRLevel',[0.95 0.99 0.95 0.99 0.95 0.99]);
    runtests(vbt)
ans=6×11 table
    PortfolioID        VaRID         VaRLevel      TL       Bin       POF       TUFF       CC       CCI       TBF       TBFI 
    ___________    ______________    ________    ______    ______    ______    ______    ______    ______    ______    ______

     "Equity"      "Normal95"          0.95      green     accept    accept    accept    accept    accept    reject    reject
     "Equity"      "Normal99"          0.99      yellow    reject    accept    accept    accept    accept    accept    accept
     "Equity"      "Historical95"      0.95      green     accept    accept    accept    accept    accept    reject    reject
     "Equity"      "Historical99"      0.99      green     accept    accept    accept    accept    accept    accept    accept
     "Equity"      "EWMA95"            0.95      green     accept    accept    accept    accept    accept    accept    accept
     "Equity"      "EWMA99"            0.99      yellow    reject    reject    accept    reject    accept    reject    accept

Input Arguments

collapse all

varbacktest (vbt) object, contains a copy of the given data (the PortfolioData and VarData properties) and all combinations of portfolio ID, VaR ID, and VaR levels to be tested. For more information on creating a varbacktest object, see varbacktest.

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: TestResults = runtests(vbt,'TestLevel',0.99)

Test confidence level, specified as the comma-separated pair consisting of 'TestLevel' and a numeric between 0 and 1.

Data Types: double

Indicates if the output displays a column showing the test confidence level, specified as the comma-separated pair consisting of 'ShowDetails' and a scalar logical value.

Data Types: logical

Output Arguments

collapse all

Results, returned as a table where the rows correspond to all combinations of portfolio ID, VaR ID, and VaR levels to be tested. The columns correspond to the following information:

  • 'PortfolioID' — Portfolio ID for the given data

  • 'VaRID' — VaR ID for each of the VaR data columns provided

  • 'VaRLevel' — VaR level for the corresponding VaR data column

  • 'TL' — Categorical (ordinal) array with categories green, yellow, and red that indicate the result of the traffic light (tl) test

  • 'Bin' — Categorical array with categories accept and reject that indicate the result of the bin test

  • 'POF' — Categorical array with the categories accept and reject that indicate the result of the pof test.

  • 'TUFF' — Categorical array with the categories accept and reject that indicate the result of the tuff test

  • 'CC' — Categorical array with the categories accept and reject that indicate the result of the cc test

  • 'CCI' — Categorical array with the categories accept and reject that indicate the result of the cci test

  • 'TBF' — Categorical array with the categories accept and reject that indicate the result of the tbf test

  • 'TBFI' — Categorical array with the categories accept and reject that indicate the result of the tbfi test

Note

For the test results, the terms 'accept' and 'reject' are used for convenience, technically a test does not accept a model. Rather, a test fails to reject it.

Version History

Introduced in R2016b