我想在BacktestVaR
包中使用GAS
函数
数据文件在returns
returns1 <- return[,-1]
BacktestVaR(returns1,0.9998714,0.05)
当我运行上面的代码时,我得到: -
&#34; svd(X)中的错误:&#39;&#39;&#34;&#34;
中的无限或缺失值
有人可以帮我这个吗?
答案 0 :(得分:0)
我猜您的VaR
参数存在问题。它需要一个包含VaR
系列的数字向量,并且您传递的是0.9998714。
您可以查看package documentation中的一个示例。
我在数据包中给出了一个示例,它对我来说很好。
library(GAS)
returns1 <- return[,-1]
Forecast = UniGASFor(Fit, Roll = TRUE, out = returns1)
alpha = 0.05
VaR = quantile(Forecast, alpha)
BacktestVaR(returns1, VaR, alpha)
它给出了一个输出: -
$LRuc
Test Pvalue
1.508023e+01 1.030369e-04
$LRcc
Test Pvalue
1.508023e+01 5.313369e-04
$AE
[1] 0
$AD
ADmean ADmax
NaN -Inf
$DQ
$DQ$stat
[,1]
[1,] 7.526316
$DQ$pvalue
[,1]
[1,] 0.3762069
$Loss
$Loss$Loss
[1] 0.02396477
$Loss$LossSeries
[1] 0.099206718 0.089934791 0.085306377 0.083944161 0.078122362 0.073599847 0.061635033
[8] 0.064839991 0.059715813 0.065246570 0.061809442 0.055136995 0.052664206 0.052750109
[15] 0.048890123 0.043372077 0.043033141 0.045092669 0.042304367 0.037946743 0.041365010
[22] 0.037392398 0.041342509 0.037154130 0.034005277 0.035064542 0.024833787 0.032198291
[29] 0.026951766 0.032110073 0.025078754 0.019482687 0.029475914 0.031723679 0.022555941
[36] 0.012634228 0.020209926 0.028950001 0.026904561 0.028708228 0.031490940 0.031142592
[43] 0.039528132 0.023939675 0.036555585 0.025622543 0.030231260 0.020470378 0.028312997
[50] 0.025243985 0.018476646 0.022936782 0.024340429 0.021230794 0.019276576 0.023544289
[57] 0.019724022 0.021008776 0.022342456 0.019971455 0.018544509 0.017889817 0.010320351
[64] 0.013567978 0.023370654 0.018427862 0.013352942 0.015784444 0.016032580 0.013898405
[71] 0.016405078 0.021259721 0.009921251 0.013944924 0.022224791 0.019584060 0.016001481
[78] 0.017540380 0.006435535 0.018837333 0.013470815 0.015819393 0.021200104 0.014361778
[85] 0.017106075 0.017225547 0.012276949 0.011625625 0.011784346 0.018752417 0.014791428
[92] 0.011591563 0.012849788 0.011635476 0.017176090 0.018051420 0.014120935 0.012636333
[99] 0.009913736 0.017225520 0.015406386 0.012874489 0.016547533 0.014883970 0.012906750
[106] 0.017762996 0.013358853 0.014217855 0.013441140 0.010019856 0.015160385 0.011431101
[113] 0.009502256 0.008921462 0.013421278 0.010276422 0.012234584 0.007779987 0.009893465
[120] 0.013416031 0.013245883 0.009740190 0.006903344 0.007681396 0.018183227 0.012966043
[127] 0.013923885 0.012345783 0.014619745 0.013296054 0.011492134 0.010751146 0.006154623
[134] 0.011448771 0.014871403 0.010247001 0.012144674 0.012527776 0.013672466 0.008994635
[141] 0.012822531 0.008867439 0.011508661 0.012899977 0.009832727 0.013247198 0.009932820
Warning message:
In max(series) : no non-missing arguments to max; returning -Inf