Announcement

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

  • Missing results in computing growth rate

    Dear Profs and Colleagues,

    I am going to compute the average growth rate of one variable over the period 2010-2020. (I mean the growth rate, according to 2 years).

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input double(year_2010 year_2020 growth) str6 Region
    .099 .217  .073 "Lisboa"
    .078 .077 -.012 "Centro"
    .057 .076   .02 "North" 
    end
    
    When I apply this code, missing values are generated. 
    
    gen g_var = D.vari1 / L.vari1
    (6 missing values generated)
    *Variables are in % form. The answer is in the third column, Red values, though I have no idea where they came from.*

    Any ideas are appreciated.

  • #2
    Your data extract has no variable var1, so your code cannot be replicated on it. Also, you show 3 values, but your warning is about 6 missing values being generated. Has your data been reshaped after running the line of code you show?

    Please show a data extract from the data as it is at the point that your code is applied to it.

    Comment


    • #3
      To set Panel I had to change the variablesl shape.

      Code:
      * Example generated by -dataex-. For more info, type help dataex
      clear
      input int year double vari1
      2010 .057
      2020 .076
      2020 .077
      2010 .078
      2010 .099
      2020 .217
      end
      
      
      .  tsset vari1 year
      
      Panel variable: vari1 (weakly balanced)
       Time variable: year, 2010 to 2020
               Delta: 1 unit
      
      . gen g_var = D.vari1 / L.vari1
      (6 missing values generated)

      Comment


      • #4
        This data example also doesn't work, since you are missing the Region variable, which is needed for the panel. Here is some alternative code to point you in the right direction:

        Code:
        clear
        input int year double vari1 str6 Region
        2010 .057 "North"
        2020 .076 "North"
        2020 .077 "Centro"
        2010 .078 "Centro"
        2010 .099 "Lisboa"
        2020 .217 "Lisboa"
        end
        
        encode Region, gen(region) // to enable tsset, which needs a numeric panel variable
        
        tsset region year, delta(10)
        gen g_var = D.vari1 / L.vari1
        this produces:

        Code:
        . li year region vari1 g_var, noobs sepby(region)
          +-----------------------------------+
          | year   region   vari1       g_var |
          |-----------------------------------|
          | 2010   Centro    .078           . |
          | 2020   Centro    .077   -.0128205 |
          |-----------------------------------|
          | 2010   Lisboa    .099           . |
          | 2020   Lisboa    .217    1.191919 |
          |-----------------------------------|
          | 2010    North    .057           . |
          | 2020    North    .076    .3333333 |
          +-----------------------------------+

        Comment


        • #5
          Dear Kumar,

          Thank you for getting back to me.
          I agree with you, though if you look at #1 you can see that the results (Red values) do not look like yours.

          Comment


          • #6
            The red values for Lisboa and North make approximate sense as annualised growth rates, but that logic does not work at all for Centro. I'm afraid I cannot tell you how those numbers were computed.

            Comment

            Working...
            X