[Gretl-users] passing a series name to a function

Ignacio Diaz-Emparanza ignacio.diaz-emparanza at ehu.es
Thu Jun 14 07:26:10 EDT 2007


Suppose I want a function that may be applied to one series (for 
example, "income") so that the function produces several output series
(for example "trend", "seasonal", etc). 
The function may be:

function decomp(series y, list comp)
# some calculus ...
series y_trend = ...
series y_seasonal= ...
list comp=y_trend y_seasonal 
return list comp
end function

at present, if you  run this type of function on a series, for example:

list components=decomp(income)

you get a new list "components" with elements "y_trend" and "y_seasonal".

The question is: 
Is there a way to pass the name of the variable to the function, so that the 
function can generate new series which change the names depending on what 
series are applied to? 

For example obtaining names "income_trend" ... when applied to "income" and 
names "consume_trend"... when applied to consume.










-- 
Ignacio Diaz-Emparanza  
DEPARTAMENTO DE ECONOMÍA APLICADA III (ECONOMETRÍA Y ESTADÍSTICA)                                        
UPV/EHU
Avda. Lehendakari Aguirre, 83 | 48015 BILBAO
T.: +34 946013732 | F.: +34 946013754
www.et.bs.ehu.es 



More information about the Gretl-users mailing list