First time asking a question here, I'll do my best to be explicit - but let me know if I should provide more info!
I'm currently working with "MSGARCH" package in R (version 3.3.3). I'm trying to caclulate rolling VaR for 288 MS-GARCH models, but it seems really time-consuming. I know that there are packages that allow to use all cores in R, but I have no idea how to use them, especially on Windows 7 (64 bit).
library(GAS)
library(MSGARCH)
for (i in 1:N_out_of_sample){
y_train <- y[i:(N_sample+i-1)]
y_OOS[i] <- y[N_sample+i]
for (j in 1:a){
model_fit[[j]] <- fit.mle(spec = spec.list[[j]], y = y_train)
VaR_OOS[i,j] <- risk(object = model_fit[[j]]$spec,
theta = model_fit[[j]]$theta,
y = y_train,
level = 0.95,
ES = FALSE,
do.its = FALSE)$VaR
saveRDS(VaR_OOS, file = "var.rds")
}
}
Where y
is exchange rate, spec.list()
contains 288 specifications of MS-GARCH.
Is it possible to:
- make R fit models using all cores;
divide specifications of models in groups and fit them parallel on all cores.
Thanks to all contributors!