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: I have daily returns and a panel: How to calculate annual returns?


From   Austin Nichols <austinnichols@gmail.com>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   Re: st: I have daily returns and a panel: How to calculate annual returns?
Date   Mon, 3 Feb 2014 14:01:02 -0500

Peter Miller <peter_miller@gmx.ch>:
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 <peter_miller@gmx.ch> 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" <peter_miller@gmx.ch>
> An: statalist@hsphsun2.harvard.edu
> 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.ats.ucla.edu/stat/stata/


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