Hi, You may try: (within the last loop)
... # ------- declare an empty list list olist = null loop foreach i Y --quiet series $i_p = 0 series $i_m = 0 series $i_p = $i_p(-1) + pd_d_$i #Partial sum process of positive changes series $i_m = $i_m(-1) + nd_d_$i #Partial sum process of negative changes # ---------- add $i_p $i_m to olist olist += $i_p $i_m endloop # ------- return return olist end function Yi-Nung Yang 2010/5/12 Artur T. <artur.tarassow(a)googlemail.com> > Hi gretl community, > > I programmed a function which gives an output of transformed variables > defined in a list. Actually I would like to add this output as newly > generated series to the current variables. > > The function is given by: > -------------------------------------------------------------------------- > function list Regime_Series (list Y "List of variables") > > smpl --full > > loop foreach i Y --quiet > series pd_d_$i = 0 #Generate series for positive changes > series nd_d_$i = 0 #Generate series for negative changes > endloop > > list dY = diff(Y) #1st difference of Y > > #attribute the first differences to the series > loop foreach i dY --quiet > smpl $i > 0 --restrict #Restrict positive changes > pd_$i = $i #Generate series of positive changes > smpl --full > smpl $i < 0 --restrict #Restrict negative changes > nd_$i = $i #Generate series of negative changes > smpl --full > endloop > > # create partial sum process > loop foreach i Y --quiet > series $i_p = 0 > series $i_m = 0 > series $i_p = $i_p(-1) + pd_d_$i #Partial sum process of positive > changes > series $i_m = $i_m(-1) + nd_d_$i #Partial sum process of negative > changes > endloop > > end function > ---------------------------------- > > I would like to add the series $i_p and $i_m to the current variables > but I cannot find out how to use the "return" command correctly in this > context. Does anybody have a suggestion? > > Thanks in advance! > > Artur > > _______________________________________________ > Gretl-users mailing list > Gretl-users(a)lists.wfu.edu > http://lists.wfu.edu/mailman/listinfo/gretl-users >Hi,
You may try:
(within the last loop)
...
# ------- declare an empty list
list olist = null
loop foreach i Y --quiet
series $i_p = 0
series $i_m = 0
series $i_p = $i_p(-1) + pd_d_$i #Partial sum process of positive changes
series $i_m = $i_m(-1) + nd_d_$i #Partial sum process of negative changes
# ---------- add $i_p $i_m to olist
olist += $i_p $i_m
endloop
# ------- return
return olist
end function
Yi-Nung Yang
2010/5/12 Artur T. <artur.taras...@googlemail.com>
Hi gretl community,
I programmed a function which gives an output of transformed variables
defined in a list. Actually I would like to add this output as newly
generated series to the current variables.
The function is given by:
--------------------------------------------------------------------------
function list Regime_Series (list Y "List of variables")
smpl --full
loop foreach i Y --quiet
series pd_d_$i = 0 #Generate series for positive changes
series nd_d_$i = 0 #Generate series for negative changes
endloop
list dY = diff(Y) #1st difference of Y
#attribute the first differences to the series
loop foreach i dY --quiet
smpl $i > 0 --restrict #Restrict positive changes
pd_$i = $i #Generate series of positive changes
smpl --full
smpl $i < 0 --restrict #Restrict negative changes
nd_$i = $i #Generate series of negative changes
smpl --full
endloop
# create partial sum process
loop foreach i Y --quiet
series $i_p = 0
series $i_m = 0
series $i_p = $i_p(-1) + pd_d_$i #Partial sum process of positive
changes
series $i_m = $i_m(-1) + nd_d_$i #Partial sum process of negative
changes
endloop
end function
----------------------------------
I would like to add the series $i_p and $i_m to the current variables
but I cannot find out how to use the "return" command correctly in this
context. Does anybody have a suggestion?
Thanks in advance!
Artur
_______________________________________________
Gretl-users mailing list
gretl-us...@lists.wfu.edu
http://lists.wfu.edu/mailman/listinfo/gretl-users