Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Cumulative Return Calculation for Recurring Periods


From   Edward Crawley <[email protected]>
To   [email protected]
Subject   Re: st: Cumulative Return Calculation for Recurring Periods
Date   Wed, 19 Jun 2013 21:28:59 +0100

Exactly what I wanted, thank you!!

On Wed, Jun 19, 2013 at 8:03 PM, Richard Herron
<[email protected]> wrote:
> This generates rolling three-month returns.
>
> ***
> clear
> set obs 30
> generate i = int((_n - 1) / 10) + 1
> generate t = mod((_n - 1), 10) + 1
> generate r = 0.0 + (0.00 + 0.10) * runiform()
> xtset i t
>
> generate sumlogr = sum(ln(1 + r))
> generate r3 = exp(s3.sumlogr) - 1
> ***
>
> If you use -xtset- then you can use -s.-, which is seasonal
> difference, here three months. This approach "throws away" the first
> month's return, but codes/computes quickly.
>
> On Wed, Jun 19, 2013 at 2:27 PM, Edward Crawley <[email protected]> wrote:
>> Dear listers,
>>
>> I am trying to calculate cumulative returns for recurring periods in
>> my panel dataset;
>>
>> date company return
>> 2001m1 1  .
>> 2001m2 1 .14425
>> 2001m3 1 -.215709
>> 2001m4 1 -.160343
>> 2001m5 1 .390866
>> 2001m6 1 -.014815
>> 2001m1 2  .
>> 2001m2 2 .315081
>> 2001m3 2 -.392042
>> 2001m4 2 -.127833
>> 2001m5 2 .646627
>> 2001m6 2 .133531
>> 2001m1 3  .
>> 2001m2 3 .184734
>> 2001m3 3 -.036814
>> 2001m4 3 -.29605
>> 2001m5 3 .457318
>> 2001m6 3 -.060292
>> .
>> .
>> .
>> .
>>
>> For instance, for each firm, I need to calculate cumulative returns
>> for recurring 3 periods ( e.g. from 2001m1 to 2001m4 and from 2001m2
>> to 2001m5 and ... etc.).
>>
>> I used the following code, but it didn't give the desired result;
>>
>> bys company (date): g c=sum(ln(return+1))
>> replace c=exp(c)-1
>> rename c cumreturn
>>
>> I appreciate any help,
>>
>> Best regards,
>>
>> Edward
>> *
>> *   For searches and help try:
>> *   http://www.stata.com/help.cgi?search
>> *   http://www.stata.com/support/faqs/resources/statalist-faq/
>> *   http://www.ats.ucla.edu/stat/stata/
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index