Page 1 of 1

lag selection with two independent variables

Posted: Tue Jul 21, 2009 9:58 am
by huseyinky
Hi everybody

I try to write a code that can make lag selection for 2 independent variables according to information criterion. The following code does not work. If anyone can help I appreciate with that.

for %y ainf1 ainf2 ainf3 ainf4 ainf5 ainf6
equation eq_{%y}
!mininfocrit=999999
for !lag=-4 to -1
for !lag2=-4 to -1
%regs=""
for !j=-4 to !lag
for !k=-4 to !lag2
%regs=%regs + "ainf(" + @str(!j) + " )" + "tr121(" + @str(!k) + " ) "
next
next
next
eq_{%y}.ls {%y} c {%regs}
if eq_{%y}.@aic<!mininfocrit then
!bestlag=!lag
!bestlag2=!lag2
!mininfocrit=eq_{%y}.@aic
endif
Next
eq_{%y}.ls {%y} c tr121(0 to !bestlag2) ainf(0 to !bestlag)
Next

Re: lag selection with two independent variables

Posted: Tue Jul 21, 2009 10:06 am
by EViews Gareth
It would be useful if you could either tell us why it doesn't work, and/or provide us with the data so that we may run it ourselves.

Re: lag selection with two independent variables

Posted: Tue Jul 21, 2009 10:15 am
by huseyinky
I thing there is a problem at the line
%regs=%regs + "ainf(" + @str(!j) + " )" + "tr121(" + @str(!k) + " ) "

I face with near singular problem. but regression seems like that ls ainf1 c ainf(-4)tr121 ainf(-4)tr121(-3) .... dependent variables are product in equation. I change the line such that
%regs= "ainf(" + @str(!j) + " )" + "tr121(" + @str(!k) + " ) "
Now it is working but I am not sure that the code evaluates all combinations.

Re: lag selection with two independent variables

Posted: Tue Jul 21, 2009 10:22 am
by EViews Gareth
You might need to put spaces into your %regs line.

Code: Select all

%regs=%regs + "ainf(" + @str(!j) + " ) " + "tr121(" + @str(!k) + " ) "

Re: lag selection with two independent variables

Posted: Tue Jul 21, 2009 10:36 am
by huseyinky
Unfortunately putting space did not work. same problem exist

Re: lag selection with two independent variables

Posted: Tue Jul 21, 2009 11:14 am
by huseyinky
I replace to %regs=%regs + "ainf(" + @str(!j) + " ) " + "tr121(" + @str(!k) + " ) " as

Code: Select all

%space=" " %regs=%regs + %space + "ainf(" + @str(!j) + " ) + %space + "tr121(" + @str(!k) + " ) "
It is working but I am still not sure that code evaluate all combinations.