Announcement

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

  • Panel Data: Generate a variable containing Initial values of another variable

    Greetings Stata Users

    I have a question, How do we generate the initial values of a variable?

    I'm reviewing articles from Barro (2000) and he uses in the regression the initial GDP of the countries over the inequality and economic growth, I'm wondering how can I do something similar in Stata in the panel data context? as an example. The regression of the form of:

    ln(GINI) = ln(GDP_Initial) + ln(GDP) +e

    I'm having this data as an example. How may I construct these initial values of the GDP into a new variable for each country?

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input long ID int year float rgdp_capita
    150 2017 73938.055
     80 2018  41032.14
    128 2018 26715.156
     58 2018  45050.71
     42 2018 36818.527
    152 2018  4187.011
     57 2018  44479.12
     42 2017  35787.89
     10 2017 14142.095
     64 2018 26460.875
    141 2018  33129.86
    105 2018  20606.47
     41 2018  32175.75
     72 2018 28223.727
     72 2017 26721.727
     93 2017   30016.5
    136 2018 16897.336
    157 2018 27102.057
    125 2018  31310.86
     40 2018 26647.395
    161 2017 12741.315
      9 2017  51983.16
     40 2017  25715.39
    129 2018  27242.97
     15 2017 20265.035
      1 2018  12625.35
     45 2017  51521.27
     73 2018  49722.31
     87 2017   6084.79
      9 2018  52904.28
      1 2017 12127.234
    149 2018   51361.5
    124 2017  29032.66
     89 2017 27177.646
    166 2017 11062.098
    111 2018     54998
    149 2017   50926.7
     73 2017   49312.4
    140 2018  27489.28
     78 2017  85500.57
      6 2017 12830.385
      6 2018 13543.347
    161 2018 13248.313
     61 2018  16192.92
     15 2018 20952.055
    152 2017  3989.608
     84 2018   26675.8
     24 2017 19725.486
    111 2017  54040.88
     94 2018  91850.15
     62 2018  51748.21
     10 2018 14226.665
    150 2018  75591.54
    129 2017 26551.533
    124 2018 30583.764
    127 2017 13282.083
    128 2017  25436.96
     16 2018  46052.12
     41 2017  31246.75
     53 2017 31037.826
    163 2018  44842.11
    117 2018 70135.914
    127 2018 14107.134
     62 2017   51254.2
    136 2017 16082.935
    163 2017  44552.94
    105 2017 19610.666
     16 2017  45419.65
    117 2017  69688.02
     80 2017  40561.09
     57 2017  43893.82
    158 2018  26077.88
     61 2017 15461.544
     84 2017  25962.47
    157 2017  26711.77
     64 2017  25989.36
     87 2018  6195.396
     78 2018  91642.77
     93 2018 31487.693
    125 2017 30396.135
     24 2018  20479.09
    140 2017 26529.924
    143 2017  39024.24
    143 2018  39804.88
    166 2018 11473.138
    116 2018 15687.484
    141 2017  31753.66
     53 2018  32267.17
     45 2018  52350.79
     89 2018 28505.254
     94 2017  90737.05
    158 2017  24824.35
     58 2017   44397.6
    116 2017 15286.814
    end
    format %ty year
    label values ID ID
    label def ID 1 "Albania", modify
    label def ID 6 "Armenia", modify
    label def ID 9 "Austria", modify
    label def ID 10 "Azerbaijan", modify
    label def ID 15 "Belarus", modify
    label def ID 16 "Belgium", modify
    label def ID 24 "Bulgaria", modify
    label def ID 40 "Croatia", modify
    label def ID 41 "Cyprus", modify
    label def ID 42 "Czech Republic", modify
    label def ID 45 "Denmark", modify
    label def ID 53 "Estonia", modify
    label def ID 57 "Finland", modify
    label def ID 58 "France", modify
    label def ID 61 "Georgia", modify
    label def ID 62 "Germany", modify
    label def ID 64 "Greece", modify
    label def ID 72 "Hungary", modify
    label def ID 73 "Iceland", modify
    label def ID 78 "Ireland", modify
    label def ID 80 "Italy", modify
    label def ID 84 "Kazakhstan", modify
    label def ID 87 "Kyrgyzstan", modify
    label def ID 89 "Latvia", modify
    label def ID 93 "Lithuania", modify
    label def ID 94 "Luxembourg", modify
    label def ID 105 "Montenegro", modify
    label def ID 111 "Netherlands", modify
    label def ID 116 "North Macedonia", modify
    label def ID 117 "Norway", modify
    label def ID 124 "Poland", modify
    label def ID 125 "Portugal", modify
    label def ID 127 "Republic of Moldova", modify
    label def ID 128 "Romania", modify
    label def ID 129 "Russian Federation", modify
    label def ID 136 "Serbia", modify
    label def ID 140 "Slovakia", modify
    label def ID 141 "Slovenia", modify
    label def ID 143 "Spain", modify
    label def ID 149 "Sweden", modify
    label def ID 150 "Switzerland", modify
    label def ID 152 "Tajikistan", modify
    label def ID 157 "Turkey", modify
    label def ID 158 "Turkmenistan", modify
    label def ID 161 "Ukraine", modify
    label def ID 163 "United Kingdom", modify
    label def ID 166 "Uzbekistan", modify
    In this setting, I want to create initial values of the variable rgdp_capita (that is, the value of the rgdp_capita in the first year of each country) in a new variable.

    How can I do it?

    Thanks,
    Merry Christmas, and Happy New Year.

    References:

    Barro, R. J. (2000). Inequality and Growth in a Panel of Countries. Journal of Economic Growth, 5(1), 5–32. http://www.jstor.org/stable/40216021

  • #2
    Code:
    bys ID (year): gen wanted = rgdp_capita[1]

    Comment


    • #3
      Awesome! Thank you very much! It is indeed helpful

      Comment

      Working...
      X