# Re: st: How to generate a cumulative sum

 From "Austin Nichols" To statalist@hsphsun2.harvard.edu Subject Re: st: How to generate a cumulative sum Date Thu, 25 Oct 2007 14:05:03 -0400

```Damiano Rossi <west--@libero.it>:
Not sure which previous post you refer to, and "doesn't help" doesn't
help clarify the confusion, but you can certainly get what you need
from -by- and log operators (see -help tsvarlist-) e.g.

webuse grunfeld, clear
g k0=int(uniform()*1000) if year==1935
g k=.
bys c (y): replace k=cond(l.k<.,l.k*(1-`d'),k0)+i
li com year k0 k inv in 1/10, noo sepby(com)

On 10/25/07, west--@libero.it <west--@libero.it> wrote:
> Dear all,
>
> I need some help to compute a capital stock series from a gross investment series. My primary problem is that I have to estimate the initial capital stock (K_0 ) for each firm. As a general rule, it is used the book value of fixed capital (K) in the first year of data (e.g. 1996) for each firm. How can I command Stata to consider this first observation (firm by firm) and then compute a capital stock series, using a perpetual inventory and a constant rate of depreciation? A previous post doesn't help me much on this point. These are the data.
>
> Panl oif 300 firms, 10 years (1996-2006)
> k = capital stock
> I = capital investment
> d [delta] = 0.05
>
> The evolution of the real capital stock is:
> K_t+i = (1 - d)*K_t+i-1 + I_t+i
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```