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]

Aw: Re: st: I have daily returns and a panel: How to calculate annual returns?


From   "Peter Miller" <[email protected]>
To   [email protected]
Subject   Aw: Re: st: I have daily returns and a panel: How to calculate annual returns?
Date   Tue, 4 Feb 2014 20:58:32 +0100 (CET)

Wouldn't it be easier to do it somehow like this:
 
tsset Identifier Time, daily
xtset Identifier Time
tsfill (is this necessary?) - notice: there is no daily return data available on some days (e.g. weekends)
generate annual_return=(1+f1.Return)*(1+f2.Return)... (how could I possibly code this for 1, 2, 3 years?)
 
Thanks
 

Gesendet: Dienstag, 04. Februar 2014 um 15:26 Uhr
Von: "Peter Miller" <[email protected]>
An: [email protected]
Betreff: Aw: Re: st: I have daily returns and a panel: How to calculate annual returns?
Hi Austin,
 
thanks for your answer. I have some questions:
 
1) In the third line of your code, why do you divide by 100? Sounds stupid, but I think this has already been done in my dataset. I downloaded the returns from CRSP. Otherwise the annualpercent results seem really low. 
2) Annual percent is the return by each year (1,2,3) and raw return is the return for 3 years, correct?
3) This method doesn't use the "panel" function of Stata, does it? Might there be an easier way to calculate returns with a panel? I have to calculate lots of different returns.
 
Besides raw returns, I also need to calculate BHER (buy and hold excess returns), CAR (cumulative abnormal returns) and some more. Do you have any experience with that?
 
Thanks!
 
Gesendet: Montag, 03. Februar 2014 um 20:01 Uhr
Von: "Austin Nichols" <[email protected]>
An: "[email protected]" <[email protected]>
Betreff: Re: st: I have daily returns and a panel: How to calculate annual returns?
Peter Miller <[email protected]>:
Try something like

g tp=(Time-mod(Time,365))/365
bys Identifier tp (Time): g sum=sum(log(1+Return))
by Identifier tp: g annualpercent=(exp(sum)-1)/100 if _n==_N
bys Identifier (Time): g sumt=sum(log(1+Return))
by Identifier: g raw=(exp(sumt)-1)/100 if _n==_N


On Mon, Feb 3, 2014 at 5:33 AM, Peter Miller <[email protected]> wrote:
> Maybe I should add that I have also some other time variables such as
> Month Year ExactDate EventDate
>
> - Event Date is the date on which the returns start to be available. From that day onwards, the Time variable starts to count upwards until 1095 (in the best case scenario, namely if returns for 3 years are available)
>
> I dropped them in the first place, because I thought they are not necessary. But, maybe they are.
>
>
> Gesendet: Montag, 03. Februar 2014 um 11:05 Uhr
> Von: "Peter Miller" <[email protected]>
> An: [email protected]
> Betreff: st: I have daily returns and a panel: How to calculate annual returns?
> What I want to do?
> I want to calculate the raw return of all my firms in the sample.
> - for the first year
> - second year
> - third year
> - up to three years
>
> How does my data look like?
>
> Return Time Identifier
> 0 0 7.796e+08
> .007751938 2 7.796e+08
> .003846154 3 7.796e+08
> -.011494253 6 7.796e+08
> -.023255814 7 7.796e+08
> 0 8 7.796e+08
> .023809524 9 7.796e+08
> 0 10 7.796e+08
> ....
> . 1074 7.796e+08 << Day 1074: Three-year period ends here
> -.025806451 0 7.802e+08 << New firm
> -.006622517 2 7.802e+08
> .026666667 3 7.802e+08
> -.032467533 6 7.802e+08
> ....
>
>
> - The time variable are basically days. However, for some days (e.g. weekends), there are no daily returns available. That's why there are missing values.
> - In the best case scenario, all firms have returns for 3 years (1095 days). However, there are firms with less available return data (e.g. only 723 days).
>
> - The identifier "identifies" each firm uniquely in the dataset.
>
> What have I done so far?
> tsset Identifier Time
> xtset Identifier Time
>
> and I got:
>
> tsset Identifier Time
> panel variable: Identifier (unbalanced)
> time variable: Time, 0 to 1095, but with gaps
> delta: 1 unit
>
> xtset Identifier Time
> panel variable: Identifier (unbalanced)
> time variable: Time, 0 to 1095, but with gaps
> delta: 1 unit
>
> Does anyone know how to proceed further with the return calculation? Basically, the result should look like (Example):
>
> Period Sample Size Raw Return
> First year 502 10%
> Second year 470 9.8%
> Third year 432 11.3%
> Up to three years 502 35%
>
>
> Thank you.
> Peter
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/[http://www.stata.com/support/faqs/resources/statalist-faq/][http://www.stata.com/support/faqs/resources/statalist-faq/[http://www.stata.com/support/faqs/resources/statalist-faq/]]
* http://www.ats.ucla.edu/stat/stata/[http://www.ats.ucla.edu/stat/stata/][http://www.ats.ucla.edu/stat/stata/[http://www.ats.ucla.edu/stat/stata/]]

*
* For searches and help try:
* http://www.stata.com/help.cgi?search[http://www.stata.com/help.cgi?search]
* http://www.stata.com/support/faqs/resources/statalist-faq/[http://www.stata.com/support/faqs/resources/statalist-faq/]
* http://www.ats.ucla.edu/stat/stata/[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