subroutine calls in a loop

For questions regarding programming in the EViews programming language.

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

donihue
Posts: 139
Joined: Wed Oct 07, 2009 8:51 am

subroutine calls in a loop

Postby donihue » Thu Mar 24, 2011 8:36 am

Hello,

I am having trouble running a programme loop in the following circumstances:

1. the programme "abcd.prg" is implemented via the command line as follows: abcd(..., a1=0.5,a2=0.5,a3=0.1, ...) ...

2. the programme "abcd.prg" calls the subroutine "efgh" as follows: call efgh(... %a1, %a2 , %a3, ... )
[reading %a1, %a2 , %a3 as strings]

3. the subroutine "efgh" then calls another subroutine called "ijkl" as follows: call ijkl(... {%a1}, {%a2}, {%a3}, ...)
[reading {%a1}, {%a2}, {%a3} as scalars]

This works fine if all three of a1, a2 and a3 are explicitly written as numbers (eg, 0.5, 0.4, 0.1) in the initial implementation of *abcd"
But it breaks down if one of the three is a scalar (used in a loop) defined as, eg, "scalar w1=0.5" and that scalar is used to implement "abcd.prg" as in
abcd(...,a1=w1,a2=0.5,a3=0.1, ...) ...

I am sure there is a simple solution to this, but I do not know what it is. Can anyone help, please?

Regards
Donihue

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

Re: subroutine calls in a loop

Postby EViews Gareth » Thu Mar 24, 2011 9:04 am

That's a little tricky to follow. You might want to come up with a simple example.

donihue
Posts: 139
Joined: Wed Oct 07, 2009 8:51 am

Re: subroutine calls in a loop

Postby donihue » Thu Mar 24, 2011 9:44 am

Sorry, Gareth. I was trying to simplify, evidently unsuccessfully.

The problem is in using the BVAR Add-in with the "koko" option. My loop programme (simplified) is:

scalar w1=0.05
for !i = 1 to 9
scalar w1=w1+0.05
bvar(Prior=2,c,it,h=20,a1=w1,a2=0.5,a3=0.1,irfper=20) 4 lm2 rl rs ly pi
next


This calls "koko", which in turn calls "hyperpriors"

But I receive the following error message:

"CALL HYPERPRIORS(_VPRIOR01, _APRIOR01, _SIGMA_SQ01, SIGMA, _YRAW01, 4, 41, 37, 21, 5, 1, A1, 0.5, 0.1)
A1 is not defined."

The problem does not arise when running the same loop (mutatis mutandis) with the Sims-Zha model, which doesn't call "hyperpriors", so I am guessing that the reason is what I outlined in my first message, ie, that "koko" uses strings, and "hyperpriors" uses scalars

Regards
Donihue

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

Re: subroutine calls in a loop

Postby EViews Gareth » Thu Mar 24, 2011 9:56 am

The following (using the latest posted version of BVAR) appears to work for me:

Code: Select all

create u 1000 series lm2 = nrnd series rl = nrnd series rs = nrnd scalar w1=0.05 for !i = 1 to 9 scalar w1=w1+0.05 bvar(Prior=2,c,it,h=20,a1=w1,a2=0.5,a3=0.1,irfper=20) 4 lm2 rl rs next

donihue
Posts: 139
Joined: Wed Oct 07, 2009 8:51 am

Re: subroutine calls in a loop

Postby donihue » Thu Mar 24, 2011 10:10 am

Thanks, Gareth.
I thought I had the latest version (downloaded yesterday) but apparently not, as your example did not work for me (same error message).
I have downloaded again just now, and your example works.

Apologies
Donihue

PS: This case perhaps exemplifies the utility of a "version list" for the Add-ins .....


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests