lag selection with two independent variables

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt

huseyinky
Posts: 18
Joined: Mon Apr 20, 2009 1:59 pm

lag selection with two independent variables

Postby huseyinky » Tue Jul 21, 2009 9:58 am

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

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13308
Joined: Tue Sep 16, 2008 5:38 pm

Re: lag selection with two independent variables

Postby EViews Gareth » Tue Jul 21, 2009 10:06 am

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.
Follow us on Twitter @IHSEViews

huseyinky
Posts: 18
Joined: Mon Apr 20, 2009 1:59 pm

Re: lag selection with two independent variables

Postby huseyinky » Tue Jul 21, 2009 10:15 am

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.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13308
Joined: Tue Sep 16, 2008 5:38 pm

Re: lag selection with two independent variables

Postby EViews Gareth » Tue Jul 21, 2009 10:22 am

You might need to put spaces into your %regs line.

Code: Select all

%regs=%regs + "ainf(" + @str(!j) + " ) " + "tr121(" + @str(!k) + " ) "
Follow us on Twitter @IHSEViews

huseyinky
Posts: 18
Joined: Mon Apr 20, 2009 1:59 pm

Re: lag selection with two independent variables

Postby huseyinky » Tue Jul 21, 2009 10:36 am

Unfortunately putting space did not work. same problem exist

huseyinky
Posts: 18
Joined: Mon Apr 20, 2009 1:59 pm

Re: lag selection with two independent variables

Postby huseyinky » Tue Jul 21, 2009 11:14 am

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.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 32 guests