Announcement

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

  • Create loop to store slope and standard error

    Dear Statalisters,

    Your help with the following problem would be highly appreciated! Using Stata version 14.1, I am trying to compute an industry munificence and an industry dynamism variable as described by Misangyi et al. 2006 (pages 581-582, see below for details and link):

    "[Industry munificence] was calculated for each year by first regressing the annual average sales in each industry over the 5 years which contained the focal year as a midpoint (i.e., industry munificence for 1995 is based on the regression of sales for the years 1993–97). The regression slope coefficient obtained from this regression was then divided by the mean value of the sales for those years (to adjust for absolute industry size)...

    [Industry Dynamism] was measured as the dispersion about the regression line estimated in the regressions used in arriving at the munificence variable just described, by dividing the standard error of the regression slope coefficient by the mean value of sales"

    My panel data has the following (rough) structure:
    Industry firm year sales
    5010 1 2000 23000
    5010 1 2001 24000
    5010 1 2003 30000
    5230 8 2001 500000
    5230 9 2002 500
    5230 9 2004 600
    5800 10 2001 80000
    5800 10 2002 81000
    5800 10 2003 80000
    Overall, there are about 50 different industries, 4.000 firms, and 14 years for which I have data.

    I have no idea about how to set this up in an elegant way without computing everything manually per industry and year. Browsing previous posts did not help.

    In case anyone could give advice, please, I would be more than thankful!
    Best wishes,
    Julia

    Misangyi, V. F., H. Elms, T. Greckhamer and J. A. Lepine. 2006. A new perspective on a fundamental debate: a multilevel approach to industry, corporate, and business unit effects. Strategic Management Journal 27 (6): 571-590.
    http://onlinelibrary.wiley.com/doi/1...lobalMessage=0


  • #2
    This question would be a lot easier to answer if you attach a datasample using -dataex- (see this forum's FAQ).

    Comment


    • #3
      Hello Jesse,
      Thank you very much for pointing this out!


      Code:
      * Example generated by -dataex-. To install: ssc install dataex
      clear
      input int(id ind year) float sales
      1 5010 1997  29130720
      1 5010 1998  24332996
      1 5010 1999  42178000
      1 5010 2000 114557000
      1 5010 2001 105318000
      1 5010 2002 102540000
      1 5010 2003 104652000
      1 5010 2004 1.227e+08
      1 5010 2005 122618000
      1 5010 2006 132689000
      1 5010 2007 136824000
      1 5010 2008 160331008
      1 5010 2009 112153000
      1 5010 2010 140476000
      1 5010 2011 166550000
      1 5010 2012 182299008
      1 5010 2013 171711008
      1 5010 2014 160546240
      2 5010 1999  34079996
      2 5010 2000  59639420
      2 5010 2001  75257624
      2 5010 2002  74355520
      2 5010 2003  97949096
      2 5010 2004 105154032
      2 5010 2005  94149304
      2 5010 2006  97584496
      2 5010 2007  96892784
      2 5010 2008 155666896
      2 5010 2009 136646768
      2 5010 2010 165201744
      2 5010 2011 202478400
      2 5010 2012 191206496
      2 5010 2013 205441344
      2 5010 2014 173170768
      3 5010 1999  65451928
      end
      id = firm identifier
      ind = industry identifier (5010 is energy - fossil fuel) it is accidental that firms 1-3 all belong to the same industry
      year = year
      sales = sales in EUR

      Does this help or would you need further data?
      THANK YOU VERY MUCH!
      Julia

      Comment


      • #4
        Hi Julia,
        I am dealing with a similar question, but have a few missing years throughout the panel (similar to the data presented in the original question). In terms of further data, the munificence variable referenced above is based on "annual average sales in each industry" which means that the second dataset is incomplete for calculating munificence and dynamism. Your data includes unique firms across years, whereas the variables you are trying to calculate are industry level measures. To get these variables, you would need to calculate average sales in each industry by year and use that as your predictor. In other words, xtset the industry and year (after calculating mean sales) rather than xtset firm and year before generating the regression model.
        Hopefully that helps, and I would also appreciate any insight related to generating these variables!

        Comment


        • #5
          There are probably more efficient ways to do this with rolling or statsby but I'm not very familiar with them.

          If you want to do program it directly, you'll probably have to set up a loop over industries and second loop for years. The manual way would look like (not debugged)

          g b=.
          local i=1
          foreach industrym in 5011 5012 {
          forvalues yearm =2000/2011 {
          local startyr=`yearm' - 3
          local endyr=`yearm' + 3
          regress y x if year>`startyr' & year<`endyr' & industry==`industrym'
          local bm=b[x]
          replace b=`bm' if industry==`industrym' & year=`yearm'
          local i=`i' + 1
          }

          You can easily make this do the mean and dispersion as well.

          Comment


          • #6
            Thank you very much, Phil! This works well!

            Comment


            • #7
              Hi,

              I had a similar problem, and I adapted Phil's code to compute industry munificence and dynamism using COMPUSTAT data.

              I am just using industry sales to compute those indicators. This is a simplification of the procedure described by Steinbach et al. (2017)*.

              I would like to post it here for future reference.


              * See description in footnote 5 in Steinbach, A. L., Holcomb, T. R., Holmes, R. M., Devers, C. E., & Cannella, A. A. (2017). Top management team incentive heterogeneity, strategic investment behavior, and performance: A contingency theory of incentive alignment. Strategic Management Journal, 38(8), 1701-1720. doi:10.1002/smj.2628

              Code:
              qui g double indmun=.
              qui g double inddyn=.
              qui bys sic2 year : egen double indsales=sum(revt)
              qui bys sic2 year : g int indcount=_n
              local if=`"if sic2=="\`industry'" & (year>\`startyr' & year<=\`curyear')"'
              forvalues industry=20/39 {
                  forvalues curyear=1991/2015 {
                      local startyr=`curyear'-5
                      qui summarize revt `if'
                      local indmean = r(mean)
                      qui regress indsales year `if' & indcount==1, vce(r)
                      local munif = _b[year]  / `indmean'
                      local dynam = _se[year] / `indmean'
                      qui replace indmun = `munif' if sic2=="`industry'" & year==`curyear'
                      qui replace inddyn = `dynam' if sic2=="`industry'" & year==`curyear'
                      //di as text "Industry: `industry' year: `curyear' industry mean: " as result %8.3f `indmean' as text ", munificence: " as result %8.3f `munif' as text ", dynamism: " as result %8.3f `dynam' as text ", regression coefs: " _b[year] "(" _se[year] "), " _b[_cons] "(" _se[_cons] ")"
                  }
              }

              Comment


              • #8
                Hi everyone!
                Please I need some help. I am working out munificence and dynamism too. I have adapted Phil and Luri code but some is wrong and I don't know what is it.

                Code:
                qui g MUNIFICENCE=.
                qui g DYNAMISM=.
                local i=1
                forvalues YEAR= 2006/2013 {
                local startyr=`YEAR' - 5
                local currentyr=`YEAR' - 1
                        qui regress L_net_income YEAR if YEAR>=`startyr' & YEAR<=`currentyr', vce(r)
                        local munif = _b[YEAR]
                        local dynam = _se[YEAR]
                        qui replace MUNIFICENCE = `munif'
                        qui replace DYNAMISM = `dynam'
                local i=`i' + 1
                  }
                But the results are:
                Code:
                NACE    YEAR    net_income    L_net_income    MUNIFICENCE    DYNAMISM
                45    1999    6.2e+07    17.9364    .4009539    .2175512
                45    2000    3.3e+07    17.32523    .4009539    .2175512
                45    2001    3.3e+07    17.32353    .4009539    .2175512
                45    2002    2.2e+07    16.92291    .4009539    .2175512
                45    2003    9.6e+06    16.08106    .4009539    .2175512
                45    2004    1.4e+07    16.42315    .4009539    .2175512
                45    2005    1.4e+07    16.48203    .4009539    .2175512
                45    2006    1.8e+07    16.70908    .4009539    .2175512
                45    2007    1.8e+07    16.71652    .4009539    .2175512
                45    2008    3.2e+06    14.96441    .4009539    .2175512
                45    2009    1.4e+07    16.46383    .4009539    .2175512
                45    2010    2.0e+07    16.82248    .4009539    .2175512
                45    2011    2.5e+07    17.01523    .4009539    .2175512
                45    2012    1.8e+07    16.69347    .4009539    .2175512
                45    2013    1.6e+07    16.57915    .4009539    .2175512
                45    2014    6.2e+07    17.93638    .4009539    .2175512
                45    2015    1.5e+07    16.53377    .4009539    .2175512
                45    2016    1.4e+07    16.44087    .4009539    .2175512
                45    2017    1.5e+07    16.51601    .4009539    .2175512
                The same munificence and dynamism for each year. I would like to get for 2006 year the B and the SE from 2001 to 2005; for 2007 year the B and the SE from 2002 to 2006 and so on...
                Thanks for help!
                Best
                Rocio

                Comment


                • #9
                  I think you forgot to copy the if condition in the replace statements.

                  Comment


                  • #10
                    Jesse, thank you very much!!!!!! 4 eyes see more than 2!!!!

                    Code:
                    qui g MUNIFICENCE=.
                    qui g DYNAMISM=.
                    local i=1
                    forvalues YEAR= 2006/2013 {
                    local startyr=`YEAR' - 5
                    local currentyr=`YEAR' - 1
                            qui regress L_net_income YEAR if YEAR>=`startyr' & YEAR<=`currentyr', vce(r)
                            local munif = _b[YEAR]
                            local dynam = _se[YEAR]
                            qui replace MUNIFICENCE = `munif' if YEAR==`currentyr'
                            qui replace DYNAMISM = `dynam' if YEAR==`currentyr'
                    local i=`i' + 1
                      }
                    And...
                    Code:
                    NACE    YEAR    net_income    L_net_income    MUNIFICENCE    DYNAMISM
                    45    1999    6.2e+07    17.9364        
                    45    2000    3.3e+07    17.32523        
                    45    2001    3.3e+07    17.32353        
                    45    2002    2.2e+07    16.92291        
                    45    2003    9.6e+06    16.08106        
                    45    2004    1.4e+07    16.42315        
                    45    2005    1.4e+07    16.48203    -.2182772    .0940471
                    45    2006    1.8e+07    16.70908    -.0026697    .1268902
                    45    2007    1.8e+07    16.71652    .1556854    .0342921
                    45    2008    3.2e+06    14.96441    -.2682989    .2374249
                    45    2009    1.4e+07    16.46383    -.1781074    .2096438
                    45    2010    2.0e+07    16.82248    -.0025885    .167032
                    45    2011    2.5e+07    17.01523    .2455504    .2625925
                    45    2012    1.8e+07    16.69347    .4009539    .2175512
                    45    2013    1.6e+07    16.57915        
                    45    2014    6.2e+07    17.93638        
                    45    2015    1.5e+07    16.53377        
                    45    2016    1.4e+07    16.44087        
                    45    2017    1.5e+07    16.51601
                    Thanks again!!!!

                    Comment


                    • #11
                      Note that you can use rangerun (from SSC) to do this. I assume that NACE stores an industry code and that you want to perform these rolling regressions by industry. The following code replicates the results for the target years from #10:

                      Code:
                      * Example generated by -dataex-. To install: ssc install dataex
                      clear
                      input byte nace int YEAR long net_income float L_net_income
                      45 1999 62000000  17.9364
                      45 2000 33000000 17.32523
                      45 2001 33000000 17.32353
                      45 2002 22000000 16.92291
                      45 2003  9600000 16.08106
                      45 2004 14000000 16.42315
                      45 2005 14000000 16.48203
                      45 2006 18000000 16.70908
                      45 2007 18000000 16.71652
                      45 2008  3200000 14.96441
                      45 2009 14000000 16.46383
                      45 2010 20000000 16.82248
                      45 2011 25000000 17.01523
                      45 2012 18000000 16.69347
                      45 2013 16000000 16.57915
                      45 2014 62000000 17.93638
                      45 2015 15000000 16.53377
                      45 2016 14000000 16.44087
                      45 2017 15000000 16.51601
                      end
                      
                      program drop _all
                      program doit
                          regress L_net_income YEAR, vce(r)
                          gen obs = e(N)
                          gen munificence = _b[YEAR]
                          gen dynamism = _se[YEAR]
                      end
                      rangerun doit, interval(YEAR -4 0) by(nace)
                      
                      gen target_years = inrange(YEAR, 2005, 2012)
                      list, sepby(target_years)
                      and the results:
                      Code:
                      . list, sepby(target_years)
                      
                           +---------------------------------------------------------------------------+
                           | nace   YEAR   net_in~e   L_net_~e   obs   munific~e   dynamism   target~s |
                           |---------------------------------------------------------------------------|
                        1. |   45   1999   62000000    17.9364     .           .          .          0 |
                        2. |   45   2000   33000000   17.32523     2   -.6111698          0          0 |
                        3. |   45   2001   33000000   17.32353     3   -.3064346   .1244076          0 |
                        4. |   45   2002   22000000   16.92291     4   -.3042166    .054209          0 |
                        5. |   45   2003    9600000   16.08106     5   -.4112997   .0673213          0 |
                        6. |   45   2004   14000000   16.42315     5   -.3046631   .0870072          0 |
                           |---------------------------------------------------------------------------|
                        7. |   45   2005   14000000   16.48203     5    -.218276   .0940468          1 |
                        8. |   45   2006   18000000   16.70908     5   -.0026691   .1268894          1 |
                        9. |   45   2007   18000000   16.71652     5     .155685   .0342919          1 |
                       10. |   45   2008    3200000   14.96441     5   -.2682989   .2374249          1 |
                       11. |   45   2009   14000000   16.46383     5    -.178107    .209644          1 |
                       12. |   45   2010   20000000   16.82248     5    -.002589   .1670315          1 |
                       13. |   45   2011   25000000   17.01523     5    .2455489   .2625922          1 |
                       14. |   45   2012   18000000   16.69347     5     .400952   .2175514          1 |
                           |---------------------------------------------------------------------------|
                       15. |   45   2013   16000000   16.57915     5    .0101627   .0736062          0 |
                       16. |   45   2014   62000000   17.93638     5    .1791721   .1740139          0 |
                       17. |   45   2015   15000000   16.53377     5    .0279989   .1790571          0 |
                       18. |   45   2016   14000000   16.44087     5   -.0550579   .1112492          0 |
                       19. |   45   2017   15000000   16.51601     5   -.1621788   .1908957          0 |
                           +---------------------------------------------------------------------------+
                      
                      .

                      Comment


                      • #12
                        Thank you Robert!!! Your code is very useful!!!
                        Thanks again,
                        Rocio

                        Comment


                        • #13
                          Hello All,
                          I hope you all are doing fine. I am facing a similar problem where I have to create Industry Munificence Index as: (1) regressing sales against time of an industry over the previous 5 years of the period under analysis and (2) taking the ratio of the regression slope coefficient to the mean value of sales over the same period. I have the following dataset:
                          Code:
                          * Example generated by -dataex-. To install: ssc install dataex
                          clear
                          input long Prowesscompanycode int Year byte Industry double Sales
                           400 2004 21    25.5
                           400 2005 21    67.8
                           400 2006 21   109.5
                           400 2007 21   140.1
                           400 2008 21   200.5
                           400 2009 21    96.6
                           400 2010 21      25
                          1120 2006 24  3045.9
                          1120 2009 24    9805
                          1120 2010 24  8458.4
                          1120 2011 24 10243.4
                          1120 2012 24   13185
                          1120 2013 24 16448.8
                          1120 2014 24 18446.3
                          1120 2015 24 21504.4
                          1120 2016 24 18856.2
                          1120 2017 24   21224
                          1144 2016 23  2144.2
                          1144 2017 23  1861.5
                          2015 2001 29    95.8
                          2015 2002 29    80.3
                          2015 2003 29   103.3
                          2015 2004 29   104.8
                          2015 2005 29   196.2
                          2015 2006 29   568.1
                          2015 2007 29  1134.6
                          2015 2008 29  1431.1
                          2015 2009 29  1154.4
                          2015 2010 29  1064.4
                          2015 2011 29  1553.7
                          2015 2012 29  1775.1
                          2015 2013 29  1440.5
                          2773 2005 24   783.1
                          2773 2006 24   920.7
                          2773 2007 24  1014.4
                          2773 2008 24  1012.1
                          2773 2009 24    1056
                          2773 2010 24  1140.7
                          2773 2011 24  1377.8
                          2773 2012 24  1457.7
                          2773 2013 24  1602.6
                          2773 2014 24  3048.1
                          2773 2015 24  1551.7
                          end
                          format %ty Year
                          Here, the ProwessCompanyCode is firm id that belongs to Industry (21,23,24 or 29). Its an unbalanced panel data where panel id is Firm. I run the similar code as posted in# 11 as below by
                          Code:
                          program drop _all
                          program doit
                              regress Sales Year, vce(r)
                              gen obs = e(N)
                              gen munificence = _b[Year]
                              gen dynamism = _se[Year]
                          end
                          rangerun doit, interval(Year -4 0) by(Industry)
                          
                          gen target_years = inrange(Year, 2005, 2012)
                          list, sepby(target_years)
                          But I get some results that refer to each firm Id and nit by years. Also, I am not aware of this "target year" , do I even have to use it as I intend to go back by five years for each of my year. Please help in this. I get the following results, (only a part shown)
                          Code:
                          6063. |           Id          |         Unique_~r          |         Industry          |
                                |         5933          |         29_232643          |               29          |
                                |--------------------------------------------------------------------------------|
                                |                                                                           Key  |
                                |                                             Spectra Industries Ltd.31-03-2017  |
                                |--------------------------------------------------------------------------------|
                                |                                                         CompanyName  |  Year   |
                                |                                             Spectra Industries Ltd.  |  2017   |
                                |--------------------------------------------------------------------------------|
                                | NICCode | Prowes~e |  WPI_1112 |    Sales | Real_S~s  | Total_A~s  | Real_S~A  |
                                |   29209 |   232643 | 111.61667 |   1315.6 | 11.78677  |     895.4  | .0131637  |
                                |--------------------------------+----------+-----------+------------+-----------|
                                | Market_~e |    Debt |     BLEV | HHI_Sa~s | Real_T~s  | Log_Rea~s  |   PBDITA  |
                                |  .0005286 |   130.6 | .1458566 | .1806151 | 8.022099  |    2.0822  |       50  |
                                |-----------+--------------------------------------------------------+-----------|
                                |      PROF |      PAT |    PATbyTA | Sellin~n | ADMSel~A | Net_Fi~s | Annual_~A |
                                |   .055841 |     12.5 |   .0139602 |      5.4 | .0060308 |    122.4 |      -6.5 |
                                |--------------------------------------------------------------------+-----------|
                                | Investme~A | Age  |  Log_Age  | rdexpen~a  |  ncfoata  | Deprec~n  | Deprec~A  |
                                |  -.0072593 |  25  | 3.218876  |         0  |  .104088  |      6.9  | .0077061  |
                                |------------+-------------------------------------------------------------------|
                                | Growth_M~e | Growth_R~s  | Current~G  |     CVA_G  |     CGIR_G  | Bankrupt~e  |
                                | -.01137034 |  .06489228  |      1.04  | .35861099  |    .104088  |  2.6766801  |
                                |--------------------------------------------------------------------------------|
                                | New_Mark~p  |  Real_PROF  |  Real_ADM  | Long_Te~g  | Real_Inv~A  |   LTBbyTA  |
                                |  .09271062  |  6.2327828  | .67314053  | 425.79999  | -.00006504  |  .4755417  |
                                |--------------------------------------------------------------------------------|
                                |    Total_~Y    |    obs    |    munifi~e    |    dynamism    |    target~s     |
                                |     2488976    |    319    |    4664.279    |    4266.587    |           0     |
                                +--------------------------------------------------------------------------------+
                          
                                +--------------------------------------------------------------------------------+
                          6064. |           Id          |         Unique_~r          |         Industry          |
                                |         5310          |          29_28981          |               29          |
                                |--------------------------------------------------------------------------------|
                                |                                                                           Key  |
                                |                                                   Force Motors Ltd.31-03-2017  |
                                |--------------------------------------------------------------------------------|
                                |                                                         CompanyName  |  Year   |
                                |                                                   Force Motors Ltd.  |  2017   |
                                |--------------------------------------------------------------------------------|
                                | NICCode | Prowes~e |  WPI_1112 |    Sales | Real_S~s  | Total_A~s  | Real_S~A  |
                                |   29102 |    28981 | 111.61667 |  34995.5 | 313.5329  |   27219.3  | .0115188  |
                                |--------------------------------+----------+-----------+------------+-----------|
                                | Market_~e |    Debt |     BLEV | HHI_Sa~s | Real_T~s  | Log_Rea~s  |   PBDITA  |
                                |  .0140602 |  2000.1 | .0734809 | .1806151 | 243.8641  |  5.496611  |   3532.5  |
                                |-----------+--------------------------------------------------------+-----------|
                                |      PROF |      PAT |    PATbyTA | Sellin~n | ADMSel~A | Net_Fi~s | Annual_~A |
                                |  .1297792 |   1799.2 |   .0661002 |    637.4 | .0234172 |   9051.4 |    1192.7 |
                                |--------------------------------------------------------------------+-----------|
                                | Investme~A | Age  |  Log_Age  | rdexpen~a  |  ncfoata  | Deprec~n  | Deprec~A  |
                                |   .0438182 |  59  | 4.077538  |   .020184  |  .172903  |   1130.8  |  .041544  |
                                |------------+-------------------------------------------------------------------|
                                | Growth_M~e | Growth_R~s  | Current~G  |     CVA_G  |     CGIR_G  | Bankrupt~e  |
                                | -.07609553 |  -.0048258  |      1.54  |    .49333  |    .172903  |  3.2244501  |
                                |--------------------------------------------------------------------------------|
                                | New_Mark~p  |  Real_PROF  |  Real_ADM  | Long_Te~g  | Real_Inv~A  |   LTBbyTA  |
                                |  .19155502  |  14.485526  | 2.6137509  |    2000.1  |  .00039258  |  .0734809  |
                                |--------------------------------------------------------------------------------|
                                |    Total_~Y    |    obs    |    munifi~e    |    dynamism    |    target~s     |
                                |     2488976    |    319    |    4664.279    |    4266.587    |           0     |
                                +--------------------------------------------------------------------------------+
                          
                                +--------------------------------------------------------------------------------+
                          6065. |           Id          |         Unique_~r          |         Industry          |
                                |         5503          |         29_230893          |               29          |
                                |--------------------------------------------------------------------------------|
                                |                                                                           Key  |
                                |                                                J T E K T India Ltd.31-03-2017  |
                                |--------------------------------------------------------------------------------|
                                |                                                         CompanyName  |  Year   |
                                |                                                J T E K T India Ltd.  |  2017   |
                                |--------------------------------------------------------------------------------|
                                | NICCode | Prowes~e |  WPI_1112 |    Sales | Real_S~s  | Total_A~s  | Real_S~A  |
                                |   29301 |   230893 | 111.61667 |  13239.2 | 118.6131  |    8212.9  | .0144423  |
                                |--------------------------------+----------+-----------+------------+-----------|
                                | Market_~e |    Debt |     BLEV | HHI_Sa~s | Real_T~s  | Log_Rea~s  |   PBDITA  |
                                |  .0053191 |  2454.9 | .2989078 | .1806151 | 73.58131  |  4.298391  |   1398.3  |
                                |-----------+--------------------------------------------------------+-----------|
                                |      PROF |      PAT |    PATbyTA | Sellin~n | ADMSel~A | Net_Fi~s | Annual_~A |
                                |  .1702565 |    250.9 |   .0305495 |    136.6 | .0166324 |   4434.6 |      56.5 |
                                |--------------------------------------------------------------------+-----------|
                                | Investme~A | Age  |  Log_Age  | rdexpen~a  |  ncfoata  | Deprec~n  | Deprec~A  |
                                |   .0068794 |  32  | 3.465736  |   .002788  |   .18253  |    747.7  | .0910397  |
                                |------------+-------------------------------------------------------------------|
                                | Growth_M~e | Growth_R~s  | Current~G  |     CVA_G  |     CGIR_G  | Bankrupt~e  |
                                | -.01753644 |  .05825046  | .76999998  | .63502502  |     .18253  |  3.4365201  |
                                |--------------------------------------------------------------------------------|
                                | New_Mark~p  |  Real_PROF  |  Real_ADM  | Long_Te~g  | Real_Inv~A  |   LTBbyTA  |
                                |   .2493435  |  19.003468  | 1.8564498  | 2454.8999  |  .00006163  |  .2989078  |
                                |--------------------------------------------------------------------------------|
                                |    Total_~Y    |    obs    |    munifi~e    |    dynamism    |    target~s     |
                                |     2488976    |    319    |    4664.279    |    4266.587    |           0     |
                                +--------------------------------------------------------------------------------+

                          Please help me in correcting this.

                          Regards,
                          Mohina

                          Comment


                          • #14
                            Dear All,

                            I could figure out my mistake and was finally able to get the regression coefficient and the standard error. Many thanks to Robert Sir (#11) for putting an elegant way to do it.
                            Still, I have a doubt, I will be grateful if someone can please resolve this. As stated in#1, for obtaining munificence we need to divide the coefficient with the average value of sales for the previous five year period. So, in #11 we need to scale the _b by sales right?

                            Code:
                            program drop _all
                            program doit
                                regress Sales Year, vce(r)
                                gen obs = e(N)
                                gen munificence = _b[Year] (This should be divided by moving average of sales to get munificence, right?)
                                gen dynamism = _se[Year]
                            end
                            rangerun doit, interval(Year -4 0) by(nace)
                            please someone correct me, if I am going wrong. And, further suggest a way for doing it in the above mentioned code. I have separately generated a rolling average of sales for the window of five years and using that for division.

                            thanks and regards,
                            Mohina

                            Comment


                            • #15
                              Hey guys,

                              I am working on quite a similar problem and don't quite know how to handle this difficult to calculate Industry Munificence and Industry Dynamism. Therefore, I referred to Iuris code [QUOTE=Iuri Gavronski;n1449288] and tried to apply to to our data.

                              An example of our data is:

                              input str6 gvkey double fyear str16 sic double sale
                              "001001" 1984 "5812" 32.007
                              "001001" 1985 "5812" 53.798
                              "001003" 1983 "5712" 13.793
                              "001003" 1984 "5712" 13.829
                              "001003" 1986 "5712" 36.308
                              "001003" 1987 "5712" 37.356
                              "001003" 1988 "5712" 32.808


                              Furthermore, we use a dummy variable to cluster the sic codes into different industries using the following code:
                              recode sic_n (0000/0999=1) (1000/1499=2) (1500/1799=3) (2000/3999=4) (4000/4999=5) ///
                              (5000/5199=6) (5200/5999=7) (6000/6799=8) (7000/8999=9) (9100/9199=10) ///
                              (9200/9899=11) (9900/9999=12), gen (sic_d)
                              label variable sic_d "Dummy Variable Industry"


                              As I said, I adjusted our code to finde Munificience by referring to Iuris code. Our code looks like this now:

                              quietly gen double indmun=.
                              quietly gen double inddyn=.

                              quietly bysort sic fyear : egen double indsales=sum(sale)

                              quietly bysort sic fyear : gen int indcount=_n
                              local if=`"if sic=="\`industry'" & (fyear>\`startyr' & fyear<=\`curyear')"'

                              forvalues industry=01/12 {
                              forvalues curyear=1980/2010 {

                              local startyr=`curyear'-5
                              quietly summarize sale `if'

                              local indmean = r(mean)

                              quietly regress indsales fyear `if' & indcount==1, vce(r)

                              local munif = _b[fyear] / `indmean'
                              local dynam = _se[fyear] / `indmean'
                              quietly replace indmun = `munif' if sic=="`industry'" & fyear==`curyear'
                              quietly replace inddyn = `dynam' if sic=="`industry'" & fyear==`curyear'
                              //di as text "Industry: `industry' fyear: `curyear' industry mean: " as result %8.3f `indmean' as text ", munificence: " as result %8.3f `munif' as text ", dynamism: " as result %8.3f `dynam' as text ", regression coefs: " _b[fyear] "(" _se[fyear] "), " _b[_cons] "(" _se[_cons] ")"
                              }
                              }

                              Whenever I run the code, however, I get the error message "no observations" . Do you guys know how to correctly adjust our code?

                              I really appreciate your help since I don't know how to continue..

                              Thank you so much in advance!!

                              Comment

                              Working...
                              X