/*############################################################################## # # # Information Criterion by Breno de Andrade Pinheiro Néri # # # # brenoneri@gmail.com www.fgv.br/aluno/bneri # # # # Septembre, 2005 - Version 1 # # # ################################################################################ # # # This code estimates the coefficients for twelve models of volatility with # # two different distributions: Normal and Skewed Student-t, namely: # # ARCH(1) # # ARCH(2) # # GARCH(1,1) # # GARCH(2,1) # # GARCH(1,2) # # GARCH(2,2) # # APARCH(1,0) # # APARCH(2,0) # # APARCH(1,1) # # APARCH(2,1) # # APARCH(1,2) # # APARCH(2,2) # # # # For each model and for each distribution, four information criterions are # # provided: Akaike, Schwarz (Bayesian), Shibata and Hannan-Quinn. # # # # You enter a time series vector (vY) in a file called vY.mat, with the # # observations in one single column. The models for volatility are estimated # # using the residuals of the ols regression of vY in its lag (with intercept). # # # # Due to the nonlinear optimizations, this code is computational intensive! # # # ################################################################################ # # # You may use this code only if you accept the conditions: # # (1) I am not liable for any problem caused by this code (i.e. you use it at # # your own risk); # # (2) You must give me credit in your papers where this code has been used. # # # ##############################################################################*/ #import // Set the path of the Garch40 package of your computer! static decl s_vE, s_obj; // ARCH(1) arch1(const vP) { decl vSigma2=s_vE[0]^2, i; for(i=0; i, vPna2=<1;0;0>, vPng11=<1;0;0>, vPng21=<1;0;0;0>, vPng12=<1;0;0;0>, vPng22=<1;0;0;0;0>, vPnap10=<1;0;0;2>, vPnap20=<1;0;0;0;0;2>, vPnap11=<1;0;0;0;2>, vPnap21=<1;0;0;0;0;0;2>, vPnap12=<1;0;0;0;0;2>, vPnap22=<1;0;0;0;0;0;0;2>, vPsta1=<1;0;10;1>, vPsta2=<1;0;0;10;1>, vPstg11=<1;0;0;10;1>, vPstg21=<1;0;0;0;10;1>, vPstg12=<1;0;0;0;10;1>, vPstg22=<1;0;0;0;0;10;1>, vPstap10=<1;0;0;2;10;1>, vPstap20=<1;0;0;0;0;2;10;1>, vPstap11=<1;0;0;0;2;10;1>, vPstap21=<1;0;0;0;0;0;2;10;1>, vPstap12=<1;0;0;0;0;2;10;1>, vPstap22=<1;0;0;0;0;0;0;2;10;1>, dP; // OLS Regression (You can use more lags, if you want!) s_obj=new Garch(); vY = vY[1:]; olsc(vY, 1~vYlag, &vOls); s_vE = vY-(1~vYlag)*vOls; // Optimizations MaxBFGS(LNA1, &vPna1, &dP, 0, 1); MaxBFGS(LNA2, &vPna2, &dP, 0, 1); MaxBFGS(LNG11, &vPng11, &dP, 0, 1); MaxBFGS(LNG21, &vPng21, &dP, 0, 1); MaxBFGS(LNG12, &vPng12, &dP, 0, 1); MaxBFGS(LNG22, &vPng22, &dP, 0, 1); MaxBFGS(LNAP10, &vPnap10, &dP, 0, 1); MaxBFGS(LNAP20, &vPnap20, &dP, 0, 1); MaxBFGS(LNAP11, &vPnap11, &dP, 0, 1); MaxBFGS(LNAP21, &vPnap21, &dP, 0, 1); MaxBFGS(LNAP12, &vPnap12, &dP, 0, 1); MaxBFGS(LNAP22, &vPnap22, &dP, 0, 1); MaxBFGS(LSTA1, &vPsta1, &dP, 0, 1); MaxBFGS(LSTA2, &vPsta2, &dP, 0, 1); MaxBFGS(LSTG11, &vPstg11, &dP, 0, 1); MaxBFGS(LSTG21, &vPstg21, &dP, 0, 1); MaxBFGS(LSTG12, &vPstg12, &dP, 0, 1); MaxBFGS(LSTG22, &vPstg22, &dP, 0, 1); MaxBFGS(LSTAP10, &vPstap10, &dP, 0, 1); MaxBFGS(LSTAP20, &vPstap20, &dP, 0, 1); MaxBFGS(LSTAP11, &vPstap11, &dP, 0, 1); MaxBFGS(LSTAP21, &vPstap21, &dP, 0, 1); MaxBFGS(LSTAP12, &vPstap12, &dP, 0, 1); MaxBFGS(LSTAP22, &vPstap22, &dP, 0, 1); // Reporting Results println("Normal ARCH(1) estimated coefficients and Information Criterions: ", "%r", {"omega:", "alpha1:"}, vPna1); println(s_obj.ICriterion(sumc(s_obj.GaussLik(s_vE, arch1(vPna1)[:rows(s_vE)-1])), rows(s_vE)-1, 2)); println("Normal ARCH(2) estimated coefficients and Information Criterions: ", "%r", {"omega:", "alpha1:", "alpha2:"}, vPna2); println(s_obj.ICriterion(sumc(s_obj.GaussLik(s_vE, arch2(vPna2)[:rows(s_vE)-1])), rows(s_vE)-1, 3)); println("Normal GARCH(1,1) estimated coefficients and Information Criterions: ", "%r", {"omega:", "alpha1:", "beta1:"}, vPng11); println(s_obj.ICriterion(sumc(s_obj.GaussLik(s_vE, garch11(vPng11)[:rows(s_vE)-1])), rows(s_vE)-1, 3)); println("Normal GARCH(2,1) estimated coefficients and Information Criterions: ", "%r", {"omega:", "alpha1:", "alpha2:", "beta1:"}, vPng21); println(s_obj.ICriterion(sumc(s_obj.GaussLik(s_vE, garch21(vPng21)[:rows(s_vE)-1])), rows(s_vE)-1, 4)); println("Normal GARCH(1,2) estimated coefficients and Information Criterions: ", "%r", {"omega:", "alpha1:", "beta1:", "beta2:"}, vPng12); println(s_obj.ICriterion(sumc(s_obj.GaussLik(s_vE, garch12(vPng12)[:rows(s_vE)-1])), rows(s_vE)-1, 4)); println("Normal GARCH(2,2) estimated coefficients and Information Criterions: ", "%r", {"omega:", "alpha1:", "alpha2:", "beta1:", "beta2:"}, vPng22); println(s_obj.ICriterion(sumc(s_obj.GaussLik(s_vE, garch22(vPng22)[:rows(s_vE)-1])), rows(s_vE)-1, 5)); println("Normal APARCH(1,0) estimated coefficients and Information Criterions: ", "%r", {"omega:", "alpha1:", "gamma1:", "delta:"}, vPnap10); println(s_obj.ICriterion(sumc(s_obj.GaussLik(s_vE, aparch10(vPnap10)[:rows(s_vE)-1])), rows(s_vE)-1, 4)); println("Normal APARCH(2,0) estimated coefficients and Information Criterions: ", "%r", {"omega:", "alpha1:", "gamma1:", "alpha2:", "gamma2:", "delta:"}, vPnap20); println(s_obj.ICriterion(sumc(s_obj.GaussLik(s_vE, aparch20(vPnap20)[:rows(s_vE)-1])), rows(s_vE)-1, 6)); println("Normal APARCH(1,1) estimated coefficients and Information Criterions: ", "%r", {"omega:", "alpha1:", "gamma1:", "beta1:", "delta:"}, vPnap11); println(s_obj.ICriterion(sumc(s_obj.GaussLik(s_vE, aparch11(vPnap11)[:rows(s_vE)-1])), rows(s_vE)-1, 5)); println("Normal APARCH(2,1) estimated coefficients and Information Criterions: ", "%r", {"omega:", "alpha1:", "gamma1:", "alpha2:", "gamma2:", "beta1:", "delta:"}, vPnap21); println(s_obj.ICriterion(sumc(s_obj.GaussLik(s_vE, aparch21(vPnap21)[:rows(s_vE)-1])), rows(s_vE)-1, 7)); println("Normal APARCH(1,2) estimated coefficients and Information Criterions: ", "%r", {"omega:", "alpha1:", "gamma1:", "beta1:", "beta2:", "delta:"}, vPnap12); println(s_obj.ICriterion(sumc(s_obj.GaussLik(s_vE, aparch12(vPnap12)[:rows(s_vE)-1])), rows(s_vE)-1, 6)); println("Normal APARCH(2,2) estimated coefficients and Information Criterions: ", "%r", {"omega:", "alpha1:", "gamma1:", "alpha2:", "gamma2:", "beta1:", "beta2:", "delta:"}, vPnap22); println(s_obj.ICriterion(sumc(s_obj.GaussLik(s_vE, aparch22(vPnap22)[:rows(s_vE)-1])), rows(s_vE)-1, 8)); println("Skewed Student-t ARCH(1) estimated coefficients and Information Criterions: ", "%r", {"omega:", "alpha1:", "nu:", "xi:"}, vPsta1); println(s_obj.ICriterion(sumc(s_obj.SkStudentLik(s_vE, arch1(vPsta1[:1])[:rows(s_vE)-1], log(vPsta1[3]), vPsta1[2])), rows(s_vE)-1, 4)); println("Skewed Student-t ARCH(2) estimated coefficients and Information Criterions: ", "%r", {"omega:", "alpha1:", "alpha2:", "nu:", "xi:"}, vPsta2); println(s_obj.ICriterion(sumc(s_obj.SkStudentLik(s_vE, arch2(vPsta2[:2])[:rows(s_vE)-1], log(vPsta2[4]), vPsta2[3])), rows(s_vE)-1, 5)); println("Skewed Student-t GARCH(1,1) estimated coefficients and Information Criterions: ", "%r", {"omega:", "alpha1:", "beta1:", "nu:", "xi:"}, vPstg11); println(s_obj.ICriterion(sumc(s_obj.SkStudentLik(s_vE, garch11(vPstg11[:2])[:rows(s_vE)-1], log(vPstg11[4]), vPstg11[3])), rows(s_vE)-1, 5)); println("Skewed Student-t GARCH(2,1) estimated coefficients and Information Criterions: ", "%r", {"omega:", "alpha1:", "alpha2:", "beta1:", "nu:", "xi:"}, vPstg21); println(s_obj.ICriterion(sumc(s_obj.SkStudentLik(s_vE, garch21(vPstg21[:3])[:rows(s_vE)-1], log(vPstg21[5]), vPstg21[4])), rows(s_vE)-1, 6)); println("Skewed Student-t GARCH(1,2) estimated coefficients and Information Criterions: ", "%r", {"omega:", "alpha1:", "beta1:", "beta2:", "nu:", "xi:"}, vPstg12); println(s_obj.ICriterion(sumc(s_obj.SkStudentLik(s_vE, garch12(vPstg12[:3])[:rows(s_vE)-1], log(vPstg12[5]), vPstg12[4])), rows(s_vE)-1, 6)); println("Skewed Student-t GARCH(2,2) estimated coefficients and Information Criterions: ", "%r", {"omega:", "alpha1:", "alpha2:", "beta1:", "beta2:", "nu:", "xi:"}, vPstg22); println(s_obj.ICriterion(sumc(s_obj.SkStudentLik(s_vE, garch22(vPstg22[:4])[:rows(s_vE)-1], log(vPstg22[6]), vPstg22[5])), rows(s_vE)-1, 7)); println("Skewed Student-t APARCH(1,0) estimated coefficients and Information Criterions: ", "%r", {"omega:", "alpha1:", "gamma1:", "delta:", "nu:", "xi:"}, vPstap10); println(s_obj.ICriterion(sumc(s_obj.SkStudentLik(s_vE, aparch10(vPstap10[:3])[:rows(s_vE)-1], log(vPstap10[5]), vPstap10[4])), rows(s_vE)-1, 6)); println("Skewed Student-t APARCH(2,0) estimated coefficients and Information Criterions: ", "%r", {"omega:", "alpha1:", "gamma1:", "alpha2:", "gamma2:", "delta:", "nu:", "xi:"}, vPstap20); println(s_obj.ICriterion(sumc(s_obj.SkStudentLik(s_vE, aparch20(vPstap20[:5])[:rows(s_vE)-1], log(vPstap20[7]), vPstap20[6])), rows(s_vE)-1, 7)); println("Skewed Student-t APARCH(1,1) estimated coefficients and Information Criterions: ", "%r", {"omega:", "alpha1:", "gamma1:", "beta1:", "delta:", "nu:", "xi:"}, vPstap11); println(s_obj.ICriterion(sumc(s_obj.SkStudentLik(s_vE, aparch11(vPstap11[:4])[:rows(s_vE)-1], log(vPstap11[6]), vPstap11[5])), rows(s_vE)-1, 8)); println("Skewed Student-t APARCH(2,1) estimated coefficients and Information Criterions: ", "%r", {"omega:", "alpha1:", "gamma1:", "alpha2:", "gamma2:", "beta1:", "delta:", "nu:", "xi:"}, vPstap21); println(s_obj.ICriterion(sumc(s_obj.SkStudentLik(s_vE, aparch21(vPstap21[:6])[:rows(s_vE)-1], log(vPstap21[8]), vPstap21[7])), rows(s_vE)-1, 9)); println("Skewed Student-t APARCH(1,2) estimated coefficients and Information Criterions: ", "%r", {"omega:", "alpha1:", "gamma1:", "beta1:", "beta2:", "delta:", "nu:", "xi:"}, vPstap12); println(s_obj.ICriterion(sumc(s_obj.SkStudentLik(s_vE, aparch12(vPstap12[:5])[:rows(s_vE)-1], log(vPstap12[7]), vPstap12[6])), rows(s_vE)-1, 8)); println("Skewed Student-t APARCH(2,2) estimated coefficients and Information Criterions: ", "%r", {"omega:", "alpha1:", "gamma1:", "alpha2:", "gamma2:", "beta1:", "beta2:", "delta:", "nu:", "xi:"}, vPstap22); println(s_obj.ICriterion(sumc(s_obj.SkStudentLik(s_vE, aparch22(vPstap22[:7])[:rows(s_vE)-1], log(vPstap22[9]), vPstap22[8])), rows(s_vE)-1, 10)); }