rmgarch - dccforecast function
There is really not enough information to say what has happened. It appears likely that on the window (690) you mention the model did not converge. You should take a look at the resulting fit object, and possibly check for non-convergence (in which case, set solver to "gosolnp")...assuming your returns data is of reasonable size, clean of NA's and does not have "huge" spikes/outliers. Alexios
On 06/03/2015 14:11, Fernando Martins Diniz wrote:
Dear R users,
I am using the dccforecast function in the package rmgarch.
In the future I will the result to run a portfolio backtest.
For this reason I am doing the calculations in a loop.
rollingDCCmatrix <-
function(data, eligibleAssets, from, to)
{
#Data is timeSeries of returns
#eligibleAssets a list which contains for each loop i the assets
names
#Time window : from and to
DCCmatrix <- list()
garch11.spec = ugarchspec(mean.model = list(armaOrder = c(0,0)),
variance.model = list(garchOrder = c(1,1),
model = "sGARCH"),
distribution.model = "norm")
for (i in 1:length(from)) {
#Separating the series
assetsNames <- eligibleAssets[[i]]
series <- window(data[, assetsNames], start = from[i], end =
to[i])
#How many assets
nAssets <- length(assetsNames)
# The DCC specification - GARCH(1,1) for conditional
correlations
dcc.garch11.spec = dccspec(uspec = multispec( replicate(nAssets,
garch11.spec) ),
dccOrder = c(1,1),
distribution = "mvnorm")
# Estimating
dcc.fit = dccfit(dcc.garch11.spec, series,
fit.control = list(eval.se = FALSE))
dcc.fcst = dccforecast(dcc.fit, n.ahead=1)
loopDCC <- rcov(dcc.fcst)
DCCmatrix[[i]] <- loopDCC
print(i)
}
# Compose Result:
ans <- DCCmatrix
# Return Value:
invisible(ans)
}
I run this function. After hundreds (690) loops I get the following error
(and its traceback):
Error in last(rcor(fit, type = "Q"), mo) :
error in the evaluation of the argument 'x' in the method of selection
for the function 'last': 'Error in 1:m : argument of length 0
'
6 last(rcor(fit, type = "Q"), mo)
5 .dccforecastm(fit, n.ahead = n.ahead, n.roll = n.roll, external.forecasts
= exf,
cluster = cluster, realizedVol = fit at mfit$realizedVol, ...)
4 .dccforecast(fit, n.ahead = n.ahead, n.roll = n.roll, external.forecasts
= external.forecasts,
cluster = cluster, ...)
3 dccforecast(dcc.fit, n.ahead = 1)
2 dccforecast(dcc.fit, n.ahead = 1)
1 rollingDCCmatrix(Brasil_returns, eligibleAssets, Brasil_from,
Brasil_to)
I believe it is a strange error due to the fact I made daily windows and
the loop just behind worked fine. The eligible assets are the same and the
time window is the same size and have no NAs values. I looked in the source
code but sadly I am not very good programmer to see for myself where I got
it wrong.
I run the R-3.1.2 and the last update of rmgach.
Sorry for not providing a reproducible code. If it is necessary I may
provide the data used (need one authorization first).
Can anyone help me?
Thanks in advance.
Fernando Martins Diniz - martinsdiniz at gmail.com
[[alternative HTML version deleted]]
_______________________________________________ R-SIG-Finance at 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.