Dear all,
my problem is the following: I running regressions for 10 countries where the time series named as follows. Country_y, Country_X. Where y is the left side var and x the right side var, country is just the county name. What i want to do now is running a loop in which i´m regressing y on x and some leads and lags of the first difference of x for each country. For model selection a info. criterion is to be minimized. So far, i put the y´s and x´s into a group object and also i have a group object with the first differences of the x-series: grp_y, grp_x and dgrp_x
My code looks roughly as follows where i used different example-codes posted in that forum here (by the way, thanks for that!):
for !i=1 to 10
for %country=grp_y.@seriesname(!i)
equation eq_{%country}
!mininfocrit=??? ' i don´t know what to include here
for !lag=2 to 4
eq_{%counry}.ls grp_y(!i) c grp_x(!i) dgrp_x(!i) 'here i want to include leads and lags but the group index seems not to work with the leads and lags
if eq_{%country}.@aic<!mininfocrit then
!bestlag=!lag
!mininfocrit=eq_{%country}.@aic
endif
next
next
eq_{%country}.ls grp_y(!i) c grp_x(!i) dgrp{%country}(-1 to -!bestlag) dgrp{%country}(1 to !bestlag)
Although it might look confused, hope you somehow get my idea and are able to help me or you can point out a different way to do it. Thanks a lot in advance
Group Object in a loop
Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt
Re: Group Object in a loop
Here is what I would do... with USA, UK and JPN as the example countries, assuming you have USA_Y, USA_X, UK_Y, UK_X, etc. in your workfile. Notice I don't use the groups.
You'll have to check out which of the below is the correct syntax:
Code: Select all
for %country USA UK JPN
equation eq_{%country}
!mininfocrit=999999
for !lag=-4 to -2
eq_{%country}.ls {%country}_y {%country}_x d({%country}_x)(-1 to !lag)
if eq_{%country}.@aic<!mininfocrit then
!bestlag=-!lag
!mininfocrit=eq_{%country}.@aic
endif
Next
eq_{%country}.ls {%country}_y {%country}_x d({%country}_x)(-1 to !bestlag)
Next
Code: Select all
d({%country}_x)(-1 to !lag)
or
d({%country}_x(-1 to !lag))
Re: Group Object in a loop
Hi gene,
thanks for your help. I see what you mean and working with a group object is indeed somewhat cumbersome. But still, there is a error massage saying that ...-1 to -4 is not a valid index. Do you have any further ideas? I tried the syntax both ways
Cheers, Adam
thanks for your help. I see what you mean and working with a group object is indeed somewhat cumbersome. But still, there is a error massage saying that ...-1 to -4 is not a valid index. Do you have any further ideas? I tried the syntax both ways
Cheers, Adam
Re: Group Object in a loop
Then you'll have to build up the lag part of the equation. There are many ways to do this. One way is to build the equation specifcation string:Hi gene,
thanks for your help. I see what you mean and working with a group object is indeed somewhat cumbersome. But still, there is a error massage saying that ...-1 to -4 is not a valid index. Do you have any further ideas? I tried the syntax both ways
Cheers, Adam
Code: Select all
for %country USA UK JPN
equation eq_{%country}
!mininfocrit=999999
%eq_str = %country+"_y " + %country+"_x"
%best_eq = %eq_str
for !lag=1 to 4
%eq_str = %eq_str + " d("+ %country+"_x(-" + @str(!lag)+"))"
eq_{%country}.ls {%eq_str}
if eq_{%country}.@aic<!mininfocrit then
%best_eq=%eq_str
!mininfocrit=eq_{%country}.@aic
endif
Next
eq_{%country}.ls {%best_eq}
Next
Re: Group Object in a loop
Hi Gene,
worked out nice. And sorry, been abscent for a long time. Thanks a lot for your help
worked out nice. And sorry, been abscent for a long time. Thanks a lot for your help
Who is online
Users browsing this forum: No registered users and 3 guests
