[R] fGarch: how to use garchFit() in loop?

Marius Hofert m_hofert at web.de
Sun Aug 15 22:26:29 CEST 2010


Dear expeRts,

How can I specify the order p,q of a GARCH(p,q) model within a loop? Here's a minimal example showing that an "Formula and data units do not match"-error appears:

library(fGarch)
spec <- garchSpec(model = list(alpha = 0.1, beta = c(0.4, 0.4)))
data <- garchSim(spec, n = 100)
x <- list()
for(q in 1:3){
	print(q)
	x[q] <- list(garchFit(~garch(1,q),data=data,trace=FALSE))
}

Cheers,

Marius


More information about the R-help mailing list