Information criterion in a loop

For questions regarding programming in the EViews programming language.

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

JER
Posts: 4
Joined: Wed Aug 12, 2009 4:20 am

Information criterion in a loop

Postby JER » Thu Aug 13, 2009 4:48 am

Hi

I want to obtain the AIC, SIC and HQ value for an estimated equation using a replacement variable in a for-next loop:

Code: Select all

 
for %crit "@aic" "@schwarz" "@hq"
equation eq_ar.ls y c ar(1) ar(2)
scalar test_{%crit}  = eq_ar.{%crit}
next


Unfortunately, this doesn't work.
I also tried:

for %crit "aic" "schwarz" "hq" ....with... scalar test_{%crit} = eq_ar.@{%crit}

But this doesn't work either. I guess the problem is the "@"...
Is there a way to make this for-next-loop work using a replacement variable for a "@"-function?

Thanks a lot for your help

trubador
Did you use forum search?
Posts: 1518
Joined: Thu Nov 20, 2008 12:04 pm

Re: Information criterion in a loop

Postby trubador » Thu Aug 13, 2009 6:30 am

There are plenty of ways to overcome this issue. Here is one:

Code: Select all

equation eq_ar.ls y1 c ar(1) ar(2)
freeze(output) eq_ar.results

!i=16
for %crit aic schwarz hq
scalar test_{%crit} = @val(output(!i,5))
!i=!i+1
next
delete output

JER
Posts: 4
Joined: Wed Aug 12, 2009 4:20 am

Re: Information criterion in a loop

Postby JER » Fri Aug 14, 2009 5:05 am

thank you very much for your suggestion. This is a very nice alternative and it works :)

However I still wonder whether one can use @functions with replacement variables in the described way in general in Eviews. (e.g. when the desired value does not appear in the results table)

trubador
Did you use forum search?
Posts: 1518
Joined: Thu Nov 20, 2008 12:04 pm

Re: Information criterion in a loop

Postby trubador » Fri Aug 14, 2009 6:01 am

If the desired value does not appear in the results table, then you can freeze the output generated by the function and then refer to the cells of your interest. The use of function handle and functions with replacement variables is a bit problematic. Actually, the problem arises when you try to assign the output of the function to a scalar or a vector. For instance, while the following command will generate an error message:

Code: Select all

%f = "@mean"
scalar res = {%f}(y) or
vector res = {%f}(y)
the one below will complete task successfully:

Code: Select all

%f = "@mean"
show {%f}(y) or
series res = {%f}(y)
I do not think if it is really necessary to have such a feature, since I believe it will always be possible to find a workaround.

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

Re: Information criterion in a loop

Postby EViews Gareth » Fri Aug 14, 2009 8:06 am

For what it is worth, the scalar version will work in EViews 7.
Follow us on Twitter @IHSEViews


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 23 guests