[R-SIG-Finance] VaRTest in rugarch package version 1.4.9 returns NaN
alexios galanos
@|ex|o@ @end|ng |rom 4d@c@pe@com
Thu May 18 17:29:36 CEST 2023
Hi Ayla,
That’s been a problem with the implementation of the VaR test for some time with large data due
to underflow. I’ll look into fixing this in the next release, but in the meantime you can try the
new package for time series tests which fixes this problem : https://github.com/tsmodels/tstests
Most of rugarch has already been re-written/ported to tsgarch and the tests in rugarch
to tstests.
Example:
####
library(tstests)
# load the data
filename = "bugreport_var_test_var.csv"
var = read.csv(file = filename)
filename = "bugreport_var_test_log_reg.csv"
data = read.csv(file = filename)
# try the test with full data
print(var_cp_test(data[,1], var[,1], 0.05))
Value at Risk Tests (Christoffersen and Pelletier)
Hypothesis(H0) : Unconditional(UC), Independent(CCI), Joint Coverage(CC) and Duration(D)
DoF Chisq Pr(>Chisq)
Kupiec (UC) 1 3.414 6.466e-02 .
CP (CCI) 1 15.113 1.013e-04 ***
CP (CC) 2 18.527 9.484e-05 ***
CP (D) 1 30.013 4.291e-08 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Coverage : 0.05
Obs. : 3419
Failures : 195
E[Failures] : 170
Alexios
> On May 18, 2023, at 1:49 AM, Ayla via R-SIG-Finance <r-sig-finance using r-project.org> wrote:
>
> Dear contributors, dear Alexios Galanos,
>
> I'm using the rugarch package version 1.4.9 to backtest a calculated value
> of risk vector against my log returns with the VaRTest function from the
> package.
>
> However, in some situations, the test returns NA. I found an example where
> the test returns NA for the full vector of VaRs and log returns but when I
> perform the test without the very last value in the vector, it returns an
> output.
> It does not help to put the data and the VaR explicitly to numeric
> (`as.numeric()`).
>
> Data for the example can be found here:
> https://drive.google.com/file/d/1YAvWpDJT93PnVDrvHuMZoBmQ8BEnB2cu/view?usp=sharing
> and here:
> https://drive.google.com/file/d/1qPQXOqZL9lancBnW_q2aa_I75wd5loTM/view?usp=share_link
>
> This is my code:
>
> ```
> ## load data
> rm(list = ls())
>
> require(rugarch)
>
> # load the data
> filename = "bugreport_var_test_var.csv"
> var = read.csv(file = filename)
> filename = "bugreport_var_test_log_reg.csv"
> data = read.csv(file = filename)
>
> # try the test with full data
> VaRTest(
> alpha=0.05,
> actual=data[,1],
> VaR=var[,1]
> )
>
> # try the test without last data point
> VaRTest(
> alpha=0.05,
> actual=data[1:(nrow(data)-1),1],
> VaR=var[1:(nrow(var)-1),1]
> )
> ```
>
> Thanks a lot in advance!
> Best,
> Ayla
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-SIG-Finance using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.
More information about the R-SIG-Finance
mailing list