Page 1 of 1

Automatic Lag Selection

Posted: Thu Nov 08, 2012 8:43 am
by camilogong
Hi,
I am trying to run a routine to perform the best lag selection for a regression. When I run it it doesn't pick the best lag, but rather takes the last lag available.
The routine looks like this

for !i=0 to 12
!r2=0
%fcistring= " "
%fcibest=" "
if !i=0 then %fcistring= "fci"+@str({!j}{!k}{!l}{!m}{!n}{!o}{!p})
else %fcistring= "fci"+@str({!j}{!k}{!l}{!m}{!n}{!o}{!p})+ "("+@str(-{!i})+")"
endif
smpl 2005m09 @last-12
equation r{!j}{!k}{!l}{!m}{!n}{!o}{!p}
r{!j}{!k}{!l}{!m}{!n}{!o}{!p}.ls g c {%arstring} {%fcistring}
if r{!j}{!k}{!l}{!m}{!n}{!o}{!p}.@rbar2>!r2 then
!r2=r{!j}{!k}{!l}{!m}{!n}{!o}{!p}.@rbar2
%fcibest =%fcistring
r{!j}{!k}{!l}{!m}{!n}{!o}{!p}.ls g c {%arstring} {%fcibest}
else delete r{!j}{!k}{!l}{!m}{!n}{!o}{!p}
endif
next


Can someone give me a hand? I really appreciate it

Re: Automatic Lag Selection

Posted: Thu Nov 08, 2012 8:45 am
by EViews Gareth
I don't see anything that jumps out at me as being wrong.

Re: Automatic Lag Selection

Posted: Thu Nov 08, 2012 8:55 am
by camilogong
I know, that is what is driving me completely crazy.
Could you run the routine and see if you get any different results?
I attach the program and the xls
Rgds

Re: Automatic Lag Selection

Posted: Thu Nov 08, 2012 10:54 am
by EViews Gareth
You're resetting !r2 inside the loop :D

Move the !r2=0 to before the for loop.

Also, from an econometric point of view, you might want to check you're using the same number of observations in each equation.

Re: Automatic Lag Selection

Posted: Thu Nov 08, 2012 12:59 pm
by camilogong
Actually, setting the !r2 outside of the loop makes does not change matters all that much, as it still does not do the lag selection
What puzzles me is that I am currently runninng an identical program for another country and that one seems to be runnning (and doing the lag selection) fine (attached).
You are right that I need to set a fixed sample for the selection criteria to make sense.
Any clue would be greatly appreciated.