var.backtest | R Documentation |
var.backtest function backtests the unbiasedness and the independence hypotheses for the intra-day VaR curve forecasts.
var.backtest(vio, tau, K = NULL)
vio |
A (grid_point) x (number of observations) matrix drawn from the violation process curves. |
tau |
The nominal/true quantile of the VaR curves. |
K |
The maximal lagged autocorrelation considered for the independence test. If it is missing, a default value "K=20" is used. |
Given the violation process Z_i^\tau(t)
at the quantile \tau
, the function computes P-values of two hypothesis tests:
(1) unbiasedness H_0
: E(Z_i^\tau(t)-\tau)=0
, for all t \in[0,1]
, 1\leq i\leq N
. The test statistics,
T_N=N|| \bar{Z}(t)-\tau||^2
is employed, where ||\cdot ||
is the L^2
norm, and \bar{Z}(t)=1/N\sum_{i=1}^N Z_i(t)
.
(2) independence H_0
: Z_i^\tau(t)
is independent, a portmanteau test statistic in used (Kokoszka et al., 2017),
V_{N,K}=N\sum_{h=1}^K||\hat{\gamma}_{h,Z}||^2
,
where K
is a pre-set maximum lag length, and the autocovariance function \hat{\gamma}_{h,Z}(t,s)=\frac{1}{N}\sum_{i=1}^{N-h}[Z_i(t)-\bar{Z}_i(t)][Z_{i+h}(s)-\bar{Z}(s)]
, for ||\cdot ||
is the L^2
norm, and \bar{Z}(t)=1/N\sum_{i=1}^N Z_i(t)
.
List of generated processes:
unbias: the p-value of the unbiasedness test;
independent: the p-value of the independence test.
Rice, G., Wirjanto, T., Zhao, Y. (2020). Forecasting Value at Risk via intra-day return curves. International Journal of Forecasting. <doi:10.1016/j.ijforecast.2019.10.006>.
var.forecast
var.vio
## Not run:
# generate discrete evaluations of the FGARCH(1,1) process.
grid_point = 50; N = 200
yd = dgp.fgarch(grid_point, N, "garch")
yd = yd$garch_mat
# extract data-driven basis functions through the truncated FPCA method.
basis_est = basis.est(yd, M=2, "tfpca")$basis
# fit the curve data and the conditional volatility by using a FGARCH(1,1) model with M=1.
fd = fda::Data2fd(argvals=seq(0,1,len=grid_point),y=yd,fda::create.bspline.basis(nbasis=32))
garch11_est = est.fGarch(fd, basis_est[,1])
diag_garch = diagnostic.fGarch(garch11_est, basis_est[,1], yd)
# get the in-sample fitting of conditional variance.
sigma_fit = diag_garch$sigma2[,1:N]
error_fit = diag_garch$eps
# get in-sample intra-day VaR curve by assuming a point-wisely Gaussian distributed error term.
var_obj = var.forecast(yd, sigma_fit, error_fit, quantile_v=0.01, Method="normal")
intra_var = var_obj$intraday_VaR
# get the violation curves.
intra_vio = var.vio(yd,intra_var)
# backtesting the Unbiasedness Hypothesis for the violation curve.
pvalues = var.backtest(vio=intra_vio, tau=0.01, K=10)
pvalues$unbias
pvalues$independent
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.