Page 1 of 1

Information criterion in a loop

Posted: Thu Aug 13, 2009 4:48 am
by JER
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

Re: Information criterion in a loop

Posted: Thu Aug 13, 2009 6:30 am
by trubador
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

Re: Information criterion in a loop

Posted: Fri Aug 14, 2009 5:05 am
by JER
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)

Re: Information criterion in a loop

Posted: Fri Aug 14, 2009 6:01 am
by trubador
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.

Re: Information criterion in a loop

Posted: Fri Aug 14, 2009 8:06 am
by EViews Gareth
For what it is worth, the scalar version will work in EViews 7.