Announcement

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

  • #16
    Hello everyone and a big thanks to all of you.

    I am working with a panel of 15 countries spanning 46 years. I have observations for CO2 emissions per capita, GDP per capita, gasoline consumption per capita etc.
    I want to run fixed effects DiD with CO2 emissions per capita as the dependent variable and the other variables as covariates. I include among the explanatory variables a dummy variable taking value 1 only for a single country and only for the last 16 years. The aim of the regression is to determine if a certain policy undertaken by the before-mentioned single country was effective in reducing CO2 emissions per capita. I would like to run the regression adjusting for first-order autocorrelation of error terms through GLS.
    Is it right to run
    Code:
    xtreg co2_transport_capita gas_cons_capita vehicles_capita treated i.year, fe vce(cluster countryno)
    ???

    Comment


    • #17
      Hello everyone and a big thanks to all of you.

      I am working with a panel of 15 countries spanning 46 years. I have observations for CO2 emissions per capita, GDP per capita, gasoline consumption per capita etc.
      I want to run fixed effects DiD with CO2 emissions per capita as the dependent variable and the other variables as covariates. I include among the explanatory variables a dummy variable taking value 1 only for a single country and only for the last 16 years. The aim of the regression is to determine if a certain policy undertaken by the before-mentioned single country was effective in reducing CO2 emissions per capita. I would like to run the regression adjusting for first-order autocorrelation of error terms through GLS.
      Is it right to run
      Code:
      xtreg co2_transport_capita gas_cons_capita vehicles_capita treated i.year, fe vce(cluster countryno)
      ???

      Comment


      • #18
        Paolo:
        your code looks Ok to me.
        However, I wonder whether you really need a panel data regression if you're interested in one country only (but I'm probably missing out on something about your research goal).
        Two asides:
        - it's recommended to post what you've got from Stata after your code and/or share an example/excerpt of your data via -dataex-. Thanks.
        - you probably posted inadvertently the same query twice.
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #19
          Hi Carlo, thank you for your quick reply.

          Why is a panel data regression not well-suited if I am interested in one country only? What approach should I take? What if I include more treated countries?

          This is the dataset I am using
          Code:
          * Example generated by -dataex-. To install: ssc install dataex
          clear
          input byte countryno str13 country int year float(co2_transport_capita gdp_per_capita gas_cons_capita vehicles_capita urban_pop pop_density) int treated byte _est_fixed
          1 "Australia" 1960 2.0921566   12290.4   399.456 265.71014 81.529 1.3376822 0 1
          1 "Australia" 1961  2.047124  12370.51  407.4215 275.68723 81.941 1.3645653 0 1
          1 "Australia" 1962  2.094582  12828.99  426.8293  284.2737 82.337 1.3982792 0 1
          1 "Australia" 1963  2.226484 13668.178  448.7671   322.274 82.727 1.4253544 0 1
          1 "Australia" 1964 2.2906778 13973.744  476.4037  334.7091  83.11  1.453601 0 1
          1 "Australia" 1965 2.3559887  13947.14  495.6972 347.31345 83.485 1.4823686 0 1
          1 "Australia" 1966 2.3577375 14588.798  503.3903  357.8104 83.855  1.516603 0 1
          1 "Australia" 1967  2.463768  14907.26 524.28174  351.0763 84.217  1.535868 0 1
          1 "Australia" 1968  2.583063   15775.7 545.17444  363.5721 84.573 1.5632037 0 1
          1 "Australia" 1969  2.716301 16599.564   571.149  377.3084 84.922 1.5962667 0 1
          1 "Australia" 1970  2.569761 16750.867  593.3477  389.2886 85.265  1.628028 0 1
          1 "Australia" 1971  2.553142 16967.568  603.3856  389.4823   85.6  1.684001 0 1
          1 "Australia" 1972  2.579495 17490.156  626.8498  400.6297 85.681 1.7152416 0 1
          1 "Australia" 1973 2.8161435 18647.756  664.7234   418.423 85.761  1.741666 0 1
          1 "Australia" 1974  2.824455 17863.201  662.9017  430.7956 85.841  1.786314 0 1
          1 "Australia" 1975  2.900741 17681.605  680.5585  447.3722 85.921  1.808443 0 1
          1 "Australia" 1976 2.9637284 18179.988  699.9216  456.1654     86 1.8266665 0 1
          1 "Australia" 1977 3.1207724   18103.2  725.4791  469.4856  85.94 1.8473634 0 1
          1 "Australia" 1978 3.2546315  18836.07  743.4183  482.3816 85.881 1.8689715 0 1
          1 "Australia" 1979  3.296128 19297.563  757.5444   489.876 85.821  1.889278 0 1
          1 "Australia" 1980  3.339913  19705.87  742.9213  491.5442  85.76  1.912448 0 1
          1 "Australia" 1981 3.3442755   20401.4  734.5079  504.4438   85.7  1.943038 0 1
          1 "Australia" 1982  3.363421  19630.93  742.1926  522.1212  85.64 1.9757104 0 1
          1 "Australia" 1983  3.286486  20482.02  722.1029 529.09686  85.58 2.0005727 0 1
          1 "Australia" 1984 3.3897324  21001.94  730.4426  539.0231  85.52 2.0233524 0 1
          1 "Australia" 1985 3.4401574  21281.98  732.3264 549.75934  85.46 2.0512085 0 1
          1 "Australia" 1986  3.474754  21371.39  733.8436  553.4644   85.4 2.0851047 0 1
          1 "Australia" 1987    3.4801  22680.14   721.967  554.9017   85.4 2.1170614 0 1
          1 "Australia" 1988  3.555486  23976.79  735.3528  558.8606   85.4 2.1519856 0 1
          1 "Australia" 1989  3.604054  24616.54  745.4325  564.8512   85.4 2.1887195 0 1
          1 "Australia" 1990 3.5974004 24053.396  758.4485 571.05725   85.4  2.221353 0 1
          1 "Australia" 1991  3.469683  23827.39  716.7901 558.42017   85.4 2.2498472 0 1
          1 "Australia" 1992  3.512432 24496.244   711.689  569.1538 85.566 2.2773128 0 1
          1 "Australia" 1993  3.539933 25263.627  710.4772 571.29114 85.748  2.299702 0 1
          1 "Australia" 1994  3.593951  26380.66  715.5419 580.39215 85.928 2.3241737 0 1
          1 "Australia" 1995 3.6990924 27463.305  716.9655 589.42444 86.106 2.3524206 0 1
          1 "Australia" 1996 3.7851565  28405.39  712.9048  606.3989 86.283  2.383531 0 1
          1 "Australia" 1997  3.815953  29473.05  705.7839  613.5784 86.504  2.410346 0 1
          1 "Australia" 1998  3.776388  30442.31  700.2298  625.8931 86.727 2.4355986 0 1
          1 "Australia" 1999 3.8058755 31649.654   703.054  624.7297 86.947  2.463585 0 1
          1 "Australia" 2000  3.876677  31808.55  711.0114  627.3394 87.165 2.4931335 0 1
          1 "Australia" 2001  3.794365 32638.424  670.8391  625.0516 87.378 2.5269775 0 1
          1 "Australia" 2002  3.834841 33289.363  695.2177  632.3193 87.541   2.55801 0 1
          1 "Australia" 2003  3.801381 34283.105   689.858  643.8242 87.695  2.589771 0 1
          1 "Australia" 2004  3.893697  34903.01  723.2429  654.8718 87.849 2.6199706 0 1
          1 "Australia" 2005  3.850001  35506.28  691.9411  665.8915     88  2.654778 0 1
          2 "Belgium"   1960  .7658282  9337.649  117.9878 101.61747  92.46 278.89972 0 1
          2 "Belgium"   1961  .7905097  9698.117 125.43625 110.89324 92.554 279.28094 0 1
          2 "Belgium"   1962  .8047218 10159.837 129.81833  120.9219 92.679 280.86533 0 1
          2 "Belgium"   1963  .8073397 10431.675 134.12604 132.72334 92.835 282.84583 0 1
          2 "Belgium"   1964  .8338565  11092.34 148.64398 146.25798 92.988 285.40524 0 1
          2 "Belgium"   1965  .8939452 11461.576 164.31264 166.33194 93.137 287.87326 0 1
          2 "Belgium"   1966  .8354493  11744.46 160.47765  191.2802 93.284  289.7014 0 1
          2 "Belgium"   1967  .9028293 12132.742 175.97345 184.34235 93.428  291.1944 0 1
          2 "Belgium"   1968 1.0178031 12590.272  193.3722 215.12476 93.569  292.1999 0 1
          2 "Belgium"   1969 1.0522461 13450.364 209.72354  226.0207 93.707 292.90067 0 1
          2 "Belgium"   1970 1.1703115  14252.76 228.15897   240.911 93.843  293.6624 0 1
          2 "Belgium"   1971  1.210566 14668.637  238.5983 250.82735 93.976 294.72882 0 1
          2 "Belgium"   1972 1.2892443 15573.906  259.2905  262.5026 94.106  295.8257 0 1
          2 "Belgium"   1973 1.3159894 16700.203 263.71112 274.12726 94.233 296.70932 0 1
          2 "Belgium"   1974  1.271947 17212.441 256.64066 285.48618 94.358  297.6234 0 1
          2 "Belgium"   1975 1.3560256  16833.35  282.1227 296.81305  94.48 298.44608 0 1
          2 "Belgium"   1976   1.43916 17881.715 291.70236  309.0316   94.6  298.9336 0 1
          2 "Belgium"   1977 1.5075748  18214.36 302.53223  322.6477 94.806 299.26874 0 1
          2 "Belgium"   1978 1.5468212  18889.66  315.3605   332.889 95.005 299.51248 0 1
          2 "Belgium"   1979 1.6358017  19542.59  317.2095   345.551 95.196 299.72577 0 1
          2 "Belgium"   1980 1.6076287 20262.205 298.50165 368.63715 95.381 300.03046 0 1
          2 "Belgium"   1981 1.5650703 18990.135  275.3834  351.4399 95.535 300.18283 0 1
          2 "Belgium"   1982  1.583758  18401.45 270.48682  353.9987 95.637  300.3047 0 1
          2 "Belgium"   1983 1.6183825 17862.926  261.2749  357.7042 95.737  300.3047 0 1
          2 "Belgium"   1984 1.6214507 17901.281 262.69937  361.7995 95.835  300.2133 0 1
          2 "Belgium"   1985 1.6605284 17741.836 253.69466  366.7868  95.93 300.36563 0 1
          2 "Belgium"   1986 1.8100102  18683.45 275.81107  371.0648 96.023 300.48752 0 1
          2 "Belgium"   1987 1.8631777 19444.145 287.42987   384.337 96.115 300.73126 0 1
          2 "Belgium"   1988 2.0077434 20955.324 296.31384   395.341 96.204 301.70627 0 1
          2 "Belgium"   1989 2.0427268  22174.15  289.5037  408.7078 96.292 302.80316 0 1
          2 "Belgium"   1990 2.0065455  23044.89  273.5925  422.0321 96.377 303.68677 0 1
          2 "Belgium"   1991 2.0490808  23491.94 273.67722  434.1785 96.461  304.8446 0 1
          2 "Belgium"   1992 2.1791594  24233.76 288.99496  438.7449 96.542  306.0634 0 1
          2 "Belgium"   1993 2.2172697 24355.896 281.52185   446.519 96.622  307.2821 0 1
          2 "Belgium"   1994 2.2480123  25267.62 280.65555  459.4555   96.7  308.2267 0 1
          2 "Belgium"   1995  2.229498  26120.06 279.47644  464.9677 96.777 308.86655 0 1
          2 "Belgium"   1996 2.3245883   26172.6 269.67587  472.8388 96.851  309.4759 0 1
          2 "Belgium"   1997 2.3258452 27685.637 248.98723 481.13205 96.924  310.2072 0 1
          2 "Belgium"   1998 2.3600883  28587.68  246.2019  489.4205 96.996  310.8775 0 1
          2 "Belgium"   1999 2.3722868  29682.32 234.09953  500.0866 97.065  311.5783 0 1
          2 "Belgium"   2000  2.371418 31589.385  218.9977  510.4809 97.128  312.3705 0 1
          2 "Belgium"   2001  2.439103 31735.797  212.5101  516.9614 97.184  313.4369 0 1
          2 "Belgium"   2002  2.419483 32457.047 201.97845  519.9617 97.239  314.8385 0 1
          2 "Belgium"   2003  2.499968  31523.12  202.8694  533.4392 97.292  314.3936 0 1
          2 "Belgium"   2004  2.544828 31763.965 185.39244   546.732 97.345  315.0444 0 1
          2 "Belgium"   2005  2.459294  31678.71 168.15196 559.48944 97.397  315.5444 0 1
          3 "Canada"    1960  2.799708 11758.042  657.0436 292.45178 69.061 1.9422036 0 1
          3 "Canada"    1961  2.763943 11934.454  659.6245 300.84225 69.668 2.0092351 0 1
          3 "Canada"    1962  2.840335  12445.81  682.6582 309.17975 70.494 2.0469544 0 1
          3 "Canada"    1963  2.938726 12820.818  711.6642  318.9651 71.307 2.0854435 0 1
          3 "Canada"    1964  3.056662 13459.042  735.9379  328.6205 72.107  2.125142 0 1
          3 "Canada"    1965 3.1751194  14110.33  765.7791 337.42325 72.892  2.163961 0 1
          3 "Canada"    1966 3.3160415  14758.46  796.1393  346.4083 73.642 2.2046492 0 1
          3 "Canada"    1967  3.425436  14920.31  822.1635  352.5087 74.155 2.2446778 0 1
          end

          And the following is the output of
          Code:
          xtreg co2_transport_capita gas_cons_capita vehicles_capita treated i.year, fe vce(cluster countryno)
          Code:
          Fixed-effects (within) regression               Number of obs     =        690
          Group variable: countryno                       Number of groups  =         15
          
          R-sq:                                           Obs per group:
               within  = 0.8639                                         min =         46
               between = 0.9772                                         avg =       46.0
               overall = 0.9206                                         max =         46
          
                                                          F(14,14)          =          .
          corr(u_i, Xb)  = 0.7762                         Prob > F          =          .
          
                                          (Std. Err. adjusted for 15 clusters in countryno)
          ---------------------------------------------------------------------------------
                          |               Robust
          co2_transport~a |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
          ----------------+----------------------------------------------------------------
          gas_cons_capita |   .0022807   .0007212     3.16   0.007     .0007338    .0038277
          vehicles_capita |    .000405   .0004626     0.88   0.396    -.0005872    .0013971
                  treated |  -.0216945   .0847987    -0.26   0.802    -.2035696    .1601807
                          |
                     year |
                    1961  |    .011048   .0126142     0.88   0.396    -.0160067    .0381027
                    1962  |   .0189826   .0135219     1.40   0.182     -.010019    .0479842
                    1963  |   .0357068    .019238     1.86   0.085    -.0055546    .0769681
                    1964  |   .0416381   .0326077     1.28   0.222    -.0282985    .1115746
                    1965  |    .063577   .0492871     1.29   0.218    -.0421333    .1692873
                    1966  |    .079883   .0577957     1.38   0.189    -.0440764    .2038424
                    1967  |   .0851657   .0656205     1.30   0.215    -.0555762    .2259075
                    1968  |   .1098762   .0753182     1.46   0.167    -.0516653    .2714177
                    1969  |   .1211954   .0878133     1.38   0.189    -.0671454    .3095362
                    1970  |   .1461626   .1010591     1.45   0.170    -.0705877    .3629129
                    1971  |   .1639291   .1128957     1.45   0.169    -.0782082    .4060664
                    1972  |   .1917821   .1286155     1.49   0.158    -.0840707    .4676348
                    1973  |   .2510762   .1448678     1.73   0.105    -.0596343    .5617867
                    1974  |   .2373506   .1424196     1.67   0.118    -.0681089    .5428102
                    1975  |   .2437352   .1534903     1.59   0.135    -.0854688    .5729391
                    1976  |   .2926769    .167922     1.74   0.103    -.0674799    .6528338
                    1977  |   .3060942   .1776429     1.72   0.107    -.0749119    .6871003
                    1978  |   .3364364     .19203     1.75   0.102     -.075427    .7482999
                    1979  |   .3969746   .2049902     1.94   0.073    -.0426856    .8366348
                    1980  |   .3926498   .2039566     1.93   0.075    -.0447937    .8300932
                    1981  |   .4033226   .2175286     1.85   0.085    -.0632298     .869875
                    1982  |   .3363654   .2055032     1.64   0.124    -.1043951    .7771259
                    1983  |   .3430656   .2064587     1.66   0.119    -.0997443    .7858755
                    1984  |   .3929421   .2158283     1.82   0.090    -.0699636    .8558478
                    1985  |    .411805   .2259284     1.82   0.090    -.0727633    .8963733
                    1986  |   .4391484   .2384545     1.84   0.087    -.0722857    .9505825
                    1987  |   .4765124   .2461789     1.94   0.073    -.0514889    1.004514
                    1988  |   .5425111   .2589437     2.10   0.055    -.0128679     1.09789
                    1989  |   .5759387    .271789     2.12   0.052    -.0069907    1.158868
                    1990  |   .5647028   .2752467     2.05   0.059    -.0256426    1.155048
                    1991  |   .5600137   .2761955     2.03   0.062    -.0323667    1.152394
                    1992  |   .5861856   .2843507     2.06   0.058     -.023686    1.196057
                    1993  |   .5983984    .287556     2.08   0.056    -.0183479    1.215145
                    1994  |   .6472655   .2981977     2.17   0.048     .0076951    1.286836
                    1995  |   .6631363    .300131     2.21   0.044     .0194193    1.306853
                    1996  |   .7005608   .3052095     2.30   0.038     .0459515     1.35517
                    1997  |   .7146512   .3071032     2.33   0.035     .0559803    1.373322
                    1998  |   .7500565   .3097648     2.42   0.030     .0856771    1.414436
                    1999  |   .7740207   .3152834     2.45   0.028      .097805    1.450236
                    2000  |   .7969029   .3212925     2.48   0.026      .107799    1.486007
                    2001  |   .8015754   .3211185     2.50   0.026     .1128446    1.490306
                    2002  |   .8008444   .3272034     2.45   0.028     .0990629    1.502626
                    2003  |   .8363676   .3256962     2.57   0.022     .1378188    1.534916
                    2004  |   .8755842   .3261664     2.68   0.018     .1760269    1.575142
                    2005  |   .8886004    .322657     2.75   0.016       .19657    1.580631
                          |
                    _cons |   .6007329   .1706615     3.52   0.003     .2347003    .9667655
          ----------------+----------------------------------------------------------------
                  sigma_u |  .53054308
                  sigma_e |  .20441702
                      rho |  .87073555   (fraction of variance due to u_i)

          Thank you so much.

          Comment


          • #20
            Paolo:
            in my previous reply I overlooked that you're dealing with a T>N panel dataset.
            Hence, if you stick with -fe- specification, you should better switch to -xtregar,fe- (see -xtregar- entry in Stata .pdf manual for further details, especially about standard errors options):
            Code:
            . xtregar co2_transport_capita gas_cons_capita vehicles_capita treated , fe
            note: treated omitted because of collinearity
            
            FE (within) regression with AR(1) disturbances  Number of obs     =         97
            Group variable: countryno                       Number of groups  =          3
            
            R-sq:                                           Obs per group:
                 within  = 0.3694                                         min =          7
                 between = 0.9994                                         avg =       32.3
                 overall = 0.9523                                         max =         45
            
                                                            F(2,92)           =      26.95
            corr(u_i, Xb)  = 0.8520                         Prob > F          =     0.0000
            
            ---------------------------------------------------------------------------------
            co2_transport~a |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
            ----------------+----------------------------------------------------------------
            gas_cons_capita |   .0023978   .0003655     6.56   0.000     .0016719    .0031236
            vehicles_capita |   .0020464   .0007192     2.85   0.005     .0006179    .0034749
                    treated |          0  (omitted)
                      _cons |   .7755625   .0191217    40.56   0.000     .7375851    .8135398
            ----------------+----------------------------------------------------------------
                     rho_ar |  .96489527
                    sigma_u |  .12820005
                    sigma_e |  .05062437
                    rho_fov |  .86510073   (fraction of variance because of u_i)
            ---------------------------------------------------------------------------------
            F test that all u_i=0: F(2,92) = 0.13                        Prob > F = 0.8766
            As far as your second question is concerned, if you're intersted in the variations of a continuous regressand along a given span of time for one country only, (say, Australia), -regress- is enough (as you have an N=1 and T>1 dataset; perhaps time-series related approached would work the same or probably better, but being not familiar with that stuff I cannot advise you about):
            Code:
            . regress co2_transport_capita gas_cons_capita vehicles_capita treated c.year##c.year if countryno==1
            note: treated omitted because of collinearity
            
                  Source |       SS           df       MS      Number of obs   =        46
            -------------+----------------------------------   F(4, 41)        =    783.13
                   Model |  14.9199633         4  3.72999083   Prob > F        =    0.0000
                Residual |  .195279921        41  .004762925   R-squared       =    0.9871
            -------------+----------------------------------   Adj R-squared   =    0.9858
                   Total |  15.1152432        45  .335894294   Root MSE        =    .06901
            
            ---------------------------------------------------------------------------------
            co2_transport~a |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
            ----------------+----------------------------------------------------------------
            gas_cons_capita |   .0009299   .0004785     1.94   0.059    -.0000365    .0018964
            vehicles_capita |   .0033556   .0011444     2.93   0.005     .0010443    .0056668
                    treated |          0  (omitted)
                       year |   .1333799   .7857033     0.17   0.866     -1.45338     1.72014
                            |
              c.year#c.year |  -.0000316   .0001971    -0.16   0.874    -.0004296    .0003664
                            |
                      _cons |  -139.4656   782.7646    -0.18   0.859    -1720.291     1441.36
            ---------------------------------------------------------------------------------
            
            .

            Kind regards,
            Carlo
            (Stata 19.0)

            Comment


            • #21
              Thank you once again Carlo.

              Can -xtregar,fe- be considered a GLS estimation?

              Comment


              • #22
                Paolo:
                no, -xtregar,fe- is a within estimator, whereas -xtregar,re- is GLS one.
                Kind regards,
                Carlo
                (Stata 19.0)

                Comment


                • #23
                  Many thanks for your precious help

                  Comment


                  • #24
                    Paul:
                    thanks, but -xtregar- entry in Stata .pdf manual deserves all credits!
                    Kind regards,
                    Carlo
                    (Stata 19.0)

                    Comment


                    • #25
                      But does -xtregar- automatically include year dummy variables?
                      If I try to add
                      Code:
                      i.year
                      among the regressors, I get the following message
                      Code:
                      time variable may not be included in varlist

                      Comment


                      • #26
                        Paolo:
                        actually -xtregar- doen not allow the inclusion -i.year- probably because it is conceived for taking AR1 disturbance into account.
                        Kind regards,
                        Carlo
                        (Stata 19.0)

                        Comment


                        • #27
                          Ok, I see.
                          Can I still consider it a model with both individual and time fixed effects?

                          Comment


                          • #28
                            Paolo:
                            no, as the only fixed effect you can retrieve is -u- (panel-wise time-invariant error).
                            That said, the only (community-contributed) programme that allows the researcher to retrieve multiple fixed effects is -reghdfe- (that is conceived for N>T panel datasets, though).
                            Kind regards,
                            Carlo
                            (Stata 19.0)

                            Comment


                            • #29
                              Hi there again,

                              I would like to thank you for your responses. They have helped me out. I would like to know whether there is a command in STATA that shows the criteria behind the cluster choice of VCE(cluster) standard error. I have tried with principal component analysis but I do not know how to analyze the results. Is there another way?
                              Thank you in advance

                              Comment


                              • #30
                                Ale:
                                if you mean some command that can help you out in choosing at which level clustering your standard errors, I am not aware of anythig similar in Stata.
                                Kind regards,
                                Carlo
                                (Stata 19.0)

                                Comment

                                Working...
                                X