Hello, I would like to put you the other question that I have about how to use loops for in R. The first is entitled “Loop For – ARMA model estimation and selection”. If you take a look and try to give me an answer to the first, I would be extremely thankful. I am an R beginner and I need R technical experts’ judgement to conduct my empirical analysis as efficiently as I can.

## Advertising

My second question is on how to loop over six variables (a,b,c,d,e) for an ARMA+GARCH model estimation. Here is the function to loop. USDlogreturns=diff(log(prices)) model<-ugarchspec(variance.model=list(model="fGARCH",submodel="c",garchOrder=c(d,e)),mean.model=list(armaOrder=c(a,b),include.mean=TRUE),distribution.model="f") modelfit<-ugarchfit(spec=model, data=USDlogreturns, solver="hybrid") Here is a description of the variables from a to f to be looped. ·ARMA orders (a,b). Both orders should be allowed to vary between 0 and 10. ·GARCH version (c). The versions should be allowed to switch from GARCH to AVGARCH, GJRGARCH, TGARCH, NGARCH, NAGARCH, APARCH and EGARCH. Note that the EGARCH version must be passed directly as “model” to the ugarchfit function. ·GARCH orders (d,e). The d order should be allowed to vary between 1 and 2. The e order should be allowed to vary between 0 and 2. ·Error distribution (f). The error distribution should be allowed to switch from Normal Gaussian to Student-T and GED. The objects to be returned from the loop are the model Akaike Information Criterion indicators, the p-values of the ADF test for standardized (stz) residual stationarity, the p-values of the Box-Ljung tests for stz residual serial uncorrelation and independence and the p-values of the Jarque-Bera test for stz residual normality. Here is the full list of the objects. armagarchaic=infocriteria(modelfit)[1] armagarchadftest=adf.test(modelfit@fit$z,k=trunc((length(modelfit@fit$z)-1)^(1/3)))$p.value armagarchboxtest=Box.test(modelfit@fit$z,lag=30,fitdf=d+e,type=c("Ljung-Box"))$p.value armagarchboxtest2=Box.test(modelfit@fit$z^2,lag=30,fitdf=d+e,type=c("Ljung-Box"))$p.value armagarchgoftest=gof(modelfit,c(20,30,40,50)) P.S. How do you tell R to set (d+e) (i.e. the sum of ARCH and GARCH orders) as fitdf in the Box-Ljung test command? Is it right as I typed? If you also believe that I should run the same model estimation in a simpler and efficient way, let me know on how to do that. Thank you in advance. --- Questa e-mail è stata controllata per individuare virus con Avast antivirus. https://www.avast.com/antivirus [[alternative HTML version deleted]] _______________________________________________ R-SIG-Finance@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.