ExactVaRTest – Exact Finite-Sample VaR Back-Testing
Description
Provides fast dynamic‐programming algorithms (C++/Rcpp) – with pure‐R fall‐backs – for the exact finite‐sample distributions and p‐values of Christoffersen’s (1998) VaR back‐tests: Independence (IND) and Conditional Coverage (CC) tests, and the Unconditional Coverage (UC) test via closed‐form binomial enumeration.
Author(s)
Maintainer: Yujian Chen yjc4996@gmail.com
See Also
Useful links:
Report bugs at https://github.com/YujianCHEN219/ExactVaRTest/issues
Exact UC/IND/CC back‐tests in one call
Description
Exact UC/IND/CC back‐tests in one call
Usage
backtest_all(x, alpha = 0.05, sig = 0.05, prune_threshold = 1e-15)
Arguments
x
0/1 exception series.
alpha
Exception probability.
sig
Significance level (default 0.05).
prune_threshold
Passed to the dynamic programming engine.
Value
An object of class "ExactVaRBacktestAll" (a named list) with components:
uc, ind, cc (each a list with stat, pval, reject),
and scalars sig (significance level), alpha (model exception probability),
n (sample size).
Examples
set.seed(1)
x <- rbinom(300, 1, 0.02)
backtest_all(x, alpha = 0.02)
Exact finite‐sample back‐test for a VaR exception series
Description
Exact finite‐sample back‐test for a VaR exception series
Usage
backtest_lr(
x,
alpha = 0.05,
type = c("uc", "ind", "cc"),
sig = 0.05,
prune_threshold = 1e-15
)
Arguments
x
0/1 exception series.
alpha
Exception probability.
type
"uc", "ind" or "cc".
sig
Significance level (default 0.05).
prune_threshold
Passed to the dynamic‐programming engine.
Value
An object of class "ExactVaRBacktest" (a named list) with components:
stat (numeric LR statistic),
pval (numeric exact p-value in [0,1]),
reject (logical; TRUE if p < sig),
type (character; one of "uc", "ind", "cc"),
alpha (numeric model exception probability),
sig (numeric significance level),
n (integer sample size).
Examples
set.seed(123)
x <- rbinom(250, 1, 0.01)
backtest_lr(x, alpha = 0.01, type = "uc")
Exact LR_cc (and LR_uc) distribution (auto‐select engine)
Description
Returns the finite‐sample distribution of Christoffersen’s conditional‐coverage
statistic LR_{\mathrm{cc}}. The returned list also includes the matching
unconditional‐coverage distribution LR_{\mathrm{uc}}, produced by the same
dynamic‐programming run.
Usage
lr_cc_dist(n, alpha = 0.05, prune_threshold = 1e-15)
Arguments
n
Integer sample size (n \ge 1).
alpha
Exception probability \alpha \in (0,1).
prune_threshold
Probability below which states are pruned by the dynamic‐programming recursion.
Value
A named list with elements LR_cc, prob_cc, LR_uc,
prob_uc. The pairs (LR_cc, prob_cc) and (LR_uc, prob_uc)
have equal lengths; each probability vector is in [0,1] and sums to 1.
Examples
lr_cc_dist(8, 0.05)
Christoffersen LR_cc statistic
Description
Christoffersen LR_cc statistic
Usage
lr_cc_stat(x, alpha = 0.05)
Arguments
x
0/1 exception series.
alpha
Exception probability.
Value
Numeric LR_cc statistic.
Exact LR_ind distribution (auto‐select engine)
Description
Returns the finite‐sample distribution of Christoffersen’s independence
statistic LR_{\mathrm{ind}}.
Usage
lr_ind_dist(n, alpha = 0.05, prune_threshold = 1e-15)
Arguments
n
Integer sample size (n \ge 1).
alpha
Exception probability \alpha \in (0,1).
prune_threshold
Probability below which states are pruned by the dynamic‐programming recursion.
Value
A named list with elements LR and prob of equal length,
where LR is the support of the LR statistic and prob are the
corresponding probabilities in [0,1] that sum to 1.
Examples
lr_ind_dist(8, 0.05)
Christoffersen LR_ind statistic
Description
Christoffersen LR_ind statistic
Usage
lr_ind_stat(x, alpha = 0.05)
Arguments
x
0/1 exception series.
alpha
Exception probability.
Value
Numeric LR_ind statistic.
Exact LR_uc distribution (closed‐form binomial)
Description
Exact LR_uc distribution (closed‐form binomial)
Usage
lr_uc_dist(n, alpha = 0.05)
Arguments
n
Integer sample size (n \ge 1).
alpha
Exception probability \alpha \in (0,1).
Value
A named list with elements LR and prob of equal length,
where LR is the support of the LR statistic and prob are the
corresponding probabilities in [0,1] that sum to 1.
Examples
lr_uc_dist(8, 0.01)
Christoffersen LR_uc statistic
Description
Christoffersen LR_uc statistic
Usage
lr_uc_stat(x, alpha = 0.05)
Arguments
x
0/1 exception series.
alpha
Exception probability.
Value
Numeric LR_uc statistic.
Print method for ExactVaRBacktest
Description
Print method for ExactVaRBacktest
Usage
## S3 method for class 'ExactVaRBacktest'
print(x, digits = max(3L, getOption("digits") - 3L), ...)
Arguments
x
An object of class 'ExactVaRBacktest'.
digits
Number of digits to print.
...
Further arguments passed to or from other methods (ignored).
Details
Prints the test name, sample size n, model alpha, significance level,
LR statistic, exact p-value, and the decision at the specified level.
Value
The input object x, returned invisibly (class ExactVaRBacktest).
Print method for ExactVaRBacktestAll
Description
Print method for ExactVaRBacktestAll
Usage
## S3 method for class 'ExactVaRBacktestAll'
print(x, digits = max(3L, getOption("digits") - 3L), ...)
Arguments
x
An object of class 'ExactVaRBacktestAll'.
digits
Number of digits to print.
...
Further arguments passed to or from other methods (ignored).
Details
Prints a header with sample size n, model alpha and significance level,
followed by per-test blocks for UC, IND, and CC: LR statistic, exact p-value,
and the decision at the specified level.
Value
The input object x, returned invisibly (class ExactVaRBacktestAll).
Exact p-value for LR_cc
Description
Exact p-value for LR_cc
Usage
pval_lr_cc(lr_obs, n, alpha = 0.05, prune_threshold = 1e-15)
Arguments
lr_obs
Observed LR_cc statistic.
n
Sample size.
alpha
Exception probability.
prune_threshold
State-pruning threshold for DP engine.
Value
Numeric exact p-value in [0,1]; may be NA_real_ if the
finite-sample distribution is unavailable.
Exact p-value for LR_ind
Description
Exact p-value for LR_ind
Usage
pval_lr_ind(lr_obs, n, alpha = 0.05, prune_threshold = 1e-15)
Arguments
lr_obs
Observed LR_ind statistic.
n
Sample size.
alpha
Exception probability.
prune_threshold
State-pruning threshold for DP engine.
Value
Numeric exact p-value in [0,1]; may be NA_real_ if the
finite-sample distribution is unavailable.
Exact p-value for LR_uc
Description
Exact p-value for LR_uc
Usage
pval_lr_uc(lr_obs, n, alpha = 0.05)
Arguments
lr_obs
Observed LR_uc statistic.
n
Sample size.
alpha
Exception probability.
Value
Numeric exact p-value in [0,1]; may be NA_real_ if the
finite-sample distribution is unavailable.