Take the 2-minute tour ×

I am try to fit an eGARCH model on an expanding basis using the rugarch package. I have 6 columns of data, and I am trying refit parameters ~6000 for each column. If I run the following code, I get an error in windows on the 2nd column (this means I am getting all the way through the first inner loop succesfully). By using gc() within the loop and removing the fitted object I have extended the length of time it takes to hit the memory error. Also, this process takes a very long time in general and I am wondering if there is anyway to improve it on my end. The package itself seems to be written pretty efficiently with most of the filtering being done in low level C. I could probably refit the model every 30-60 days, but I would really prefer to do it this way. I am running R 2.13.2 on 32-Bit windows. Thanks in advance. Edit: The error is: "The instruction at "0x6c732a07" referenced memory at "0x00000008." The memory could not be "read"".

e.spec <- ugarchspec(variance.model = list(model = "eGARCH", garchOrder = c(1,1)),   mean.model = list(armaOrder = c(1,0), include.mean = TRUE)) 
dly.xts <- xts(matrix(rnorm(8000*6), nrow = 8000, ncol = 6), as.Date(1:8000))
tst.xts <- tail(dly.xts, 6000)
names(tst.xts) <- 1:6
tst.idx <- index(tst.xts)
dly.idx <- index(dly.xts)
for(j in 1:ncol(tst.xts)){
     sig.est <- rep(NA, nrow(tst.xts))
    for(i in 1:nrow(tst.xts)){
        dat <- dly.xts[dly.idx <= tst.idx[i], j]
        fit <- try(ugarchfit(e.spec, data = dat[-nrow(dat), ], solver = "solnp", solver.control = list(trace = FALSE)))
        if(class(fit) != "try-error"){
            spec.new <- ugarchspec(variance.model = list(model = "eGARCH", garchOrder = c(1,1)), mean.model = list(armaOrder = c(1,0), include.mean = TRUE), fixed.pars = coef(fit))
             sig.est[i] <- as.numeric(tail(sigma(ugarchfilter(spec = spec.new, data = dat)),1))
            sig.est[i] <- NA
    save(sig.est, file = paste("egarch", names(tst.xts)[j], ".RData", sep = ""))
share|improve this question
Just to be sure that memory is the only problem, does your code run okay if you reduce the number of parameters below 6000? If it does run, how many parameters can you fit before problems occur? –  Richie Cotton Oct 25 '11 at 17:17
Its tough to know where the cutoff is, but the loop will run fine if you cut the inner iterations. So, if I change the inner loop iterations from 1:6000, to 5990:6000 it runs fine. –  Bob Oct 25 '11 at 17:26

1 Answer 1

up vote 1 down vote accepted

When changing the data types from xts to numeric, the problem went away and the speed of processing increased dramatically. (seems obvious in hindsight)

share|improve this answer

Your Answer


