0

So I'm trying to replicate this post for Colombia stock http://unstarched.net/2013/03/20/high-frequency-garch-the-multiplicative-component-garch-mcsgarch-model/, so first I do the same that the post do to understand what it does and how do it work. But when fitting the mscGARCH I'm getting which I don't now why because I'm doing the same that the post do. All ready ask there but i haven't get an answer so I came here for some help. The code that I have is:

library(rugarch)
Sys.setenv(TZ="GMT")
library(quantmod)
library(zoo)
library(TTR)

R_i=read.csv('C:/Users/Alejandro/Downloads/C_2008_1minret.csv')
R_i= xts(R_i[,2],as.POSIXct(R_i[,1]))
getSymbols("C", from="2000-01-01", to="2013-03-20")
C= adjustOHLC(C,use.Adjusted = T)
R_d= ROC(Cl(C),na.pad=F)

par(cex.main=0.85,col.main="black")
acf(abs(as.numeric(R_i)),lag.max=4000, main="1-min retornos absolutos\nCitigroup (2008 Jan-Feb)"
      ,cex.lab=1.5)

####################
## Implementacion ##
####################

n= length(unique(format(index(R_i),"%Y-%m-%d")))

spec_d=ugarchspec(mean.model = list(armaOrder=c(1,1)),
                  variance.model = list(model="eGARCH",garchOrder=c(2,1)),
                  distribution="nig")

roll=ugarchroll(spec_d,data=R_d["/2008-02-29"], forecast.lenght=n,
                refit.every = 5,refit.window = "moving", moving.size=2000,
                calculate.VaR=F)

df=as.data.frame(roll)
f_sigma=as.xts(df[,"Sigma",drop=F])

spec= ugarchspec(mean.model=list(armaOrder=c(1,1),include.mean=T),
                 variance.model=list(model="mcsGARCH"), distribution="nig")

fit=ugarchfit(data=R_i, spec=spec,DailyVar=f_sigma^2)

the last command it the one that's giving me the error which is: Error in !matchD : invalid argument type. But I don't know what I'm doing wrong

Alejandro Andrade
  • 2,196
  • 21
  • 40

1 Answers1

1

I've encountered this error before myself. If I recall correctly, your error comes from this line:

fit=ugarchfit(data=R_i, spec=spec,DailyVar=f_sigma^2)

You need to ensure the data range for R_i and for f_sigma coincide. I think that's what this error is telling you (matchD = intraday matches on daily data?)

For example, if R_i has intraday data for all dates in 2012, then in your call make sure your daily vol estimates,used as inputs, which are contained in f_sigma, overlaps for the same time range (i.e. subset f_sigma correctly). E.g. do something like fit=ugarchfit(data=R_i, spec=spec,DailyVar=f_sigma["2012"]^2)

FXQuantTrader
  • 6,821
  • 3
  • 36
  • 67
  • I encounter an other problem that I don't understand either. After this command `forc = ugarchforecast(fit2, n.ahead = 10, n.roll = 299, DailyVar = f_sigma^2)` y get the `Error: cannot allocate vector of size 360.0 Mb In addition: Warning messages: 1: In format.POSIXlt(as.POSIXlt(x, tz), format, usetz, ...) : Reached total allocation of 8169Mb: see help(memory.size)` do you what I am doing wrong? is it just that my PC doesn't have the power to compute this? or I just have to increase the memory in R? in this case how do i do it? – Alejandro Andrade Sep 22 '15 at 18:15
  • Sounds like it. Have you looked at say this? http://stackoverflow.com/questions/5171593/r-memory-management-cannot-allocate-vector-of-size-n-mb – FXQuantTrader Sep 22 '15 at 22:05