storing r2 into vector

For questions regarding programming in the EViews programming language.

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

simonius
Posts: 2
Joined: Tue Jun 15, 2010 12:26 pm

storing r2 into vector

Postby simonius » Mon Sep 27, 2010 12:38 am

Dear all, I use the following code in eviews 6 to store the R squared of 150 regressions to a vector.

Code: Select all

'create vector to store r-squares vector(150) r2s 'create empty equation to be used inside the loop equation eq ''counter of how many equations we have run !rowcounter=1 for !i=1 to 150 eq.ls n_a{!i} c macro r2s(!rowcounter) = eq.@r2 !rowcounter = !rowcounter+1 next
However, sometimes the series of a dependent variable are missing in my workfile, e.g. n_a17. Then the loops stops and doesn't store the R2 of later numbers (e.g. n_a18). Is there any way to program eviews in order to skip the missing series and continue with the series that do appear in the workfile?

thanks a lot,

Simon

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

Re: storing r2 into vector

Postby EViews Gareth » Mon Sep 27, 2010 8:14 am

You can use @isobject to check whether the series exists or not. Something like:

Code: Select all

'create vector to store r-squares vector(150) r2s 'create empty equation to be used inside the loop equation eq ''counter of how many equations we have run !rowcounter=1 for !i=1 to 150 %name = "n_a" + @str(!i) if @isobject(%name) then eq.ls n_a{!i} c macro r2s(!rowcounter) = eq.@r2 !rowcounter = !rowcounter+1 endif next


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests