Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: Re: st: RE: st: RE: cumulative sum with depreciation


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: Re: st: RE: st: RE: cumulative sum with depreciation
Date   Wed, 7 Jun 2006 17:07:48 +0100

There is no need to put constants into
variables. In this case, local macros 
would serve as well. Also, you save 
on storage. 

* PARAMETERS
local ky0 1
local delta .06 
 
* REAL GDP
gen Y = rgdpl * pop

* INVESTMENT
ren ki I
 
* CAPITAL
g miss = mi(Y) 
bysort code miss (year): gen K = Y[1] * `ky0'
by code: replace K = (1 - `delta') * K[_n - 1] + I if _n > 1 

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

Anna Gueorguieva
 
> Dear Austin,
> Thank you so much!  I used the first method of
> identifying missing and sorting them out to the end. 
> 
> For the purpose of aiding future searches, I am doing
> a total factor productivity (TFP) growth excercise and
> calculating the capital stock using the perpetual
> inventory method. 
> 
> Here's my code:
> *PARAMETERS
> gen ky0=1		/* range 1 to 2*/
> gen delta=.06 /*range .04 to .08*/
> 
> 
> *REAL GDP
> gen Y=rgdpl*pop
> 
> *INVESTMENT
> ren ki I
> 
> *CAPITAL
> g miss=mi(Y) 
> bysort code miss (year): gen K = Y[1] *ky0
> by code: replace K=(1-delta)*K[_n-1]+I if _n>1 
> 
> The result is:
>      +----------------------------------------------+
>      | code   year          K          Y          I |
>      |----------------------------------------------|
>   1. |  ALB   1990          .          .          . |
>   2. |  ALB   1991    7252145    7252145   5.277578 |
>   3. |  ALB   1992    6817020    7269795   3.772736 |
>   4. |  ALB   1993    6408010    7745880   10.85033 |
>   5. |  ALB   1994    6023543    8463700   14.01817 |
>      |----------------------------------------------|
>   6. |  ALB   1995    5662144    9114887   12.99762 |
>   7. |  ALB   1996    5322426   1.00e+07   10.65489 |
>   8. |  ALB   1997    5003091    9227298   11.00514 |
>   9. |  ALB   1998    4702917    9688186   11.68663 |
>  10. |  ALB   1999    4420754   1.10e+07   11.80726 |
>      |----------------------------------------------|
>  11. |  ALB   2000    4155522   1.14e+07   13.42595 |
> 
> 

*
*   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/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index