Announcement

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

  • State-year fixed effects vs state specific year trends

    Hello,

    I wanted to clarify if my understanding of including interaction terms in a panel estimation model is correct. Say, we observe outcomes for individual i in group j in state s at time t along with some covariates x. Would the factor variables generated by i.state#c.year be referred to what is known as state specific year trends whereas i.state#i.year would mean state by year fixed effects?

    Code:
    use http://www.stata-press.com/data/r13/nlswork, clear
    xtset idcode year
    
    * assume industry code are state codes
    rename ind_code state
    
    * state specific year trends?
    xtreg ln_wage i.state#c.year, fe 
    
    * state by year fixed effects?
    xtreg ln_wage i.state#i.year, fe
    Thanks!

  • #2
    Allan:
    welcome to the list.
    The following thread may be interesting: http://www.statalist.org/forums/foru...-to-panel-data
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Dear Carlo,

      Thank you for your reply. I had seen this before and I've also read the manual on factor variables. I think I understand the concepts. I am only not sure how to go about implementing this in Stata. Looking at the regression results makes me think that I am on the right track but I wanted to confirm this with someone more knowledgeable.

      Comment


      • #4
        Allan:
        the main difference is in the way you read the results of your panel data regression.
        If you use the dummy approach (that I would prefer), you can see how years contribute to explain the variation of depvar with respect to a reference year and state, as you ca see from the following toy-example.
        If you consider the trend approach, you can only say that each year contribute to explain the variation of depvar for a given amount (given by the related coefficient), no matter which is the year under discussion.
        As an aside, I would also recommend you to change a bit your code for interactions, in order to get also the "main" (but in fact conditional) effect of each predictor included in the interactions.
        Lastly, adding -baselevels. option, will help you to get how your interactions work:

        Code:
        . use http://www.stata-press.com/data/r14/nlswork.dta
        (National Longitudinal Survey.  Young Women 14-26 years of age in 1968)
        . xtreg ln_wage i.ind_code##i.year, fe basel
        note: 2.ind_code#70.year identifies no observations in the sample
        
        Fixed-effects (within) regression               Number of obs     =     28,193
        Group variable: idcode                          Number of groups  =      4,695
        
        R-sq:                                           Obs per group:
             within  = 0.1772                                         min =          1
             between = 0.1921                                         avg =        6.0
             overall = 0.1593                                         max =         15
        
                                                        F(178,23320)      =      28.21
        corr(u_i, Xb)  = 0.0803                         Prob > F          =     0.0000
        
        -------------------------------------------------------------------------------
              ln_wage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
        --------------+----------------------------------------------------------------
             ind_code |
                   1  |          0  (base)
                   2  |   .5283798    .336922     1.57   0.117    -.1320093    1.188769
                   3  |   .0369872   .1645912     0.22   0.822    -.2856223    .3595967
                   4  |   .3405781   .1023243     3.33   0.001     .1400159    .5411404
                   5  |   .3198663   .1081291     2.96   0.003     .1079261    .5318065
                   6  |   .0811109   .1030751     0.79   0.431    -.1209231     .283145
                   7  |   .1725109    .106214     1.62   0.104    -.0356756    .3806974
                   8  |   .3607797   .1177101     3.06   0.002     .1300602    .5914993
                   9  |  -.1955503   .1053099    -1.86   0.063    -.4019646     .010864
                  10  |   .1104911   .1344455     0.82   0.411     -.153031    .3740131
                  11  |   .1869438   .1030126     1.81   0.070    -.0149676    .3888552
                  12  |   .2316852    .108192     2.14   0.032     .0196217    .4437487
                      |
                 year |
                  68  |          0  (base)
                  69  |  -.1872708   .1750389    -1.07   0.285    -.5303586    .1558169
                  70  |   .1473832   .1295017     1.14   0.255    -.1064487     .401215
                  71  |   .2586222   .1256015     2.06   0.039     .0124351    .5048093
                  72  |   .0422235   .1316306     0.32   0.748    -.2157811    .3002281
                  73  |   .2691994   .1214713     2.22   0.027     .0311078    .5072911
                  75  |     .43668   .1312098     3.33   0.001     .1795001    .6938598
                  77  |   .3608121   .1275431     2.83   0.005     .1108193     .610805
                  78  |   .3741747   .1186339     3.15   0.002     .1416445    .6067049
                  80  |   .4580959   .1400491     3.27   0.001     .1835905    .7326014
                  82  |   .2758236   .1342379     2.05   0.040     .0127084    .5389387
                  83  |   .4115642   .1254241     3.28   0.001     .1657248    .6574036
                  85  |   .4347122   .1328933     3.27   0.001     .1742326    .6951918
                  87  |   .5020667   .1330855     3.77   0.000     .2412105     .762923
                  88  |   .4667113   .1288443     3.62   0.000     .2141679    .7192547
                      |
        ind_code#year |
                2 69  |   .1526565   .4775042     0.32   0.749    -.7832831    1.088596
                2 70  |          0  (empty)
                2 71  |  -.3662046   .3894775    -0.94   0.347    -1.129606    .3971969
                2 72  |  -.1283315   .4107568    -0.31   0.755    -.9334417    .6767788
                2 73  |  -.2704486   .3645722    -0.74   0.458     -.985034    .4441369
                2 75  |   -.632495   .3737003    -1.69   0.091    -1.364972    .0999821
                2 77  |  -.3343902   .3683555    -0.91   0.364    -1.056391    .3876109
                2 78  |  -.3113816   .3789757    -0.82   0.411    -1.054199    .4314356
                2 80  |  -.3726721   .3843197    -0.97   0.332    -1.125964    .3806198
                2 82  |   .0440821   .3713542     0.12   0.906    -.6837966    .7719608
                2 83  |  -.2134343   .3713055    -0.57   0.565    -.9412175    .5143489
                2 85  |   -.763444   .3819403    -2.00   0.046    -1.512072    -.014816
                2 87  |  -.4840651   .3925925    -1.23   0.218    -1.253572    .2854421
                2 88  |   .2443213   .3799636     0.64   0.520    -.5004323    .9890748
                3 69  |   .5811191   .2391745     2.43   0.015     .1123213    1.049917
                3 70  |   .1829536    .202398     0.90   0.366    -.2137598    .5796671
                3 71  |   .0695361   .2107347     0.33   0.741    -.3435178      .48259
                3 72  |    .315057   .2062528     1.53   0.127     -.089212    .7193259
                3 73  |   .1096071    .194887     0.56   0.574    -.2723841    .4915984
                3 75  |  -.1310049   .2047039    -0.64   0.522    -.5322379    .2702281
                3 77  |  -.0186752   .2012999    -0.09   0.926    -.4132363     .375886
                3 78  |   .0521297   .1986728     0.26   0.793     -.337282    .4415413
                3 80  |  -.0849118   .2066545    -0.41   0.681    -.4899681    .3201445
                3 82  |   .1679358   .1970498     0.85   0.394    -.2182948    .5541663
                3 83  |   .0517929   .1897907     0.27   0.785    -.3202093     .423795
                3 85  |   .1177318   .1962936     0.60   0.549    -.2670166    .5024802
                3 87  |  -.0022413   .1957883    -0.01   0.991    -.3859994    .3815167
                3 88  |   .2611482    .192329     1.36   0.175    -.1158292    .6381256
                4 69  |   .2641208   .1766544     1.50   0.135    -.0821335    .6103751
                4 70  |  -.0736489   .1315185    -0.56   0.575    -.3314338    .1841361
                4 71  |  -.1667249   .1276829    -1.31   0.192    -.4169918     .083542
                4 72  |   .0351128   .1338349     0.26   0.793    -.2272125     .297438
                4 73  |  -.1593927   .1236494    -1.29   0.197    -.4017537    .0829684
                4 75  |  -.3350783   .1330791    -2.52   0.012    -.5959222   -.0742345
                4 77  |  -.2015708   .1295951    -1.56   0.120    -.4555857    .0524441
                4 78  |  -.1694671   .1209795    -1.40   0.161    -.4065948    .0676606
                4 80  |   -.263051   .1420474    -1.85   0.064    -.5414733    .0153712
                4 82  |   -.047804   .1362825    -0.35   0.726    -.3149267    .2193186
                4 83  |  -.1677446   .1277774    -1.31   0.189    -.4181968    .0827076
                4 85  |  -.1683886   .1351553    -1.25   0.213    -.4333019    .0965247
                4 87  |  -.2078094   .1354498    -1.53   0.125    -.4732999    .0576812
                4 88  |  -.1161465   .1311578    -0.89   0.376    -.3732244    .1409315
                5 69  |   .1928669     .18238     1.06   0.290      -.16461    .5503437
                5 70  |  -.1378333   .1386158    -0.99   0.320    -.4095293    .1338627
                5 71  |  -.1838778    .134511    -1.37   0.172    -.4475282    .0797725
                5 72  |   .1298684   .1406108     0.92   0.356    -.1457381    .4054748
                5 73  |  -.0787484   .1311508    -0.60   0.548    -.3358127    .1783158
                5 75  |  -.2301484   .1404817    -1.64   0.101    -.5055017     .045205
                5 77  |  -.0538196   .1366556    -0.39   0.694    -.3216736    .2140345
                5 78  |  -.0141694   .1287352    -0.11   0.912    -.2664989    .2381601
                5 80  |  -.0697008   .1485594    -0.47   0.639     -.360887    .2214854
                5 82  |   .0760369   .1429502     0.53   0.595    -.2041549    .3562287
                5 83  |    .023829   .1350259     0.18   0.860    -.2408307    .2884887
                5 85  |   .0814462   .1418388     0.57   0.566    -.1965672    .3594597
                5 87  |   .0513103    .142117     0.36   0.718    -.2272485     .329869
                5 88  |   .1091772    .139025     0.79   0.432     -.163321    .3816753
                6 69  |   .2678922    .177444     1.51   0.131    -.0799096     .615694
                6 70  |   -.094933   .1323393    -0.72   0.473    -.3543267    .1644608
                6 71  |    -.16762   .1284493    -1.30   0.192    -.4193889     .084149
                6 72  |   .0826893   .1344153     0.62   0.538    -.1807734     .346152
                6 73  |  -.1129439   .1243178    -0.91   0.364    -.3566148    .1307271
                6 75  |  -.3105774   .1338556    -2.32   0.020    -.5729432   -.0482116
                6 77  |  -.1478014   .1303247    -1.13   0.257    -.4032464    .1076436
                6 78  |  -.1117213   .1217943    -0.92   0.359    -.3504462    .1270037
                6 80  |   -.136562   .1430434    -0.95   0.340    -.4169364    .1438123
                6 82  |   .0379435   .1370279     0.28   0.782    -.2306402    .3065271
                6 83  |  -.1252465   .1285573    -0.97   0.330    -.3772273    .1267343
                6 85  |  -.0955736   .1358591    -0.70   0.482    -.3618663     .170719
                6 87  |  -.1696802   .1361038    -1.25   0.213    -.4364525    .0970922
                6 88  |   -.044585   .1318683    -0.34   0.735    -.3030555    .2138855
                7 69  |   .2383896   .1803502     1.32   0.186    -.1151086    .5918878
                7 70  |  -.0189114   .1358684    -0.14   0.889    -.2852224    .2473997
                7 71  |  -.0777623   .1318864    -0.59   0.555    -.3362684    .1807437
                7 72  |   .1625899   .1379755     1.18   0.239    -.1078511     .433031
                7 73  |  -.0798336   .1279899    -0.62   0.533    -.3307022     .171035
                7 75  |  -.2247787    .137316    -1.64   0.102     -.493927    .0443696
                7 77  |  -.1040765   .1337448    -0.78   0.436    -.3662251    .1580721
                7 78  |  -.0845962   .1253915    -0.67   0.500    -.3303719    .1611794
                7 80  |  -.1643216   .1460135    -1.13   0.260    -.4505176    .1218744
                7 82  |   .0331852   .1401227     0.24   0.813    -.2414646    .3078349
                7 83  |  -.0735093   .1318813    -0.56   0.577    -.3320053    .1849867
                7 85  |   .0027527   .1391206     0.02   0.984    -.2699328    .2754382
                7 87  |  -.0369558    .139077    -0.27   0.790    -.3095559    .2356443
                7 88  |   .0936351    .135051     0.69   0.488    -.1710736    .3583439
                8 69  |   .0769338   .1927749     0.40   0.690    -.3009176    .4547852
                8 70  |  -.2351879   .1503681    -1.56   0.118    -.5299193    .0595434
                8 71  |  -.3547953   .1471316    -2.41   0.016    -.6431829   -.0664076
                8 72  |  -.1276403   .1503908    -0.85   0.396    -.4224161    .1671355
                8 73  |   -.305146   .1414542    -2.16   0.031    -.5824055   -.0278864
                8 75  |  -.5443847   .1512979    -3.60   0.000    -.8409385   -.2478309
                8 77  |  -.3950093   .1477459    -2.67   0.008     -.684601   -.1054176
                8 78  |  -.3116593   .1407374    -2.21   0.027     -.587514   -.0358047
                8 80  |   -.490115   .1585851    -3.09   0.002    -.8009521   -.1792778
                8 82  |  -.2097171   .1532674    -1.37   0.171    -.5101313     .090697
                8 83  |  -.3740381   .1457663    -2.57   0.010    -.6597495   -.0883266
                8 85  |  -.2578397   .1503417    -1.72   0.086    -.5525193    .0368399
                8 87  |  -.4094689   .1506167    -2.72   0.007    -.7046875   -.1142502
                8 88  |  -.3055674   .1464741    -2.09   0.037    -.5926662   -.0184686
                9 69  |   .3317367   .1810805     1.83   0.067    -.0231929    .6866663
                9 70  |  -.0253877   .1353814    -0.19   0.851    -.2907441    .2399687
                9 71  |  -.0389549   .1313653    -0.30   0.767    -.2964394    .2185297
                9 72  |   .1864514   .1377669     1.35   0.176    -.0835808    .4564836
                9 73  |  -.0511059   .1277247    -0.40   0.689    -.3014547    .1992428
                9 75  |  -.0938328    .138153    -0.68   0.497    -.3646219    .1769562
                9 77  |    .071135   .1341598     0.53   0.596     -.191827    .3340971
                9 78  |   .0951593   .1263915     0.75   0.452    -.1525763    .3428949
                9 80  |   .0424277   .1475864     0.29   0.774    -.2468514    .3317068
                9 82  |   .1955234   .1409891     1.39   0.166    -.0808245    .4718712
                9 83  |   .0498224   .1331979     0.37   0.708    -.2112543    .3108991
                9 85  |   .1296113   .1406551     0.92   0.357    -.1460819    .4053044
                9 87  |   .0175613   .1413606     0.12   0.901    -.2595148    .2946373
                9 88  |   .1197615   .1368616     0.88   0.382    -.1484963    .3880193
               10 69  |   .1434814   .2292074     0.63   0.531    -.3057802     .592743
               10 70  |  -.0587163   .1868798    -0.31   0.753     -.425013    .3075804
               10 71  |  -.0261439   .1907291    -0.14   0.891    -.3999854    .3476977
               10 72  |   .1354942   .1845186     0.73   0.463    -.2261743    .4971627
               10 73  |  -.1971927   .1721744    -1.15   0.252    -.5346658    .1402804
               10 75  |  -.1694313   .1805807    -0.94   0.348    -.5233812    .1845187
               10 77  |  -.0938945   .1726617    -0.54   0.587    -.4323229    .2445338
               10 78  |   .0212702   .1683405     0.13   0.899    -.3086883    .3512287
               10 80  |  -.2296768   .1821394    -1.26   0.207    -.5866819    .1273284
               10 82  |   .0032826   .1759219     0.02   0.985     -.341536    .3481011
               10 83  |   .0483658   .1724988     0.28   0.779    -.2897432    .3864748
               10 85  |    .070932   .1868785     0.38   0.704    -.2953622    .4372262
               10 87  |  -.2492522   .1828235    -1.36   0.173    -.6075982    .1090938
               10 88  |   -.017436   .1757196    -0.10   0.921    -.3618578    .3269859
               11 69  |   .2804442   .1771373     1.58   0.113    -.0667567     .627645
               11 70  |  -.0736746   .1320139    -0.56   0.577    -.3324305    .1850813
               11 71  |  -.1089434   .1281699    -0.85   0.395    -.3601649     .142278
               11 72  |   .1048631   .1341527     0.78   0.434     -.158085    .3678112
               11 73  |  -.1220965   .1239945    -0.98   0.325    -.3651338    .1209408
               11 75  |  -.3001917   .1334326    -2.25   0.024    -.5617283   -.0386551
               11 77  |  -.1946921   .1297604    -1.50   0.134    -.4490311    .0596469
               11 78  |  -.1729132   .1210757    -1.43   0.153    -.4102295    .0644031
               11 80  |  -.2793676   .1421652    -1.97   0.049    -.5580207   -.0007145
               11 82  |  -.0601358    .136446    -0.44   0.659    -.3275789    .2073072
               11 83  |  -.1568974   .1278198    -1.23   0.220    -.4074326    .0936378
               11 85  |  -.1396371   .1350311    -1.03   0.301    -.4043069    .1250327
               11 87  |  -.1795026   .1351943    -1.33   0.184    -.4444923    .0854872
               11 88  |  -.0995814   .1309932    -0.76   0.447    -.3563366    .1571739
               12 69  |    .319903   .1831218     1.75   0.081    -.0390278    .6788338
               12 70  |  -.0181839   .1392113    -0.13   0.896    -.2910472    .2546793
               12 71  |  -.0619852   .1350282    -0.46   0.646    -.3266494    .2026791
               12 72  |   .1835384     .14026     1.31   0.191    -.0913804    .4584573
               12 73  |  -.0528312   .1312094    -0.40   0.687    -.3100103    .2043479
               12 75  |  -.2521524   .1392938    -1.81   0.070    -.5251773    .0208725
               12 77  |  -.1062303   .1358253    -0.78   0.434    -.3724567    .1599962
               12 78  |  -.1423141   .1281827    -1.11   0.267    -.3935607    .1089324
               12 80  |   -.175019   .1479639    -1.18   0.237    -.4650381        .115
               12 82  |   .0237382   .1421887     0.17   0.867     -.254961    .3024374
               12 83  |  -.0224468   .1342386    -0.17   0.867    -.2855632    .2406696
               12 85  |   -.025773   .1406477    -0.18   0.855    -.3014518    .2499058
               12 87  |  -.0744125   .1407521    -0.53   0.597    -.3502959    .2014708
               12 88  |   .0345037   .1367635     0.25   0.801    -.2335617    .3025691
                      |
                _cons |   1.269297   .1008424    12.59   0.000      1.07164    1.466955
        --------------+----------------------------------------------------------------
              sigma_u |  .38553175
              sigma_e |  .29180275
                  rho |  .63577919   (fraction of variance due to u_i)
        -------------------------------------------------------------------------------
        F test that all u_i=0: F(4694, 23320) = 7.78                 Prob > F = 0.0000
        
        . xtreg ln_wage i.ind_code##c.year, fe basel
        
        Fixed-effects (within) regression               Number of obs     =     28,193
        Group variable: idcode                          Number of groups  =      4,695
        
        R-sq:                                           Obs per group:
             within  = 0.1642                                         min =          1
             between = 0.1942                                         avg =        6.0
             overall = 0.1562                                         max =         15
        
                                                        F(23,23475)       =     200.52
        corr(u_i, Xb)  = 0.0867                         Prob > F          =     0.0000
        
        ---------------------------------------------------------------------------------
                ln_wage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
        ----------------+----------------------------------------------------------------
               ind_code |
                     1  |          0  (base)
                     2  |  -.0329854   .7319445    -0.05   0.964    -1.467644    1.401673
                     3  |   .3231847   .4031876     0.80   0.423    -.4670891    1.113459
                     4  |   .6667461   .2971012     2.24   0.025     .0844084    1.249084
                     5  |   -.341637   .3146354    -1.09   0.278    -.9583428    .2750687
                     6  |   .1678251   .2973208     0.56   0.572     -.414943    .7505932
                     7  |   .0733862   .3053652     0.24   0.810    -.5251494    .6719218
                     8  |   .6120698   .3246469     1.89   0.059    -.0242592    1.248399
                     9  |  -.5972762   .3111788    -1.92   0.055    -1.207207    .0126546
                    10  |   .1517473   .4219619     0.36   0.719    -.6753255    .9788201
                    11  |   .5611393   .2959224     1.90   0.058    -.0188878    1.141166
                    12  |   .3002371   .3120751     0.96   0.336    -.3114504    .9119246
                        |
                   year |   .0206094   .0037528     5.49   0.000     .0132536    .0279651
                        |
        ind_code#c.year |
                     2  |   .0036438   .0092519     0.39   0.694    -.0144905     .021778
                     3  |  -.0024792   .0051251    -0.48   0.629    -.0125247    .0075663
                     4  |  -.0060619   .0038341    -1.58   0.114     -.013577    .0014533
                     5  |   .0081629   .0040563     2.01   0.044     .0002122    .0161136
                     6  |  -.0023953    .003836    -0.62   0.532     -.009914    .0051235
                     7  |   .0007548   .0039363     0.19   0.848    -.0069605    .0084702
                     8  |  -.0072093   .0041682    -1.73   0.084    -.0153792    .0009605
                     9  |   .0058143   .0040262     1.44   0.149    -.0020773    .0137058
                    10  |  -.0013774   .0054403    -0.25   0.800    -.0120408     .009286
                    11  |  -.0064252   .0038144    -1.68   0.092    -.0139017    .0010514
                    12  |  -.0015099   .0040132    -0.38   0.707    -.0093759    .0063562
                        |
                  _cons |  -.0165655    .290949    -0.06   0.955    -.5868444    .5537135
        ----------------+----------------------------------------------------------------
                sigma_u |  .38585435
                sigma_e |  .29312307
                    rho |  .63407407   (fraction of variance due to u_i)
        ---------------------------------------------------------------------------------
        F test that all u_i=0: F(4694, 23475) = 7.74                 Prob > F = 0.0000
        
        .
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment

        Working...
        X