Search code examples
rmatlabstatisticscode-translationeconomics

GARCH model specification in R and Matlab


I want to do to GARCH modeling in R and for this I need do translate a Matlab code to R. I tried different packages, e.g. rugarch. However, I could not figure the right specification in R which is equivalent to the one in Matlab.

The Matlab code is as follows:

spec = garchset('C',0,'K',0.0001,'GARCH',0.9,'ARCH',0.05,'Display','off');
[Ca,Ea,LLa,A,Sa,Suma] = garchfit(spec,data); 

Could somebody tell me how to put this in R?


Solution

  • The two lines of Matlab code stated in the question can be translated to R by using the rugarch package. At first, the mean model is set to have no AR and no MA part, so that it is simply a constant. Secondly, the variance model is standard GARCH (sGARCH) and has one GARCH and one ARCH component. Since in the provided Matlab code all parameters are fixed, one needs to include the fixed.pars command. Here, mu, alpha1, beta1 and omega are the values of the unconditional mean, of the ARCH parameter, GARCH parameter and the intercept of the variance model, respectively.

    install.packages("rugarch")
    require(rugarch)
    spec <- ugarchspec(mean.model=list(armaOrder=c(0,0)),
            variance.model=list(model = "sGARCH", garchOrder = c(1,1)), 
            fixed.pars=list(mu = 0, alpha1=0.05, beta1 = 0.9, omega = 0.0001))
    
    garch_fit <- ugarchfilter(spec = spec, data = data)
    

    The information contained in [Ca,Ea,LLa,A,Sa,Suma] can then be found by applying the following functions to garch_fit, e.g. residuals(garch_fit, standardize = FALSE) extracts the unstandardized residuals.

    coef: Extracts the coefficients.
    fitted: Extracts the filtered values.
    infocriteria: Calculates and returns various information criteria.
    likelihood: Extracts the likelihood.
    residuals: Extracts the residuals. Optional logical argument standardize (default is FALSE) allows to extract the standardized residuals

    More detailed information can be found in the rugarch package manual guide.