reference to member of group object

For questions regarding programming in the EViews programming language.

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

maxchen
Posts: 191
Joined: Fri Oct 10, 2008 4:03 pm

reference to member of group object

Postby maxchen » Thu Jul 22, 2010 7:02 pm

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

EViews Glenn
EViews Developer
Posts: 2682
Joined: Wed Oct 15, 2008 9:17 am

Re: reference to member of group object

Postby EViews Glenn » Fri Jul 23, 2010 9:19 am

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.

maxchen
Posts: 191
Joined: Fri Oct 10, 2008 4:03 pm

Re: reference to member of group object

Postby maxchen » Fri Jul 23, 2010 6:30 pm

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.

EViews Glenn
EViews Developer
Posts: 2682
Joined: Wed Oct 15, 2008 9:17 am

Re: reference to member of group object

Postby EViews Glenn » Sat Jul 24, 2010 5:59 am

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.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests