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
lag selection with two independent variables
Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13308
- Joined: Tue Sep 16, 2008 5:38 pm
Re: lag selection with two independent variables
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
Re: lag selection with two independent variables
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.
%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.
-
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13308
- Joined: Tue Sep 16, 2008 5:38 pm
Re: lag selection with two independent variables
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
Re: lag selection with two independent variables
Unfortunately putting space did not work. same problem exist
Re: lag selection with two independent variables
I replace to %regs=%regs + "ainf(" + @str(!j) + " ) " + "tr121(" + @str(!k) + " ) " as
It is working but I am still not sure that code evaluate all combinations.
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.
Who is online
Users browsing this forum: No registered users and 32 guests