Information about equation/locals returned by procedure

Use this forum to post questions about syntax problems or general programming issues. Questions on implementing a particular aspect of econometrics should go in "Econometrics Issues" below.

Information about equation/locals returned by procedure

Postby jonasdovern » Mon Apr 20, 2009 10:38 am

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
jonasdovern
 
Posts: 68
Joined: Sat Apr 11, 2009 10:30 am

Re: Information about equation/locals returned by procedure

Postby TomDoan » Mon Apr 20, 2009 4:18 pm

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.
TomDoan
 
Posts: 2720
Joined: Wed Nov 01, 2006 5:36 pm


Return to Help With Programming

Who is online

Users browsing this forum: No registered users and 2 guests