[R] Interesting Memory Management Problem (Windows)

Bob rharlow86 at gmail.com
Thu Oct 27 14:36:34 CEST 2011


Hi,

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 very 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"".  After searching
through the forums (and also posting on Stack Overflow, so sorry if you are
reading this twice) I also tried using memory.limit(size = 3092), which did
not solve the problem.  The surprising thing about this is that my objects
are not very big, I never would have expected to have so many memory errors.  

library(rugarch)
library(xts)
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)){
        print(i)
        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))
            rm(spec.new)
            rm(fit)
            gc()
        }else{
            sig.est[i] <- NA
        }
    }
    save(sig.est, file = paste("egarch", names(tst.xts)[j], ".RData", sep =
""))
}

--
View this message in context: http://r.789695.n4.nabble.com/Interesting-Memory-Management-Problem-Windows-tp3944243p3944243.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list