Learn R Programming

rugarch (version 1.0-16)

BerkowitzTest: Berkowitz Density Forecast Likelihood Ratio Test

Description

Implements the Berkowitz Density Forecast Likelihood Ratio Test.

Usage

BerkowitzTest(data, lags = 1, significance = 0.05, tail.test = FALSE, alpha = 0.05)

Arguments

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.
tail.test
Whether to use the tail test of Berkowitz using a censored likelihood.
alpha
The quantile level for the tail.test cuttoff.

Value

  • A list with the following items:
  • uLLThe unconditional Log-Likelihood of the maximized values.
  • rLLThe restricted Log-Likelihood with zero mean, unit variance and zero coefficients in the autoregressive lags.
  • LRThe Likelihood Ratio Test Statistic.
  • LRpThe LR test statistic p-value (distributed chisq with 2+lags d.o.f).
  • H0The Null Hypothesis.
  • TestThe test of the Null Hypothesis at the requested level of significance.
  • muThe estimated mean of the model.
  • sigmaThe estimated sd of the model.
  • rhoThe estimated autoregressive coefficients of the model (not calculated when tail.test is used).
  • JBThe Jarque-Bera Test of Normality Statistic (not calculated when tail.test is used).
  • JBpThe Jarque-Beta Test Statistic p-value (not calculated when tail.test is used).

Details

See not below.

References

Berkowitz, J. 2001, Testing density forecasts, with applications to risk management, Journal of Business and Economic Statistics, 19(4), 465--474. Dowd, K. 2004, A modified Berkowitz back-test, RISK Magazine, 17(4), 86--87. Jarque, C.M. and Bera, A.K. 1987, A test for normality of observations and regression residuals, International Statistical Review, 55(2), 163--172. Rosenblatt, M. 1952, Remarks on a multivariate transformation, The Annals of Mathematical Statistics, 23(3), 470--472.

Examples

Run this code
#  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)
test1 = BerkowitzTest(data = nvector, lags = 1, significance = 0.05)
test2 = BerkowitzTest(data = nvector, alpha = 0.05, significance = 0.05, 
tail.test=TRUE)
test3 = BerkowitzTest(data = nvector, alpha = 0.01, significance = 0.05, 
tail.test=TRUE)

Run the code above in your browser using DataLab