Automatic Lag Selection
Posted: Thu Nov 08, 2012 8:43 am
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
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