Dear all,

 

I’ve run across something strange when using diff() in a loop. Given a series with missing values, Gretl seems to be “recycling” values from the previous loop iteration. The following script illustrates the problem: on the second loop iteration, the series “r” should be missing for the first half of the sample but instead the values from the first loop iteration are printed. Doing the same thing “by hand” after the loop produces what I’d expect. Is this intended?

 

<hansl>

nulldata 104

setobs 52 2006-01-03

 

series y1 = uniform()

series y2 = uniform()*(obs>obsnum(2006-07-04))

y2 = zeromiss(y2) # y2 is missing for first half

 

list ylist = y1 y2

loop foreach i ylist --quiet

    r = 100*diff(log(ylist[i]))

    print ylist[i] r --byobs

endloop

 

r1 = 100*diff(log(y1))

r2 = 100*diff(log(y2))

 

print r1 r2 --byobs

</hansl>

 

TIA,

PS

 

cid:logoimg