Description Usage Arguments Details Value Note Author(s) References Examples
Implements the Berkowitz Density Forecast Likelihood Ratio Test.
1 | BerkowitzLR(data, lags = 1, significance = 0.05)
|
data |
A univariate vector of standard normal transformed values (see details and example). |
lags |
The number of autoregressive lags (positive and greater than 0). |
significance |
The level of significance at which the Null Hypothesis is evaluated. |
See not below.
A list with the following items:
uLL |
The unconditional Log-Likelihood of the maximized values. |
rLL |
The restricted Log-Likelihood with zero mean, unit variance and zero coefficients in the autoregressive lags. |
LR |
The Likelihood Ratio Test Statistic. |
LRp |
The LR test statistic p-value (distributed chisq with 2+lags d.o.f). |
H0 |
The Null Hypothesis. |
Test |
The test of the Null Hypothesis at the requested level of significance. |
mu |
The estimated mean of the model. |
sigma |
The estimated sd of the model. |
rho |
The estimated autoregressive coefficients of the model. |
JB |
The Jarque Bera Test of Normality Statistic. |
JBp |
The Jarque Beta Test Statistic p-value. |
The data must first be transformed before being submitted to the function as described here. Given a forecast density (d*) at time t, transform the actual(observed) realizations of the data by applying the distribution function of the forecast density (p*). This will result in a set of uniform values (see Rosenblatt (1952)). Transform those value into standard normal variates by applying the standard normal quantile function (qnorm). The example below hopefully clarifies this. The function also returns the Jarque Bera Normality Test statistic as an additional check of the normality assumption which the test does not explicitly account for (see Dowd reference).
Alexios Ghalanos
Berkowitz, J. Testing density forecasts, with applications to risk management, 2001,
Journal of Business and Economic Statistics, 19, 4, 465-474.
Dowd, K. A modified Berkowitz back-test, 2004, RISK Magazine, 17, 4, 86-87.
Jarque, C.M. and Bera, A.K. A test for normality of observations and regression residuals,
1987, International Statistical Review, 55, 2, 163-172.
Rosenblatt, M. Remarks on a multivariate transformation, 1952, The Annals of Mathematical Statistics,
23, 3, 470-472.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | ## Not run:
# A univariate GARCH model is used with rolling out of sample forecasts.
data(dji30ret)
spec = ugarchspec(mean.model = list(armaOrder = c(6,1), include.mean = TRUE),
variance.model = list(model = "gjrGARCH"), distribution.model = "nig")
fit = ugarchfit(spec, data = dji30ret[, 1, drop = FALSE], out.sample = 1000)
pred = ugarchforecast(fit, n.ahead = 1, n.roll = 999)
dmatrix = cbind(as.array(pred)[,2,],as.array(pred)[,1,], coef(fit)["skew"], coef(fit)["shape"])
colnames(dmatrix) = c("mu", "sigma", "skew", "shape")
# Get Realized (Oberved) Data
obsx = tail(dji30ret[,1], 1000)
# you can check that this is correct by looking at the dates of the
# first and last predictions:
as.data.frame(pred, rollframe = 0)
head(tail(dji30ret[,1, drop = FALSE], 1000), 1)
as.data.frame(pred, rollframe = 999)
tail(dji30ret[,1, drop = FALSE], 1)
# Transform to Uniform
uvector = apply(cbind(obsx,dmatrix), 1, FUN = function(x) pdist("nig", q = x[1],
mu = x[2], sigma = x[3], skew = x[4], shape = x[5]))
# hist(uvector)
# transform to N(0,1)
nvector = qnorm(uvector)
test = BerkowitzLR(data = nvector, lags = 1, significance = 0.05)
print(test)
# We fail to reject Null at the 5% level, but not at 10%.
# plot(density(nvector))
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.