Hi everyone,
I want to calculate the cumulative return, which t0=1/30/2020 is the first day, as follows:
I would really appreciate all the help I can get.
Best regards
P/s: I attache the small sample for example.
I want to calculate the cumulative return, which t0=1/30/2020 is the first day, as follows:
cum_re (at t=0) = return (at t=0)However, I don't know how to code it in Stata.
cum_re (at t=1) = [(1 + return (at t=0)) * (1 + return (at t=1))]^(1/2) - 1
cum_re (at t=2) = [(1 + return (at t=0)) * (1 + return (at t=1)) * (1 + return (at t=2))]^(1/3) - 1
...
cum_re (at t=10)
I would really appreciate all the help I can get.
Best regards
P/s: I attache the small sample for example.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input int company_id float(date return t cum_re) 1 21937 .004804236 -5 . 1 21938 -.0028854576 -4 . 1 21941 -.029846454 -3 . 1 21942 .027896367 -2 . 1 21943 .02071675 -1 . 1 21944 -.0014503612 0 . 1 21945 -.04535168 1 . 1 21948 -.002750865 2 . 1 21949 .032480955 3 . 1 21950 .008121479 4 . 1 21951 .011628815 5 . 1 21952 -.013652723 6 . 1 21955 .004738188 7 . 1 21956 -.0060511 8 . 1 21957 .02346898 9 . 1 21958 -.007145829 10 . 2 21937 .006136745 -5 . 2 21938 -.010127876 -4 . 2 21941 -.016864497 -3 . 2 21942 .01940629 -2 . 2 21943 .015472523 -1 . 2 21944 .02781715 0 . 2 21945 -.014868793 1 . 2 21948 .02408653 2 . 2 21949 .032386478 3 . 2 21950 -.0012224098 4 . 2 21951 .02052206 5 . 2 21952 .0014147813 6 . 2 21955 .025820585 7 . 2 21956 -.02283419 8 . 2 21957 .0014628787 9 . 2 21958 -.005428527 10 . 3 21937 -.0015270904 -5 . 3 21938 -.012246813 -4 . 3 21941 -.018049529 -3 . 3 21942 .01353241 -2 . 3 21943 .002559859 -1 . 3 21944 .006800847 0 . 3 21945 .07119624 1 . 3 21948 -.0022526423 2 . 3 21949 .02243314 3 . 3 21950 -.004792484 4 . 3 21951 .005066657 5 . 3 21952 .014068715 6 . 3 21955 .025935084 7 . 3 21956 .00788418 8 . 3 21957 .004267564 9 . 3 21958 -.004700152 10 . end format %tdnn/dd/CCYY date
Comment