Description Usage Arguments Details Value Author(s) References Examples
Implements the Directional Accuracy Test of Pesaran and Timmerman and Excess Profitability Test of Anatolyev and Gerko.
1 |
forecast |
A numeric vector of the forecasted values. |
actual |
A numeric vector of the actual (realized) values. |
test |
Choice of Pesaran and Timmermann (‘PT’) or Anatolyen and Gerko (‘AG’) tests. |
conf.level |
The confidence level at which the Null Hypothesis is evaluated. |
See the references for details on the tests. The Null is effectively that of independence, and distributed as N(0,1).
A list with the following items:
Test |
The type of test performed. |
Stat |
The test statistic. |
p-value |
The p-value of the test statistic. |
H0 |
The Null Hypothesis. |
Decision |
Whether to reject or not the Null given the conf.level. |
DirAcc |
The directional accuracy of the forecast. |
Alexios Ghalanos
Anatolyev, S. and Gerko, A. A trading approach to testing for predictability, 2005,
Journal of Business and Economic Statistics, 23, 4, 455-461.
Pesaran, M.H. and Timmermann, A. A simple nonparametric test of predictive performance, 1992,
Journal of Business and Economic Statistics, 10, 4, 461-465.
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.