# RE: st: RE: st: RE: cumulative sum with depreciation

 From Anna Gueorguieva To statalist@hsphsun2.harvard.edu Subject RE: st: RE: st: RE: cumulative sum with depreciation Date Tue, 6 Jun 2006 20:37:29 -0700 (PDT)

```Dear Nick and others,
However I am running into a problem of missing initial
values.
I am trying to calculate similarly capital stock
K=(1-delta)*K[_n-1]+ I
where the initial K  is K=Y

So, if I use your code, this is what I get:

+----------------------------------------------+
| code   year          Y          K          I |
|----------------------------------------------|
1. |  ALB   1990          .          .          . |
2. |  ALB   1991    7252145          .   5.277578 |
3. |  ALB   1992    7269795          .   3.772736 |
4. |  ALB   1993    7745880          .   10.85033 |
5. |  ALB   1994    8463700          .   14.01817 |
|----------------------------------------------|
6. |  ALB   1995    9114887          .   12.99762 |
7. |  ALB   1996   1.00e+07          .   10.65489 |
8. |  ALB   1997    9227298          .   11.00514 |
9. |  ALB   1998    9688186          .   11.68663 |
10. |  ALB   1999   1.10e+07          .   11.80726 |
|----------------------------------------------|
11. |  ALB   2000   1.14e+07          .   13.42595 |

and I am unable to make it "jump" to 1991 if 1990 is
missing. Overall, the sample is very unbalanced with
some countries missing up to four initial years.

Thank you in advance for your help!!!
Best,
Anna

From: "Nick Cox" <n.j.cox@durham.ac.uk>
To: <statalist@hsphsun2.harvard.edu>
Subject: st: RE: cumulative sum with depreciation
Date: Sun, 19 Mar 2006 19:10:20 -0000

bysort Firm (year) : gen S_t = 0
by firm : replace S_t = 0.85 * S_t[_n-1] + R_t if _n >
1

Nick
n.j.cox@durham.ac.uk

André Paul

> I would like to build a stock variable with
declining balance
> depreciation:
>
> S_t=0.85*S_t-1 + R_t
> (the initial value is always 0)
>
> The data (an unbalanced panel) looks like:
>
> Firm	year	R
> 2	1980	0
> 2	1981	1
> 2	1982	0
> 2	1983	7
> 2	1984	9
> 2	1985	4
> 2	1986	3
> 3	1994	0
> 3	1995	0
> 3	1996	0
> 3	1997	1
> 3	1998	0
> .
> .
> .
>
> But I couldn't find a way to build the variable "S",
can
> anybody help me?

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
*
*   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/
```