Main Content

tbf

Time between failures mixed test for value-at-risk (VaR) backtesting

Description

example

TestResults = tbf(vbt) generates the time between failures mixed test (TBF) for value-at-risk (VaR) backtesting.

example

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

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 tbf test results.

TestResults = tbf(vbt)
TestResults=1×20 table
    PortfolioID    VaRID    VaRLevel     TBF      LRatioTBF    PValueTBF     POF      LRatioPOF    PValuePOF     TBFI     LRatioTBFI    PValueTBFI    Observations    Failures    TBFMin    TBFQ1    TBFQ2    TBFQ3    TBFMax    TestLevel
    ___________    _____    ________    ______    _________    _________    ______    _________    _________    ______    __________    __________    ____________    ________    ______    _____    _____    _____    ______    _________

    "Portfolio"    "VaR"      0.95      reject     88.952      0.0055565    accept     0.46147      0.49694     reject      88.491      0.0047475         1043           57         1         3        9      25.25      85        0.95   

Use the varbacktest constructor with name-value pair arguments to create a varbacktest object.

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])
vbt = 
  varbacktest with properties:

    PortfolioData: [1043x1 double]
          VaRData: [1043x6 double]
             Time: [1043x1 double]
      PortfolioID: "Equity"
            VaRID: ["Normal95"    "Normal99"    "Historical95"    "Historical99"    "EWMA95"    "EWMA99"]
         VaRLevel: [0.9500 0.9900 0.9500 0.9900 0.9500 0.9900]

Generate the tbf test results using the TestLevel optional input.

TestResults = tbf(vbt,'TestLevel',0.90)
TestResults=6×20 table
    PortfolioID        VaRID         VaRLevel     TBF      LRatioTBF    PValueTBF     POF      LRatioPOF    PValuePOF     TBFI     LRatioTBFI    PValueTBFI    Observations    Failures    TBFMin    TBFQ1    TBFQ2    TBFQ3    TBFMax    TestLevel
    ___________    ______________    ________    ______    _________    _________    ______    _________    _________    ______    __________    __________    ____________    ________    ______    _____    _____    _____    ______    _________

     "Equity"      "Normal95"          0.95      reject     88.952      0.0055565    accept     0.46147       0.49694    reject      88.491      0.0047475         1043           57         1           3      9      25.25      85         0.9   
     "Equity"      "Normal99"          0.99      reject     26.441       0.090095    reject      3.5118      0.060933    accept      22.929        0.15157         1043           17         3       21.25     48      78.25     215         0.9   
     "Equity"      "Historical95"      0.95      reject      83.63       0.023609    accept     0.91023       0.34005    reject      82.719       0.022513         1043           59         1           3     13         25      85         0.9   
     "Equity"      "Historical99"      0.99      accept     16.456        0.22539    accept     0.22768       0.63325    accept      16.228        0.18101         1043           12         3        19.5     45      152.5     200         0.9   
     "Equity"      "EWMA95"            0.95      accept     72.545        0.12844    accept     0.91023       0.34005    accept      71.635        0.12517         1043           59         1           4     13      25.75      82         0.9   
     "Equity"      "EWMA99"            0.99      reject      41.66      0.0099428    reject      9.8298     0.0017171    reject       31.83       0.080339         1043           22         2          16     40         56     143         0.9   

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 = tbf(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

Output Arguments

collapse all

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

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

  • 'LRatioTBF' — Likelihood ratio of the tbf test

  • 'PValueTBF' — P-value of the tbf test

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

  • 'LRatioPOF' — Likelihood ratio of the pof test

  • 'PValuePOF' — P-value of the pof test

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

  • 'LRatioTBFI' — Likelihood ratio of the tbfi test

  • 'PValueTBFI' — P-value of the tbfi test

  • 'Observations' — Number of observations

  • 'Failures' — Number of failures

  • 'TBFMin' — Minimum value of observed times between failures

  • 'TBFQ1' — First quartile of observed times between failures

  • 'TBFQ2' — Second quartile of observed times between failures

  • 'TBFQ3' — Third quartile of observed times between failures

  • 'TBFMax' — Maximum value of observed times between failures

  • 'TestLevel' — Test confidence level

Note

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

More About

collapse all

Time Between Failures (TBF) Mixed Test

The tbf function performs the time between failures mixed test, also known as the Haas mixed Kupiec test.

'Mixed' means that it combines a frequency and an independence test. The frequency test is Kupiec's proportion of failures (POF) test. The independence test is the time between failures independence (TBFI) test. The TBF test is an extension of Kupiec's time until first failure (TUFF) test, proposed by Haas (2001), to take into account not only the time until the first failure, but also the time between all failures. The tbf function combines the pof test and the tbfi test.

Algorithms

The likelihood ratio (test statistic) of the TBF test is the sum of the likelihood ratios of the POF and TBFI tests

LRatioTBF=LRatioPOF+LRatioTBFI

which is asymptotically distributed as a chi-square distribution with x+1 degrees of freedom, wherex is the number of failures. See the Algorithms sections for pof and tbfi for the definitions of their likelihood ratios.

The p-value of the tbf test is the probability that a chi-square distribution with x+1 degrees of freedom exceeds the likelihood ratio LRatioTBF

PValueTBF=1F(LRatioTBF)

where F is the cumulative distribution of a chi-square variable with x+1 degrees of freedom and x is the number of failures.

The result of the test is to accept if

F(LRatioTBF)<F(TestLevel)

and reject otherwise, where F is the cumulative distribution of a chi-square variable with x+1 degrees of freedom and x is the number of failures. If the likelihood ratio (LRatioTBF) is undefined, that is, with no failures yet, the TBF result is to accept only when both POF and TBFI tests accept.

References

[1] Haas, M. "New Methods in Backtesting." Financial Engineering, Research Center Caesar, Bonn, 2001.

Version History

Introduced in R2016b