Page 1 of 1

storing r2 into vector

Posted: Mon Sep 27, 2010 12:38 am
by simonius
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

Re: storing r2 into vector

Posted: Mon Sep 27, 2010 8:14 am
by EViews Gareth
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