Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

bin

Binomial test for value-at-risk (VaR) backtesting

Syntax

TestResults = bin(vbt)
TestResults = bin(vbt,Name,Value)

Description

example

TestResults = bin(vbt) generates the binomial test results for value-at-risk (VaR) backtesting.

example

TestResults = bin(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]
      PortfolioID: "Portfolio"
            VaRID: "VaR"
         VaRLevel: 0.9500

Generate the bin test results.

TestResults = bin(vbt)
TestResults =

  1x9 table

    PortfolioID    VaRID    VaRLevel     Bin      ZScoreBin    PValueBin    Observations    Failures    TestLevel
    ___________    _____    ________    ______    _________    _________    ____________    ________    _________

    "Portfolio"    "VaR"    0.95        accept    0.68905      0.24539      1043            57          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]
      PortfolioID: "Equity"
            VaRID: [1x6 string]
         VaRLevel: [0.9500 0.9900 0.9500 0.9900 0.9500 0.9900]

Generate the bin test results using the TestLevel optional argument.

TestResults = bin(vbt,'TestLevel',0.90)
TestResults =

  6x9 table

    PortfolioID        VaRID         VaRLevel     Bin      ZScoreBin    PValueBin     Observations    Failures    TestLevel
    ___________    ______________    ________    ______    _________    __________    ____________    ________    _________

    "Equity"       "Normal95"        0.95        accept    0.68905         0.24539    1043            57          0.9      
    "Equity"       "Normal99"        0.99        reject     2.0446        0.020448    1043            17          0.9      
    "Equity"       "Historical95"    0.95        accept     0.9732         0.16523    1043            59          0.9      
    "Equity"       "Historical99"    0.99        accept    0.48858         0.31257    1043            12          0.9      
    "Equity"       "EWMA95"          0.95        accept     0.9732         0.16523    1043            59          0.9      
    "Equity"       "EWMA99"          0.99        reject     3.6006      0.00015875    1043            22          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 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 single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: TestResults = bin(vbt,'TestLevel',0.99)

collapse all

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

Bin 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 given data

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

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

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

  • 'ZScoreBin' — Z-score of the number of failures

  • 'PValueBin' — P-value of the bin test

  • 'Observations' — Number of observations

  • 'Failures' — Number of failures.

  • 'TestLevel' — Test confidence level.

Note

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

More About

collapse all

Binomial Test (Bin)

The bin function performs a binomial test to assess if the number of failures is consistent with the VaR confidence level.

The binomial test is based on a normal approximation to the binomial distribution.

Algorithms

The result of the binomial test is based on a normal approximation to a binomial distribution. Suppose:

  • N is the number of observations.

  • p = 1VaRLevel is the probability of observing a failure if the model is correct.

  • x is the number of failures.

If the failures are independent, then the number of failures is distributed as a binomial distribution with parameters N and p. The expected number of failures is N*p, and the standard deviation of the number of failures is

Np(1p)

The test statistic for the bin test is the z-score, defined as:

ZScoreBin=(xNp)Np(1p)

The z-score approximately follows a standard normal distribution. This approximation is not reliable for small values of N or small values of p, but for typical uses in VaR backtesting analyses (N = 250 or much larger,p in the range 1–10%) the approximation gives results in line with other tests.

The p-value of the bin test is the probability that a standard normal distribution exceeds the absolute value of the z-score

PValueBin=1F(|ZScoreBin|)

where F is the standard normal cumulative distribution. When too few failures are observed, relative to the expected failures, PValueBin is (approximately) the probability of observing that many failures or fewer. For too many failures, this is (approximately) the probability of observing that many failures or more.

References

[1] Jorion, P. Financial Risk Manager Handbook. 6th Edition. Wiley Finance, 2011.

Introduced in R2016b

Was this topic helpful?