Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Stock variable problem

    Dear Statalist, I am trying to address the perpetual method in order to build a stock variable. Basically, first it generates a initial stock (first year), and then it sum up on the following values accounting for a depreciation rate. However, the problem is when the average growth rate is negative (and higher than the depreciation rate which I set to be 0.05) ending in a negative stock variable. It is advised to use geometric mean instead of arithmetic one. However, I am not sure if I am calculating right the growth rate as it is, or if I should I multiply it by 100 (in the first line of the first loop). When multiplying by 100, the stock is positive, but the geometric average is higher than the arithmetic one (which should not be).

    Have anybody any advice?

    Code:
    foreach x in new_sumx1   {  
            bys sic (year): gen g_`x' = (( `x' - L.`x')/L.`x')
            egen ameang_`x' = mean( g_`x' ), by(sic)
            egen gmeang_`x' = mean(log(1 + g_`x')), by(sic) 
            replace gmeang_`x' = exp(gmeang_`x') - 1    
            gen stock_`x'g = ( `x' /(0.05 + gmeang_`x' )) if year==2004
            gen stock_`x'a = ( `x' /(0.05 + ameang_`x' )) if year==2004
            }
    
    sort sic year
    brow sic year new_sumx1 g_new_sumx1 gmeang_new_sumx1 stock_new_sumx1g ameang_new_sumx1 stock_new_sumx1a
    
    foreach x in new_sumx1  {  
               forvalues i = 2005/2016 {
               bys sic: replace stock_`x'a = (1-0.05)*L.stock_`x'a + `x' if year==`i'
               bys sic: replace stock_`x'g = (1-0.05)*L.stock_`x'g + `x' if year==`i'
               }
               }
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input byte sic int year float new_sumx1
     5 2004   2001276
     5 2005  43234.54
     5 2006 76543.516
     5 2007 144225.97
     5 2008  374271.3
     5 2009  518562.8
     5 2010  657756.1
     5 2011 28355.887
     5 2012 113218.86
     5 2013  3358.796
     5 2014         .
     5 2015         .
     5 2016 1659679.3
    10 2004  27806592
    10 2005  20727666
    10 2006  23789176
    10 2007  18034548
    10 2008  25033572
    10 2009  28634690
    10 2010  28286054
    10 2011  19459068
    10 2012  17952214
    10 2013  18554806
    10 2014   9926886
    10 2015  11262449
    10 2016  10461789
    end
Working...
X