Record Schwarz, Akaike, HQ

For questions regarding programming in the EViews programming language.

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

jasmin
Posts: 19
Joined: Thu Jun 16, 2011 8:50 am

Record Schwarz, Akaike, HQ

Postby jasmin » Mon Jun 27, 2011 9:35 am

I am running various regressions and comparing the SC, AC, HQC of the regressions. I always need to write the SC, AC, HC on a paper and after run again and do it again. Alternatively I could freeze the output of 10 regressions and compare it like that. You can see it is not efficient. How could I create a program, that would run 10 ls regressions and record the SC, AC, HC as an output (it could be a matrix output, but any other output will do or might be better)?

For simplicity assume that there are 5 ls:

ls aaa c bbb
ls aaa c bbb ddd
ls aaa c bbb ddd eee
ls aaa c bbb ddd eee fff
ls aaa c bbb ddd eee fff ggg

And I would expect an output like this:

X [AC] [SC] [HQC]
1 [2.1] [2.7] [1.9]
2 [2.0] [2.5] [1.4]
3 [2.2] [2.7] [1.5]
4 [2.3] [2.8] [1.6]
5 [2.4] [2.9] [1.8]

This would make it easy to write all the equations I want to test into the program, and then just run the programme and see all the criteria as an output, spool, or matrix. It could also record the R2 there etc. Note: I will make sure all the equations have the same sample for the comparison (that is clear).

Is it possible to do this? Thanks!

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

Re: Record Schwarz, Akaike, HQ

Postby EViews Gareth » Mon Jun 27, 2011 9:43 am

You can use the @aic, @schwarz and @hq data members to record them. What you're doing is similar to the programming guide example that stores the R2 from each equation.

jasmin
Posts: 19
Joined: Thu Jun 16, 2011 8:50 am

Re: Record Schwarz, Akaike, HQ

Postby jasmin » Mon Jun 27, 2011 10:53 am

Gareth, your advice is perfect as always. I followed the instruction, and create a very simpel program without even using the loops. For reference to this question I am posting the program below.

Code: Select all

'create vector to store r-squares matrix(10,3) comparison 'create empty equation to be used inside the loop equation eq 'Equation 1 eq.ls aaa c bbb comparison(1,1)=eq.@schwarz comparison(1,2)=eq.@aic comparison(1,3)=eq.@hq 'Equation 2 eq.ls aaa c bbb ddd comparison(2,1)=eq.@schwarz comparison(2,2)=eq.@aic comparison(2,3)=eq.@hq 'Equation 3 eq.ls aaa c bbb ddd eee comparison(3,1)=eq.@schwarz comparison(3,2)=eq.@aic comparison(3,3)=eq.@hq 'Display results show comparison
Note: This program could obviously do as many euqation as necessary.

Two more questions:

(1) Can I do something to rename the columns in the matrix from C1, C2, C3 to "SWC", "AIC", "HQC". This probably can't be done, but it’s better to ask. (Btw. is there any other way to show the results then a matrix?)

(2) For model comparison it matters that the sample is the same (as pointed out in a previous post on this forum on lag comparison of VARs). So I would like to put in the matrix in row 4 and row 5 the sample and the number of observations. Can that be done?

Example: As in the matrix below, the next rows would be on number of [observation] and the [sample] used in the eq. Obvious from this example, the 3rd equation is not comparable with the two above – exactly for this type of error I want to put this data in the matrix.

X [Observations] [Sampe]
1 [56] [1996Q4 2011Q4]
2 [56] [1996Q4 2011Q4]
3 [51] [1997Q4 2011Q4]

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

Re: Record Schwarz, Akaike, HQ

Postby EViews Gareth » Mon Jun 27, 2011 11:14 am

Use a table rather than a matrix. Tables can hold both numbers and characters, so you can title your rows/columns.

Something like:

Code: Select all

table mytable mytable(1,1) = "AIC" mytable(2,1) = eq.@aic

jasmin
Posts: 19
Joined: Thu Jun 16, 2011 8:50 am

Re: Record Schwarz, Akaike, HQ

Postby jasmin » Mon Jun 27, 2011 4:26 pm

Everything works now. As a final step,let's say that column 2 of the table represents the Schwarz Criterion: I would like to select the minium of that column 2. and set it to yellow. How do I find the minimum (!r,2) in a table colum 2?

Code: Select all

mytable.setfillcolor(!r,2) yellow
P.S. This is a minor, but is there a single command to clear all the table? Now, it tends to overwrite itself, leaving old figures in (if they are not overwriten by new).

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

Re: Record Schwarz, Akaike, HQ

Postby EViews Gareth » Mon Jun 27, 2011 6:08 pm

No, but you can always delete it.

jasmin
Posts: 19
Joined: Thu Jun 16, 2011 8:50 am

Re: Record Schwarz, Akaike, HQ

Postby jasmin » Tue Jun 28, 2011 2:54 am

Thanks for that. Is it possible to calculate the position of a minimum in a table column in EViews? Such as in the example of a table below, the program would find that row 2 is a minimum for colum 2 (AIC):

X [AIC] [SC] [HQC]
1 [2.1] [2.7] [1.9]
2 [2.0] [2.5] [1.4]
3 [2.2] [2.7] [1.5]
4 [2.3] [2.8] [1.6]
5 [2.4] [2.9] [1.8]

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

Re: Record Schwarz, Akaike, HQ

Postby EViews Gareth » Tue Jun 28, 2011 7:51 am

You'll just have to loop through the elements one at a time and find the minimum.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests