Announcement

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

  • Panel Data Regression: reg vs xtreg

    Hello Everyone,

    I have a panel data that I am trying to make a regression for and I am confused which regression command I should use, "reg" or "xtreg"

    Below is a sub sample of my data using dataex command, but I couldn't upload it properly.

    Thanks in advance
    input str52 CompanyName int Year double(CAPEX NetPPE DepAmor)
    "American Electric Power Company, Inc. (NasdaqGS:AEP)" 2010 2591 35674 1780
    "American Electric Power Company, Inc. (NasdaqGS:AEP)" 2011 2794 36971 1792
    "American Electric Power Company, Inc. (NasdaqGS:AEP)" 2012 3156 38763 1641
    "American Electric Power Company, Inc. (NasdaqGS:AEP)" 2013 3802.1 40997 1572
    "American Electric Power Company, Inc. (NasdaqGS:AEP)" 2014 4311 43635.1 1717.9
    "American Electric Power Company, Inc. (NasdaqGS:AEP)" 2015 4605.3 46133.2 1819.3
    "American Electric Power Company, Inc. (NasdaqGS:AEP)" 2016 5017.5 45639.3 1817.1
    "American Electric Power Company, Inc. (NasdaqGS:AEP)" 2017 5799.3 50261.5 1838.2
    "American Electric Power Company, Inc. (NasdaqGS:AEP)" 2018 6357 55099.1 2078.8
    "American Electric Power Company, Inc. (NasdaqGS:AEP)" 2019 6143.7 61095.5 2429.3
    "ALLETE, Inc. (NYSE:ALE)" 2010 248.9 1805.6 80.5
    "ALLETE, Inc. (NYSE:ALE)" 2011 239.2 1982.7 90.4
    "ALLETE, Inc. (NYSE:ALE)" 2012 405.8 2347.6 100.2
    "ALLETE, Inc. (NYSE:ALE)" 2013 328.5 2576.5 116.6
    "ALLETE, Inc. (NYSE:ALE)" 2014 598.5 3284.8 136.3
    "ALLETE, Inc. (NYSE:ALE)" 2015 286.8 3669.1 167.5
    "ALLETE, Inc. (NYSE:ALE)" 2016 265.6 3741.2 195.7
    "ALLETE, Inc. (NYSE:ALE)" 2017 208.5 3822.4 182.1
    "ALLETE, Inc. (NYSE:ALE)" 2018 312.4 3904.4 209.7
    "ALLETE, Inc. (NYSE:ALE)" 2019 597.1 4405.6 212.3
    "Amgen Inc. (NasdaqGS:AMGN)" 2010 580 5522 594
    "Amgen Inc. (NasdaqGS:AMGN)" 2011 567 5420 680
    "Amgen Inc. (NasdaqGS:AMGN)" 2012 689 5326 691
    "Amgen Inc. (NasdaqGS:AMGN)" 2013 693 5349 644
    "Amgen Inc. (NasdaqGS:AMGN)" 2014 718 5223 637
    "Amgen Inc. (NasdaqGS:AMGN)" 2015 594 4907 608
    "Amgen Inc. (NasdaqGS:AMGN)" 2016 738 4961 605
    "Amgen Inc. (NasdaqGS:AMGN)" 2017 664 4989 604
    "Amgen Inc. (NasdaqGS:AMGN)" 2018 738 4958 630
    "Amgen Inc. (NasdaqGS:AMGN)" 2019 618 5397 635
    "Anika Therapeutics, Inc. (NasdaqGS:ANIK)" 2010 2.79 37 1.31
    "Anika Therapeutics, Inc. (NasdaqGS:ANIK)" 2011 1.4 36.5 1.82
    "Anika Therapeutics, Inc. (NasdaqGS:ANIK)" 2012 1.51 35.1 2.5
    "Anika Therapeutics, Inc. (NasdaqGS:ANIK)" 2013 .441 32.9 2.67
    "Anika Therapeutics, Inc. (NasdaqGS:ANIK)" 2014 1.55 31.7 2.61
    "Anika Therapeutics, Inc. (NasdaqGS:ANIK)" 2015 9.23 40.1 2.68
    "Anika Therapeutics, Inc. (NasdaqGS:ANIK)" 2016 14 52.3 2.63
    "Anika Therapeutics, Inc. (NasdaqGS:ANIK)" 2017 8.98 56.2 3.29
    "Anika Therapeutics, Inc. (NasdaqGS:ANIK)" 2018 4.66 54.1 4.91
    "Anika Therapeutics, Inc. (NasdaqGS:ANIK)" 2019 2.83 73.6 4.96
    "ANSYS, Inc. (NasdaqGS:ANSS)" 2010 14.3 36.9 11
    "ANSYS, Inc. (NasdaqGS:ANSS)" 2011 22.1 45.6 13.3
    "ANSYS, Inc. (NasdaqGS:ANSS)" 2012 24 52.3 17.4
    "ANSYS, Inc. (NasdaqGS:ANSS)" 2013 28.8 78.7 19.9
    "ANSYS, Inc. (NasdaqGS:ANSS)" 2014 26 64.6 20.9
    "ANSYS, Inc. (NasdaqGS:ANSS)" 2015 16.1 61.9 19.5
    "ANSYS, Inc. (NasdaqGS:ANSS)" 2016 12.4 54.7 18.7
    "ANSYS, Inc. (NasdaqGS:ANSS)" 2017 19.1 57.1 17.9
    "ANSYS, Inc. (NasdaqGS:ANSS)" 2018 21.8 61.7 18.4
    "ANSYS, Inc. (NasdaqGS:ANSS)" 2019 44.9 189.3 23.6
    "APA Corporation (NasdaqGS:APA)" 2010 4922 38151 3083
    "APA Corporation (NasdaqGS:APA)" 2011 7078 45448 4095
    "APA Corporation (NasdaqGS:APA)" 2012 9464 53280 4955
    "APA Corporation (NasdaqGS:APA)" 2013 9556 52421 4871
    "APA Corporation (NasdaqGS:APA)" 2014 10964 48076 4526
    "APA Corporation (NasdaqGS:APA)" 2015 4808 20838 3300
    "APA Corporation (NasdaqGS:APA)" 2016 1949 18867 2618
    "APA Corporation (NasdaqGS:APA)" 2017 2760 17759 2280
    "APA Corporation (NasdaqGS:APA)" 2018 3904 18421 2405
    "APA Corporation (NasdaqGS:APA)" 2019 2961 14158 2680
    "The Boeing Company (NYSE:BA)" 2010 1125 8931 1746
    "The Boeing Company (NYSE:BA)" 2011 1713 9313 1675
    "The Boeing Company (NYSE:BA)" 2012 1703 9660 1811
    "The Boeing Company (NYSE:BA)" 2013 2098 10224 1844
    "The Boeing Company (NYSE:BA)" 2014 2236 11007 1906
    "The Boeing Company (NYSE:BA)" 2015 2450 12076 1833
    "The Boeing Company (NYSE:BA)" 2016 2613 12807 1889
    "The Boeing Company (NYSE:BA)" 2017 1739 12672 2047
    "The Boeing Company (NYSE:BA)" 2018 1722 12645 2114
    "The Boeing Company (NYSE:BA)" 2019 1834 13684 2271
    "Biogen Inc. (NasdaqGS:BIIB)" 2010 173.1 1641.6 146.8
    "Biogen Inc. (NasdaqGS:BIIB)" 2011 208 1571.4 145.7
    "Biogen Inc. (NasdaqGS:BIIB)" 2012 254.5 1742.2 163.4
    "Biogen Inc. (NasdaqGS:BIIB)" 2013 246.3 1750.7 188.8
    "Biogen Inc. (NasdaqGS:BIIB)" 2014 287.8 1765.7 198.3
    "Biogen Inc. (NasdaqGS:BIIB)" 2015 643 2187.6 217.8
    "Biogen Inc. (NasdaqGS:BIIB)" 2016 616.1 2501.8 263.8
    "Biogen Inc. (NasdaqGS:BIIB)" 2017 867.4 3182.4 266.3
    "Biogen Inc. (NasdaqGS:BIIB)" 2018 770.6 3601.2 269.3
    "Biogen Inc. (NasdaqGS:BIIB)" 2019 514.5 3674.3 190.7
    "Bristol0Myers Squibb Company (NYSE:BMY)" 2010 424 4664 473
    "Bristol0Myers Squibb Company (NYSE:BMY)" 2011 367 4521 448
    "Bristol0Myers Squibb Company (NYSE:BMY)" 2012 548 5333 235
    "Bristol0Myers Squibb Company (NYSE:BMY)" 2013 537 4579 417
    "Bristol0Myers Squibb Company (NYSE:BMY)" 2014 526 4417 392
    "Bristol0Myers Squibb Company (NYSE:BMY)" 2015 820 4412 385
    "Bristol0Myers Squibb Company (NYSE:BMY)" 2016 1215 4980 344
    "Bristol0Myers Squibb Company (NYSE:BMY)" 2017 1055 5001 393
    "Bristol0Myers Squibb Company (NYSE:BMY)" 2018 951 5027 392
    "Bristol0Myers Squibb Company (NYSE:BMY)" 2019 836 6956 421
    "Caterpillar Inc. (NYSE:CAT)" 2010 2586 12539 2220
    "Caterpillar Inc. (NYSE:CAT)" 2011 3924 14395 2294
    "Caterpillar Inc. (NYSE:CAT)" 2012 5076 16461 2426
    "Caterpillar Inc. (NYSE:CAT)" 2013 4446 13078 2716
    "Caterpillar Inc. (NYSE:CAT)" 2014 3379 12392 2798
    "Caterpillar Inc. (NYSE:CAT)" 2015 3261 11888 2709
    "Caterpillar Inc. (NYSE:CAT)" 2016 2928 10899 2708
    "Caterpillar Inc. (NYSE:CAT)" 2017 2336 9823 2554
    "Caterpillar Inc. (NYSE:CAT)" 2018 2916 9085 2435
    "Caterpillar Inc. (NYSE:CAT)" 2019 2669 9230 2253



  • #2
    Please upload this data with dataex. It'll work so much easier like that.

    In short, use xtreg. You presumably have many of the same units over time, so that's the way to go here.

    Comment


    • #3
      Could you please tell me how I can upload my data using dataex?

      I typed the command and copied the output here, but it seems it's not the right way to do it.

      Thanks for your support.

      Comment


      • #4
        Let's try that again- type in dataex in your Stata terminal and post the exact content you see, including everything from the next bracket of the first CODE to the right bracket of /CODE

        Comment


        • #5
          Code:
          * Example generated by -dataex-. For more info, type help dataex
          clear
          input str52 CompanyName int Year double(CAPEX NetPPE DepAmor)
          "Envestnet, Inc. (NYSE:ENV)"                           2010   4.17    9.71   2.98
          "Envestnet, Inc. (NYSE:ENV)"                           2011    4.8    11.1   3.86
          "Envestnet, Inc. (NYSE:ENV)"                           2012   4.84    11.8   4.69
          "Envestnet, Inc. (NYSE:ENV)"                           2013   6.13    12.8   5.15
          "Envestnet, Inc. (NYSE:ENV)"                           2014   6.18    16.6   6.09
          "Envestnet, Inc. (NYSE:ENV)"                           2015   9.18    28.7   7.67
          "Envestnet, Inc. (NYSE:ENV)"                           2016     14      33   14.8
          "Envestnet, Inc. (NYSE:ENV)"                           2017   14.9    35.9   15.4
          "Envestnet, Inc. (NYSE:ENV)"                           2018   20.5      45   15.7
          "Envestnet, Inc. (NYSE:ENV)"                           2019   19.8   136.6   20.8
          "AT&T Inc. (NYSE:T)"                                   2010  20302  103196  13887
          "AT&T Inc. (NYSE:T)"                                   2011  20272  107087  14125
          "AT&T Inc. (NYSE:T)"                                   2012  19728  109767  14803
          "AT&T Inc. (NYSE:T)"                                   2013  21228  110968  15581
          "AT&T Inc. (NYSE:T)"                                   2014  21433  112898  16269
          "AT&T Inc. (NYSE:T)"                                   2015  20015  124450  17628
          "AT&T Inc. (NYSE:T)"                                   2016  22408  124899  18299
          "AT&T Inc. (NYSE:T)"                                   2017  21550  125222  16951
          "AT&T Inc. (NYSE:T)"                                   2018  21251  131473  16991
          "AT&T Inc. (NYSE:T)"                                   2019  19635  154167  16972
          "Comfort Systems USA, Inc. (NYSE:FIX)"                 2010   7.09    43.6   11.2
          "Comfort Systems USA, Inc. (NYSE:FIX)"                 2011   8.67    41.7   12.6
          "Comfort Systems USA, Inc. (NYSE:FIX)"                 2012   11.8    41.4   11.8
          "Comfort Systems USA, Inc. (NYSE:FIX)"                 2013   17.4    46.9   11.4
          "Comfort Systems USA, Inc. (NYSE:FIX)"                 2014   19.2    55.8   13.7
          "Comfort Systems USA, Inc. (NYSE:FIX)"                 2015   20.8    60.8   15.9
          "Comfort Systems USA, Inc. (NYSE:FIX)"                 2016   23.2    68.2     18
          "Comfort Systems USA, Inc. (NYSE:FIX)"                 2017   35.5    87.6   20.1
          "Comfort Systems USA, Inc. (NYSE:FIX)"                 2018   27.3    99.6   22.6
          "Comfort Systems USA, Inc. (NYSE:FIX)"                 2019   31.8   193.9   24.5
          "Ford Motor Company (NYSE:F)"                          2010   4092   24309   5487
          "Ford Motor Company (NYSE:F)"                          2011   4293   23585   4244
          "Ford Motor Company (NYSE:F)"                          2012   5488   26228   5290
          "Ford Motor Company (NYSE:F)"                          2013   6597   28876   6544
          "Ford Motor Company (NYSE:F)"                          2014   7463   31494   7423
          "Ford Motor Company (NYSE:F)"                          2015   7196   32177   7966
          "Ford Motor Company (NYSE:F)"                          2016   6992   33692   8717
          "Ford Motor Company (NYSE:F)"                          2017   7049   36901   8572
          "Ford Motor Company (NYSE:F)"                          2018   7785   37883   8413
          "Ford Motor Company (NYSE:F)"                          2019   7632   39496   8490
          "JetBlue Airways Corporation (NasdaqGS:JBLU)"          2010    313    4577    194
          "JetBlue Airways Corporation (NasdaqGS:JBLU)"          2011    527    4817    213
          "JetBlue Airways Corporation (NasdaqGS:JBLU)"          2012    827    5114    230
          "JetBlue Airways Corporation (NasdaqGS:JBLU)"          2013    637    5475    258
          "JetBlue Airways Corporation (NasdaqGS:JBLU)"          2014    857    5865    263
          "JetBlue Airways Corporation (NasdaqGS:JBLU)"          2015    941    6481    288
          "JetBlue Airways Corporation (NasdaqGS:JBLU)"          2016   1011    7048    337
          "JetBlue Airways Corporation (NasdaqGS:JBLU)"          2017   1202    7845    383
          "JetBlue Airways Corporation (NasdaqGS:JBLU)"          2018   1114    8746    423
          "JetBlue Airways Corporation (NasdaqGS:JBLU)"          2019   1156    9093    473
          "Tenet Healthcare Corporation (NYSE:THC)"              2010    446    4304    380
          "Tenet Healthcare Corporation (NYSE:THC)"              2011    467    4350    398
          "Tenet Healthcare Corporation (NYSE:THC)"              2012    506    4293    430
          "Tenet Healthcare Corporation (NYSE:THC)"              2013    691    7582    545
          "Tenet Healthcare Corporation (NYSE:THC)"              2014    933    7733    849
          "Tenet Healthcare Corporation (NYSE:THC)"              2015    842    7915    653
          "Tenet Healthcare Corporation (NYSE:THC)"              2016    875    8053    698
          "Tenet Healthcare Corporation (NYSE:THC)"              2017    707    7030    698
          "Tenet Healthcare Corporation (NYSE:THC)"              2018    617    6993    617
          "Tenet Healthcare Corporation (NYSE:THC)"              2019    670    7790    662
          "The Southern Company (NYSE:SO)"                       2010   4086   41609   1831
          "The Southern Company (NYSE:SO)"                       2011   4525   44498   2048
          "The Southern Company (NYSE:SO)"                       2012   4809   47755   2145
          "The Southern Company (NYSE:SO)"                       2013   5463   50571   2298
          "The Southern Company (NYSE:SO)"                       2014   5246   54160   2290
          "The Southern Company (NYSE:SO)"                       2015   5674   60340   2392
          "The Southern Company (NYSE:SO)"                       2016   7310   77811   2873
          "The Southern Company (NYSE:SO)"                       2017   7423   79238   3333
          "The Southern Company (NYSE:SO)"                       2018   8001   80191   3460
          "The Southern Company (NYSE:SO)"                       2019   7555   84420   3270
          "American Electric Power Company, Inc. (NasdaqGS:AEP)" 2010   2591   35674   1780
          "American Electric Power Company, Inc. (NasdaqGS:AEP)" 2011   2794   36971   1792
          "American Electric Power Company, Inc. (NasdaqGS:AEP)" 2012   3156   38763   1641
          "American Electric Power Company, Inc. (NasdaqGS:AEP)" 2013 3802.1   40997   1572
          "American Electric Power Company, Inc. (NasdaqGS:AEP)" 2014   4311 43635.1 1717.9
          "American Electric Power Company, Inc. (NasdaqGS:AEP)" 2015 4605.3 46133.2 1819.3
          "American Electric Power Company, Inc. (NasdaqGS:AEP)" 2016 5017.5 45639.3 1817.1
          "American Electric Power Company, Inc. (NasdaqGS:AEP)" 2017 5799.3 50261.5 1838.2
          "American Electric Power Company, Inc. (NasdaqGS:AEP)" 2018   6357 55099.1 2078.8
          "American Electric Power Company, Inc. (NasdaqGS:AEP)" 2019 6143.7 61095.5 2429.3
          "Emergent BioSolutions Inc. (NYSE:EBS)"                2010   22.1   152.7   5.99
          "Emergent BioSolutions Inc. (NYSE:EBS)"                2011     54     209   9.36
          "Emergent BioSolutions Inc. (NYSE:EBS)"                2012   53.8   241.8   11.2
          "Emergent BioSolutions Inc. (NYSE:EBS)"                2013     42   264.2     17
          "Emergent BioSolutions Inc. (NYSE:EBS)"                2014   30.7     314   25.5
          "Emergent BioSolutions Inc. (NYSE:EBS)"                2015   44.8   327.8   27.9
          "Emergent BioSolutions Inc. (NYSE:EBS)"                2016   76.2   376.4   31.2
          "Emergent BioSolutions Inc. (NYSE:EBS)"                2017   54.8   407.2     34
          "Emergent BioSolutions Inc. (NYSE:EBS)"                2018   72.1   510.2   37.2
          "Emergent BioSolutions Inc. (NYSE:EBS)"                2019   86.9     567     52
          "Johnson & Johnson (NYSE:JNJ)"                         2010   2384   14553   2191
          "Johnson & Johnson (NYSE:JNJ)"                         2011   2893   14739   2306
          "Johnson & Johnson (NYSE:JNJ)"                         2012   2934   16097   2520
          "Johnson & Johnson (NYSE:JNJ)"                         2013   3595   16710   2704
          "Johnson & Johnson (NYSE:JNJ)"                         2014   3714   16126   2495
          "Johnson & Johnson (NYSE:JNJ)"                         2015   3463   15905   2546
          "Johnson & Johnson (NYSE:JNJ)"                         2016   3226   15912   2554
          "Johnson & Johnson (NYSE:JNJ)"                         2017   3279   17005   2642
          "Johnson & Johnson (NYSE:JNJ)"                         2018   3670   17035   2529
          "Johnson & Johnson (NYSE:JNJ)"                         2019   3498   18658   2509
          end

          Comment


          • #6
            Mohammed:
            with such scant details about what you're after, I would go:
            Code:
            . encode CompanyName, g(CompanyName_num)
            
            . xtset CompanyName_num Year
            
            Panel variable: CompanyName_num (strongly balanced)
             Time variable: Year, 2010 to 2019
                     Delta: 1 unit
            . 
            
            xtreg <depvar> <indepvar> <controls> i.year, fe vce(cluster CompanyName_num)
            Kind regards,
            Carlo
            (StataNow 18.5)

            Comment

            Working...
            X