Hi everyone,

I try to understand the difference between the codes mentioned in the header. On my dataset I tried following codes and got two different results


Code:
gen lcumreturn = L.cumreturn
&

Code:
gen lcumreturn_L1 = cumreturn[_n-1]
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float return double cumreturn float(lcumreturn_L1 lcumreturn)
1.0079681 1.0079680681228638         .         .
        1 1.0079680681228638 1.0079681 1.0079681
1.0039526 1.0119521853011548 1.0079681 1.0079681
  .984252   .996015938013521 1.0119522 1.0119522
    1.016  1.011952225317481   .996016   .996016
1.0177165 1.0298805042250194 1.0119523 1.0119523
1.0019342 1.0019341707229614 1.0298805 1.0298805
        . 1.0019341707229614 1.0019342 1.0019342
        .                  . 1.0019342         .
 .9560819  .9560818672180176         .         .
 1.048836 1.0027730744142218  .9560819  .9560819
1.0131539 1.0159634618241578  1.002773  1.002773
 .9927707 1.0086187891207565 1.0159634 1.0159634
 .9667113  .9750431634166093 1.0086188 1.0086188
1.0151422  .9898074643236853  .9750432  .9750432
 .9949268  .9949268102645874  .9898075  .9898075
 .9702436  .9653213434524304  .9949268  .9949268
1.0298847  .9941696783503577  .9653214  .9653214
1.0142422 1.0083288141464128  .9941697  .9941697
1.1347151 1.1441659112738582 1.0083288 1.0083288
1.0047648  1.149617627634143 1.1441659 1.1441659
 .9118093 1.0482320047894862 1.1496177 1.1496177
 .9703121 1.0171121547990258  1.048232  1.048232
1.0166008 1.0339970783111274 1.0171121 1.0171121
1.0062244 1.0404330833607063  1.033997  1.033997
1.0306382 1.0723100989061582  1.040433  1.040433
end
Thanks