Page 1 of 1

Information about equation/locals returned by procedure

Posted: Mon Apr 20, 2009 10:38 am
by jonasdovern
Hallo,

if I have an equation estimated in a procedure based on time series that is local to this procedure, what information is available after returning the equation definition from the procedure? It seems as if I can access the equation and e.g. use it for forecasting although the underlying time series are of course no longer known to my program (see example below). Can anybody clearify what's going on in this example? (I just want to be sure the program does what I think it does.)

Code: Select all

 set x 1 100 = %ran(2)
set z 1 100 = %ran(2)
set e 1 100 = %ran(2)
set y = 0.5 + 3*z + 5*x + e

procedure estimation aser bser eqn
type series aser bser
type equation eqn
*
local series zser
local integer ta te
*
inquire(regressorlist) ta te
# aser bser
*
set zser ta te = exp(aser)
linreg(define=eqn) bser ta te
# constant zser
*
end procedure

decl equation eqn
@estimation x y eqn
forecast(static,from=50,steps=5,print) 1
# eqn
print / zser

Re: Information about equation/locals returned by procedure

Posted: Mon Apr 20, 2009 4:18 pm
by TomDoan
The local series are still around - you just can't use them by name outside the procedure. When a procedure is called for the first time, any local series are "registered" at that point. If you have 10 series defined previously, the new local series will be registered as number 11.

Obviously, if you really want predictable access to a series which is being created by a procedure, define it as a parameter or option with a * in front of the name; for instance,

Code: Select all

procedure myprocedure 
option series *newseries
if %defined(newseries)
   set newseries = ....
end if
...
If you then use

Code: Select all

@myprocedure(newseries=mynewseries)
it will create mynewseries.