1
$\begingroup$

I am trying to do a financial time series forecast in order to build a portfolio. I already have some code running rugarch library and I am not sure if I am forecasting correctly, after that I would like to use the sigmas (or maybe the fitted values) in order to calculate a covariance matrix so I can build a portfolio.

R code for forecasting

  gcarso.prices=get.hist.quote(
  instrument="GCARSOA1.MX",
  start="2000-01-01",
  end="2016-08-03",
  quote = "Close",
  provider = c("yahoo"), method = NULL,
  origin = "1899-12-30", compression = "d",
  retclass = c("zoo"), quiet = FALSE, drop = FALSE
)
gcarso=as.data.frame(gcarso.prices)

N=length(gcarso[,1])
gcarso.returns=100*(log(gcarso[2:N,])-log(gcarso[1:(N-1),]))
time <- index(gcarso.prices[2:N])
gcarso.xts <- na.omit(xts(x = gcarso.returns, order.by = time))

#Model and forecast    
model=ugarchspec (
  variance.model = list(model = "sGARCH", garchOrder = c(1, 1)),
  mean.model = list(armaOrder = c(1, 1)),
  distribution.model = "norm"
)
modelfit=ugarchfit(model,data=gcarso.xts,out.sample=10)
modelfor=ugarchforecast(modelfit, data = NULL, n.ahead = 1, n.roll
                        = 10, out.sample = 10)
fitted(modelfor)
sigma(modelfor)
fpm(modelfor)

The output:

> fitted(modelfor)
    2016-07-20 2016-07-21 2016-07-22 2016-07-25 2016-07-26 2016-07-27 2016-07-28 2016-07-29 2016-08-01 2016-08-02 2016-08-03
T+1  -0.245073 0.03921982  0.0120029  0.1588765  0.4137586  0.4635337  0.3734044  0.3273671  0.2226516  0.3274746  0.2945644
> sigma(modelfor)
    2016-07-20 2016-07-21 2016-07-22 2016-07-25 2016-07-26 2016-07-27 2016-07-28 2016-07-29 2016-08-01 2016-08-02 2016-08-03
T+1   1.607644    1.65467   1.601347   1.593421   1.733585   1.718388   1.656873   1.603244   1.554496    1.56264   1.517701
> fpm(modelfor)
       MSE       MAE DAC
1 1.368462 0.9172632 0.6

I calculated MAPE (Mean Average Percentage Error) and it was very high (more than 100%), I would like to know if I am doing something wrong at the forecast or if its just normal to have a very bad accuracy?.

Also, if I were to use the sigmas how should I use them in order to build a covariance matrix (I am doing the same procedure as above with 5 more time series)?

Thanks in advance!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.