# Re: st: Cumulative return for each firm each day

 From Austin Nichols To statalist@hsphsun2.harvard.edu Subject Re: st: Cumulative return for each firm each day Date Thu, 12 Mar 2009 15:52:02 -0400

```Hua Pan <panhua@gmx.de> :
If returns are missing, why should they be treated as zero?  If share
price data is not available for one day, does that imply that the
returns that day are zero?  In general, no...  I think at a minimum
you should replace those data with missing values, but in the
following example they should all be missing after the first missing
return:

webuse grunfeld, clear
g ret=invest/15000 if !inrange(invest,450,500)
bys company (year): g cumul=1+ret if _n==1
replace cumul=(1+ret)*l.cumul if mi(cumul)
replace cumul=cumul-1
bys company (year): g c=exp(sum(ln(ret+1)))-1
replace c=. if mi(ret)
g r=invest/15000
bys company (year): g c2=exp(sum(ln(r+1)))-1
li year ret cumul c c2 if company==1, noo clean

Note also that the return over a two-day period is no longer a daily
return--how are you calculating the daily returns?  The lag operator
is safer, in that it will return missings if a day is missing from the
sequence...  and then you have to decide how to fill those missing
values in if there is a sensible way to do so.

On Thu, Mar 12, 2009 at 3:34 PM, Hua Pan <panhua@gmx.de> wrote:
> Dear Martin, Austin, Antoine and Nick
>
> Thank you sooooo much for your great help and wonderful answers. Although it’s very easy for you, but for me as a beginner, I’ve already spent a lot of time on the issue with reading books, search for special ado files, FAQ, Statalist archives… and can’t find the answer. So I come here to ask for help and all of you are so kind and give me the answer, thank you!
>
> Austin:  thanks a lot for your help. Two methods work very well when all of the returns are available.  But I find out when one ret is missing, all of the returns behind it will be missing, even their ret are not, with the first method (because of l.cumul). With the second one all missing values of ret are treated as 0 and all of the Cret have a value, so I think the second one, that’s exactly the one of Antoine, is better. Many thanks, Antoine!
>

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```