Page 3 of 4

Re: Automatic ARMA selection

Posted: Tue Sep 03, 2013 7:10 am
by EViews Gareth
It probably won't run in EV6.

Re: Automatic ARMA selection

Posted: Wed Sep 04, 2013 11:18 am
by priyanshi
Thank you Gareth. Then I think I will go ahead with the try and error method by fixing the maximum lag length at 4 for the daily data.

Re: Automatic ARMA selection

Posted: Fri Aug 07, 2015 9:04 pm
by diggetybo
Hello,

I was wondering which spot is right for entering a sample restriction clause. I originally thought this could be toggled from the workfile interface, but even when I restrict the workfile sample range, the ARMA selection program always uses the full range of the data.

Thanks again for your excellent programming resources!

Re: Automatic ARMA selection

Posted: Fri Aug 07, 2015 9:27 pm
by EViews Gareth

Code: Select all

smpl @first+!maxAR @last

Change that line.

Re: Automatic ARMA selection

Posted: Sun Aug 23, 2015 7:15 pm
by priyanshi
Hi Gareth,

I ran the code on one of my series. In addition, i tried to confirm results using the Automatic ARIMA selection addin. The results vary. While the Schwarz value against zero lag comes same in both cases, it varies for lag 1,2,3 and 4.

i want to specify that i have one more independent variable other than "c". Also i am setting MA=0 and i am checking upto 4 lags of AR.

Please help me. I would be very thankful.

-Priyanshi

Re: Automatic ARMA selection

Posted: Sun Aug 23, 2015 7:38 pm
by EViews Gareth
There are many many reasons they could differ

Re: Automatic ARMA selection

Posted: Sun Aug 23, 2015 10:10 pm
by priyanshi
Thank you for your reply!

Re: Automatic ARMA selection

Posted: Wed Mar 02, 2016 12:18 am
by Sammoland
Hi

I am trying to run an auto ARMA selection code, with a base in the code discussed here. However, I would like to run the code using a for loop that creates equations for each series in a group. I've tried to use a common identifier of "m_*", but still struggling. I've placed the code below, can anyone advise? The idea is it creates and names each equation as dl+the name of the original series.

for !i=1 to batch01.count 'create the group name
%iname= batch01.@seriesname(!i) 'identifiy the individual series in the group
next
%iname = "{dl}_{%iname}" 'name of equation object that will be used.
%maxAR = "4" 'maximum number of AR terms
%maxMA = "4" 'maximum number of MA terms
%dep = "d(log{%iname})" 'dependent variable
%regs = "C " 'independent variables
%criterion = "@AIC" 'which criterion to use enter "@AIC" for Akaike, "@schwarz" for Schwarz, and @HQ for Hannan-Quinn

!maxAR = @val(%maxAR)
!maxMA = @val(%maxMA)


close {%iname}

'create table for storing critical values.
%matname = "crits"
if @isobject(%matname) then
%matname = "__crits"
if @isobject(%matname) then
delete {%matname}
endif
endif
table(!maxar+2,!maxma+2) {%matname}
{%matname}(1,1) = "AR / MA"
{%matname}.setlines(1) +b
{%matname}.setlines(a) +r

'set sample
smpl @first+!maxAR @last

!mincrit = 1e12 'set the minimum to an artificially large value to begin

'estimate the models
%arstring = ""
for !i=0 to !maxar
'build up string for AR terms.
if !i>0 then
%arstring = %arstring + " ar(" + @str(!i) + ")"
endif
%mastring = ""
for !j=0 to !maxma
'build up string for MA terms
if !j>0 then
%mastring = %mastring + " ma(" + @str(!j) + ")"
endif
'estimate equation
equation {%iname}.ls {%dep} {%regs} {%arstring} {%mastring}
'capture criterion
if @upper(%criterion) = "@AIC" then
!crit = {%iname}.@aic
endif
if @upper(%criterion) = "@SCHWARZ" then
!crit = {%i
name}.@schwarz
endif
if @upper(%criterion) = "@HQ" then
!crit = {%iname}.@hq
endif
'compare criterion
if !crit < !mincrit then
!mincrit = !crit
!bestAR = !i
!bestMA = !j
%bestARstr = %arstring 'store the best ar string
%bestMAstr = %mastring 'store the best ma string
{%matname}.settextcolor(@all) black 'table formatting.
!ii=!i+2
!jj=!j+2
{%matname}.settextcolor(!ii,!jj) red
endif
{%matname}(!i+2,!j+2) = !crit
{%matname}(!i+2,1) = !i
{%matname}(1,!j+2) = !j
next
next

equation {%iname}.ls {%dep} {%regs} {%bestARstr} {%bestMAstr}

show {%iname}
show {%matname}

Re: Automatic ARMA selection

Posted: Wed Mar 02, 2016 12:59 am
by EViews Gareth
All of the estimation stuff is done outside your loop the loops through the group members. It needs to be done inside the loop

Re: Automatic ARMA selection

Posted: Fri Apr 15, 2016 7:40 am
by Sammoland
Hi All

I am attempting to run a program that runs an ols equation where the lag length of the independent variables are selected automatically. The idea is to run through each independent variable, select the optimum lags, and then forecast the dependent variable based on this.

The code is a variation of the auto ARMA selection, but I feel I am missing something. Any help here?

Here is the code:

Code: Select all

for !p=1 to gexp_f.count
   %var = gexp_f.@seriesname(!p) 'name of var
   




'h_mark_stre h_sup_stre pmi veh_s_com veh_s_pas veh_s_tot

%eqname = "fore" 'name of equation object that will be used.
%dep = "y1_ind" 'dependent variable

%maxlag = "4" 'maximum number of AR terms
%maxlagabs="4" 'maximum number of AR terms (absolute)
'%maxMA = "5" 'maximum number of MA terms

%regs = "C " 'independent variables
%criterion = "@schwarz" 'which criterion to use enter "@AIC" for Akaike, "@schwarz" for Schwarz, and @HQ for Hannan-Quinn

!maxlag = @val(%maxlag)
!maxlagabs=@val(%maxlagabs)


close {%eqname}

'set sample
smpl @first+!maxlagabs @last

!mincrit = 1e12 'set the minimum to an artificially large value to begin

'estimate the models
%lagstring = ""
for !i=0 to !maxlag
'build up string for lag terms.
if !i>0 then
%lagstring =  %var+"(-" + @str(!i) + ")"
endif
'%mastring = ""
'for !j=0 to !maxma
'build up string for MA terms
'if !j>0 then

'estimate equation

smpl 1980m1 %end
equation {%eqname}.ls dlog({%dep}) {%regs} {%lagstring} '{%mastring}

'capture criterion
if @upper(%criterion) = "@AIC" then
!crit = {%eqname}.@aic
endif
if @upper(%criterion) = "@SCHWARZ" then
!crit = {%eqname}.@schwarz
endif
if @upper(%criterion) = "@HQ" then
!crit = {%eqname}.@hq
endif

next


equation {%eqname}_{%var}.ls dlog({%dep}) {%regs} {%bestlagstr}

Re: Automatic ARMA selection

Posted: Thu Aug 11, 2016 8:09 pm
by dwinda
Dear Gareth or Trubador

I am using Eviews 9, the ARMA method is maximum likelihood and it could not be tested with LM test. Do you know the reason behind this? or how can we change the method in order to use LM test.


Thank you

Re: Automatic ARMA selection

Posted: Thu Aug 11, 2016 8:37 pm
by EViews Gareth
Change the ARMA method to CLS.

Re: Automatic ARMA selection

Posted: Tue Nov 07, 2017 4:21 am
by flourence
Hello I'm using eviews 9. And I am currently using Automatic Arima to find the best model for our data series but we had a hard time understanding the rules in AR and MA that's why we dont know if 4 is fixed in both MA and AR or we need to change that and how ? Thank you for your kindly consideration .

Re: Automatic ARMA selection

Posted: Wed Nov 08, 2017 4:47 pm
by Felipe
Hello!
I want to change the program beacuse I need a regression without constant. I stablished a conditional, but it does't work.

Code: Select all

'Create some data.  Delete these first few lines if you want to run on your existing workfile.

series y_SW =0
copy  etec y_SW


'Program that calculates the "best" ARMA specification for an equation.  Edit the variables below to match your particular data/setup.

%eqname = "ciclo_SW"   'name of equation object that will be used.
%maxAR = "4"           'maximum number of AR terms
%maxMA = "4" 'maximum number of MA terms
%dep = "Y_SW"   'dependent variable
%regs = "C "   'independent variables
%criterion = "@schwarz"    'which criterion to use  enter "@AIC" for Akaike, "@schwarz" for Schwarz, and @HQ for Hannan-Quinn

!maxAR = @val(%maxAR)
!maxMA = @val(%maxMA)


close {%eqname}


'create table for storing critical values.
%matname = "crits_SW"
if @isobject(%matname) then
   %matname = "__crits_SW"
   if @isobject(%matname) then
      delete {%matname}
   endif
endif
table(!maxar+2,!maxma+2) {%matname}
{%matname}(1,1) = "AR /  MA"
{%matname}.setlines(1) +b
{%matname}.setlines(a) +r

'set sample
smpl @all

!mincrit = 1e12  'set the minimum to an artificially large value to begin

'estimate the models
%arstring = ""
for !i=0 to !maxar
   'build up string for AR terms.
   if !i>0 then
      %arstring = %arstring + " ar(" + @str(!i) + ")"
   endif
   
%mastring = ""
   for !j=0 to !maxma
      'build up string for MA terms
      if !j>0 then
         %mastring = %mastring + " ma(" + @str(!j) + ")"
      endif
     
      'estimate equation
if %arstring="ar(1)" or %arstring="ar(2)" or  %arstring="ar(3)" or  %arstring="ar(4)" or %mastring="ma(1)" or %mastring="ma(2)" or %mastring="ma(3)" or %mastring="ma(4)"  then
       equation {%eqname}.ls(arma=cls, optmethod=legacy) {%dep} {%arstring}{%mastring}
endif

if %arstring="ar(0)" and  %mastring="ma(0)" then
      equation{%eqname}.ls(arma=cls, optmethod=legacy) {%dep} {%regs}
endif
      'capture criterion
      if @upper(%criterion) = "@SCHWARZ" then
         !crit = {%eqname}.@schwarz
      endif
next
next

I have an error because %eqname is undeterminated or undifined. I think last conditionals isn't correct but I don't know why.

Re: Automatic ARMA selection

Posted: Wed Nov 08, 2017 4:54 pm
by EViews Gareth
Not sure what you're trying to do - but have you tried the built in automatic ARMA forecasting (which also does arma model selection)?