'E-views Program for estimation of ARMA models 'Schwarz criterion 'by Freddy Rojas 'Universidad de Chile 'e-mail: frojasca@facea.uchile.cl 'Last update 09/24/2011 'Last update 09/30/2011 backcast off feature was included subroutine arma MODE VER4 '------------------------------------------------------------------------- 'Information required '%const="c " ' with constant or not '%0="serie1" 'depend variable ' you have to look the period when begins your data! 'be careful with series in differences 'you have to create a serie, do not put d(serie). '%date_i="1" '1998:01" 'initial date '%date_f="500" '2005:02" 'last date '!lagp=16 'AR process '!lagq=0 'MA process 'Include estimation without or with backcast applied to MA terms '----------------------------------------------------------- %regres2=" " %regres4=" " %regres5=" " %regres6=" " %regres7=" " %0=%0+" "+%const smpl %date_i+!lagp %date_f matrix(!lagp+1,!lagq+1) f !max=1 'n de variables for !j=1 to !max for !i=1 to !lagp %regres2=%regres2+" ar("+@str(!i)+")" %regres3=%regres2 equation ar1.ls({%bkcast}) %0 %regres2 'f(!i+1,1)=ar1.@{%ic} if @upper(%icriterion) = "AIC" then f(!i+1,1)=ar1.@aic endif if @upper(%icriterion) = "SCHWARZ" then f(!i+1,1)=ar1.@schwarz endif if @upper(%icriterion) = "HQ" then f(!i+1,1)=ar1.@hq endif if !lagq>=1 then for !q=1 to !lagq %regres2=%regres2+" ma("+@str(!q)+")" equation arma.ls({%bkcast}) %0 %regres2 if !i=1 then %regres4=%regres4+" ma("+@str(!q)+")" equation ma1.ls({%bkcast}) %0 %regres4 'f(1,!q+1)=ma1.{%ic} if @upper(%icriterion) = "AIC" then f(1,!q+1)=ma1.@aic endif if @upper(%icriterion) = "SCHWARZ" then f(1,!q+1)=ma1.@schwarz endif if @upper(%icriterion) = "HQ" then f(1,!q+1)=ma1.@hq endif else !a=1 endif 'f(!i+1,!q+1)=arma.@{%ic} if @upper(%icriterion) = "AIC" then f(!i+1,!q+1)=arma.@aic endif if @upper(%icriterion) = "SCHWARZ" then f(!i+1,!q+1)=arma.@schwarz endif if @upper(%icriterion) = "HQ" then f(!i+1,!q+1)=arma.@hq endif next else equation ma1.ls({%bkcast}) %0 equation arma.ls({%bkcast}) %0 %regres2 endif %regres2=%regres3 next next F(1,1)=na 'Without drift !lagq=!lagq+1 !lagp=!lagp+1 for !qq=1 to !lagq for !pp=1 to !lagp if f(!pp,!qq)=@min(f) and !qq=1 and !pp>1 then for !w1=2 to !pp %regres5=%regres5+" ar("+@str(!w1-1)+")" next equation final_ARMA.ls({%bkcast}) %0 %regres5 else if f(!pp,!qq)=@min(f) and !qq>1 and !pp=1 then for !w2=2 to !qq %regres6=%regres6+" ma("+@str(!w2-1)+")" next equation final_ARMA.ls({%bkcast}) %0 %regres6 else if f(!pp,!qq)=@min(f) and !qq>1 and !pp>1 then for !m=2 to !pp %regres7=%regres7+" ar("+@str(!m-1)+")" %regres3=%regres7 next for !q1=2 to !qq %regres7=%regres7+" ma("+@str(!q1-1)+")" next equation final_ARMA.ls({%bkcast}) %0 %regres7 else !x=1 endif endif endif next next d ar1 arma ma1 matrix anex=f 'f anex d f smpl @all 'show final_ARMA endsub