Page 1 of 1

reference to member of group object

Posted: Thu Jul 22, 2010 7:02 pm
by maxchen
the following code has been run on EV5.1 and EV7.1

Code: Select all

wfcreate u 4 genr x = 1 genr y = @obsid genr z = x+2*y+nrnd group gz x y equation eq.ls z gz equation eqb call gSub(z,gz,eqb) subroutine local gSub(series y, group gp, equation eqb) c(11) = @sum(y) genr yg = gp(2) c(12) = @sum(yg) eqb.ls y gp endsub
I found that
  • gp(2) works fine, equals the global series y. By C(12) = 10
  • gp(2) in "eqb.ls y gp", short circuit to local series y

Re: reference to member of group object

Posted: Fri Jul 23, 2010 9:19 am
by EViews Glenn
What is going on is that when you pass in the series z as y in the local subroutine, all references to y in the subroutine are now matched to the input series z.

When you do the equation regression of y on gp in the subroutine, the gp is expanded to it's original definition which is x y. So the regression that you run is:

eqb.ls y x y

which is interpreted as since z is passed in as y

eqb.ls z x z

Now as I'm not certain what regression you wanted to run in the subroutine, I can't tell you how you should have crafted your subroutine. If you give me more information, I might be able to help.

Re: reference to member of group object

Posted: Fri Jul 23, 2010 6:30 pm
by maxchen
Thanks, I see.
However, first, I intended to have
eqb.ls z x y 'z x y are global
but fail. And thanks your for the confirmation.

Re: reference to member of group object

Posted: Sat Jul 24, 2010 5:59 am
by EViews Glenn
Make your series y call in the subroutine to a variable name that you are not likely to use, as in

subroutine local gSub(series _$$dep$$_, group gp, equation eqb)

and then everything else should go through as you've written.