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