You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
for (i in 1:nots)
{
GBPits<- GBPr[i:(nits+i-1)] # rolling estimation window of last 365 obs (updates the in-sample observations)
cat("VaR forecasts vs. out-of-sample: ", i, "\n")
if (i %% update == 1) # if modulus is 1 (rest after division, 8/7=1 ; 15/7=1 etc) -> every 7 days update
{
BestGBPfit <- FitML(spec = EGARCH2.EGARCH3 ,data = GBPits) # reestimate model with updated in-sample observations
cat("Best model is reestimated \n")
}
GBPots[i] <- GBPr[nits+i] # pick corresponding to VaR forecast out-of-sample observation for the later backtesting
BestGBPES_0.01[i] <- Risk(object = BestGBPfit$spec, # fill entry by ES, using specification of model
par = BestGBPfit$par, # using parameters
data = GBPits, # use updated 365 in-sample obs as rolling window to give VaR forecast
alpha = 0.01, # quantile
nahead = 1, # horizon
do.es = TRUE)$ES # ES
It seems like an estimation issue perhaps at some point in the loop, we often get it with EGARCH and probably should look more once time is not an issue. Hard to check now without the time series. You could try using the past parameter estimates as the starting value for the subsequent one. This can be set up by setting: ctr = list(par0 = SomeOldEstPar) in FitML()
Error: Error in out$VaR[n, i] <- x[which.min(abs(cumul[, n] - alpha[i]))] :
replacement has length zero
Code:
nots<- 1196 #length of outsample evaluation
nits<- 3000 #length of insample data (fit sample size)
alpha<- c(0.01 , 0.05) #Risk level
update<- 7 #Estimation Frequency
GBPits<- GBPr[i:(nits+i-1)]
GBPots<- matrix(NA, nrow = nots, ncol = 1)
#BEST EURO
BestGBPES_0.01<-matrix(NA, nrow = nots, ncol = 1)
BestGBPES_0.025<-matrix(NA, nrow = nots, ncol = 1)
for (i in 1:nots)
{
GBPits<- GBPr[i:(nits+i-1)] # rolling estimation window of last 365 obs (updates the in-sample observations)
cat("VaR forecasts vs. out-of-sample: ", i, "\n")
if (i %% update == 1) # if modulus is 1 (rest after division, 8/7=1 ; 15/7=1 etc) -> every 7 days update
{
BestGBPfit <- FitML(spec = EGARCH2.EGARCH3 ,data = GBPits) # reestimate model with updated in-sample observations
}
GBPots[i] <- GBPr[nits+i] # pick corresponding to VaR forecast out-of-sample observation for the later backtesting
BestGBPES_0.01[i] <- Risk(object = BestGBPfit$spec, # fill entry by ES, using specification of model
par = BestGBPfit$par, # using parameters
data = GBPits, # use updated 365 in-sample obs as rolling window to give VaR forecast
alpha = 0.01, # quantile
nahead = 1, # horizon
do.es = TRUE)$ES # ES
BestGBPES_0.025[i] <- Risk(object = BestGBPfit$spec,
par = BestGBPfit$par,
data = GBPits,
alpha = 0.025,
nahead = 1,
do.es = TRUE)$ES
}
I am facing this issue with two exchange rate data sets.
can you help ?
The text was updated successfully, but these errors were encountered: