Announcement

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

  • #16
    Yes, I will use -xtreg, fe-.

    I actually cannot perform -linktest- with -xtreg-, so I did it with -areg-. _hatsq seems to be significant which is a problem.

    Code:
     areg $ylist $xlist i.year, absorb(id)
    
    Linear regression, absorbing indicators         Number of obs     =      1,840
                                                    F(  16,   1652)   =      28.03
                                                    Prob > F          =     0.0000
                                                    R-squared         =     0.9728
                                                    Adj R-squared     =     0.9697
                                                    Root MSE          =     0.2624
    
    --------------------------------------------------------------------------------------
      protest_level |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    ---------------------+----------------------------------------------------------------
                ideology |  -.1407932   .0217453    -6.47   0.000    -.1834444   -.0981419
          internet_users |  -.0010012   .0011427    -0.88   0.381    -.0032424    .0012401
                  gdp_pc |   .0000124   4.34e-06     2.86   0.004     3.88e-06    .0000209
         opposition_size |  -.3005896   .0275566   -10.91   0.000    -.3546392   -.2465401
    executive_corruption |  -.9609528   .0989993    -9.71   0.000     -1.15513   -.7667754
                         |
                    year |
                   2011  |   .0051467    .029066     0.18   0.859    -.0518634    .0621567
                   2012  |  -.0048074   .0296329    -0.16   0.871    -.0629294    .0533147
                   2013  |  -.0373195   .0306978    -1.22   0.224    -.0975303    .0228913
                   2014  |  -.0669302   .0321451    -2.08   0.037    -.1299796   -.0038808
                   2015  |  -.0752066   .0338111    -2.22   0.026    -.1415237   -.0088896
                   2016  |  -.1157768   .0356009    -3.25   0.001    -.1856044   -.0459492
                   2017  |   -.103583   .0380022    -2.73   0.006    -.1781206   -.0290454
                   2018  |  -.1097797   .0392564    -2.80   0.005    -.1867771   -.0327822
                   2019  |   -.136404   .0402481    -3.39   0.001    -.2153467   -.0574612
                   2020  |  -.1664269   .0405677    -4.10   0.000    -.2459965   -.0868572
                         |
                   _cons |   .5787519    .094865     6.10   0.000     .3926836    .7648202
    ---------------------+----------------------------------------------------------------
                      id |      F(171, 1652) =    149.403   0.000         (172 categories)
    
    
    . linktest, absorb(id)
    
    Linear regression, absorbing indicators         Number of obs     =      1,840
                                                    F(   2,   1666)   =     235.76
                                                    Prob > F          =     0.0000
                                                    R-squared         =     0.9730
                                                    Adj R-squared     =     0.9702
                                                    Root MSE          =     0.2601
    
    ------------------------------------------------------------------------------
    protest_level |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
            _hat |   1.001816   .0468148    21.40   0.000     .9099934    1.093638
          _hatsq |  -.1352415   .0347017    -3.90   0.000     -.203305   -.0671781
           _cons |   .1124367   .0331366     3.39   0.001      .047443    .1774304
    -------------+----------------------------------------------------------------
              id |      F(171, 1666) =    264.959   0.000         (172 categories)
    Adding i.id to reg, it is _hatsq is no longer significant

    Code:
    . reg $ylist $xlist i.year i.id
    
          Source |       SS           df       MS      Number of obs   =     1,840
    -------------+----------------------------------   F(187, 1652)    =    315.60
           Model |  4062.03409       187  21.7221075   Prob > F        =    0.0000
        Residual |  113.705354     1,652  .068828907   R-squared       =    0.9728
    -------------+----------------------------------   Adj R-squared   =    0.9697
           Total |  4175.73945     1,839  2.27065767   Root MSE        =    .26235
    
    --------------------------------------------------------------------------------------
    protest_level |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    ---------------------+----------------------------------------------------------------
                ideology |  -.1407932   .0217453    -6.47   0.000    -.1834444   -.0981419
          internet_users |  -.0010012   .0011427    -0.88   0.381    -.0032424    .0012401
                  gdp_pc |   .0000124   4.34e-06     2.86   0.004     3.88e-06    .0000209
         opposition_size |  -.3005896   .0275566   -10.91   0.000    -.3546392   -.2465401
    executive_corruption |  -.9609528   .0989993    -9.71   0.000     -1.15513   -.7667754
                         |
                    year |
                   2011  |   .0051467    .029066     0.18   0.859    -.0518634    .0621567
                   2012  |  -.0048074   .0296329    -0.16   0.871    -.0629294    .0533147
                   2013  |  -.0373195   .0306978    -1.22   0.224    -.0975303    .0228913
                   2014  |  -.0669302   .0321451    -2.08   0.037    -.1299796   -.0038808
                   2015  |  -.0752066   .0338111    -2.22   0.026    -.1415237   -.0088896
                   2016  |  -.1157768   .0356009    -3.25   0.001    -.1856044   -.0459492
                   2017  |   -.103583   .0380022    -2.73   0.006    -.1781206   -.0290454
                   2018  |  -.1097797   .0392564    -2.80   0.005    -.1867771   -.0327822
                   2019  |   -.136404   .0402481    -3.39   0.001    -.2153467   -.0574612
                   2020  |  -.1664269   .0405677    -4.10   0.000    -.2459965   -.0868572
                         |
                      id |
                      2  |  -.1084751   .1225067    -0.89   0.376    -.3487598    .1318096
                      3  |   -.046946   .1405237    -0.33   0.738    -.3225692    .2286773
                      4  |  -4.645161   .3573057   -13.00   0.000     -5.34598   -3.944341
                      5  |    1.05249   .1617483     6.51   0.000      .735237    1.369744
                      6  |   .8088901   .1315889     6.15   0.000     .5507914    1.066989
                      7  |  -.5442214   .2732276    -1.99   0.047     -1.08013   -.0083124
                      8  |   .1415788   .2448754     0.58   0.563    -.3387201    .6218776
                      9  |  -.9483137   .1531772    -6.19   0.000    -1.248756   -.6478717
                     10  |   -.767803   .1124315    -6.83   0.000    -.9883263   -.5472798
                     11  |   .7977124   .2347512     3.40   0.001     .3372713    1.258154
                     12  |   1.509316   .1262564    11.95   0.000     1.261676    1.756955
                     13  |   .1015856   .1273594     0.80   0.425    -.1482172    .3513885
                     14  |  -.6809547   .1340719    -5.08   0.000    -.9439234    -.417986
                     15  |   .3981609    .156813     2.54   0.011     .0905876    .7057341
                     16  |   -1.69854    .233059    -7.29   0.000    -2.155662   -1.241418
                     17  |   2.078095     .15071    13.79   0.000     1.782492    2.373697
                     18  |  -.0217372   .1632549    -0.13   0.894    -.3419455     .298471
                     19  |    1.19187   .1337272     8.91   0.000      .929577    1.454162
                     20  |   .1878096   .1467378     1.28   0.201    -.1000021    .4756213
                     21  |   .8979478   .1686245     5.33   0.000     .5672076    1.228688
                     22  |  -2.009646   .1483966   -13.54   0.000    -2.300711   -1.718581
                     23  |    1.77604   .1562677    11.37   0.000     1.469537    2.082544
                     24  |   1.267054   .1291389     9.81   0.000      1.01376    1.520347
                     25  |   -.057597   .2537567    -0.23   0.820    -.5553157    .4401217
                     26  |  -.1770524   .3372567    -0.52   0.600    -.8385482    .4844433
                     27  |   .3100188   .1789274     1.73   0.083    -.0409296    .6609673
                     28  |  -2.810343   .1645801   -17.08   0.000    -3.133151   -2.487535
                     29  |   .3273517   .1209019     2.71   0.007     .0902147    .5644887
                     30  |   1.425016   .1226652    11.62   0.000      1.18442    1.665612
                     31  |  -.4379394   .1234899    -3.55   0.000    -.6801526   -.1957261
                     32  |  -1.187343   .1252764    -9.48   0.000    -1.433061   -.9416259
                     33  |  -.1068639   .1539283    -0.69   0.488    -.4087789    .1950512
                     34  |  -.3379935   .1231509    -2.74   0.006    -.5795419   -.0964452
                     35  |   .5212173   .1407011     3.70   0.000     .2452459    .7971886
                     36  |  -.3757769   .1625354    -2.31   0.021     -.694574   -.0569798
                     37  |  -3.007146   .1685122   -17.85   0.000    -3.337666   -2.676626
                     38  |   1.049938   .1921045     5.47   0.000     .6731443    1.426732
                     39  |   .6554494   .1896606     3.46   0.001     .2834489     1.02745
                     40  |  -1.248918   .2624368    -4.76   0.000    -1.763661   -.7341738
                     41  |  -1.089929   .1189021    -9.17   0.000    -1.323143   -.8567138
                     42  |  -.1423088   .2699745    -0.53   0.598    -.6718371    .3872195
                     43  |    .745926   .1369417     5.45   0.000     .4773283    1.014524
                     44  |  -.7842187   .1456992    -5.38   0.000    -1.069993   -.4984441
                     45  |    -1.1456   .1404838    -8.15   0.000    -1.421145    -.870055
                     46  |  -1.196022   .1401679    -8.53   0.000    -1.470948   -.9210968
                     47  |  -2.232651   .1605256   -13.91   0.000    -2.547506   -1.917796
                     48  |  -.2674375   .2132151    -1.25   0.210    -.6856377    .1507628
                     49  |   .8877415   .1948917     4.56   0.000     .5054806    1.270002
                     50  |   -2.51155   .1365275   -18.40   0.000    -2.779335   -2.243765
                     51  |   .4291922   .2359059     1.82   0.069    -.0335139    .8918983
                     52  |   .6656403   .1840907     3.62   0.000     .3045646    1.026716
                     53  |  -.2900298   .2257262    -1.28   0.199    -.7327695    .1527098
                     54  |   .5924103   .1413858     4.19   0.000      .315096    .8697246
                     55  |   .0814999   .2315584     0.35   0.725     -.372679    .5356788
                     56  |   1.492435   .1487083    10.04   0.000     1.200758    1.784111
                     57  |   1.401971   .1166993    12.01   0.000     1.173077    1.630865
                     58  |   .2352561   .1182551     1.99   0.047     .0033104    .4672019
                     59  |  -.5377026   .1157611    -4.64   0.000    -.7647566   -.3106486
                     60  |   .2465166   .1150891     2.14   0.032     .0207808    .4722525
                     61  |  -.9624268   .1964737    -4.90   0.000     -1.34779   -.5770632
                     62  |  -1.286572   .2052213    -6.27   0.000    -1.689094   -.8840509
                     63  |   1.473396   .1176813    12.52   0.000     1.242575    1.704216
                     64  |   1.227977   .1591378     7.72   0.000     .9158436    1.540109
                     65  |  -.2509415   .2717651    -0.92   0.356    -.7839819    .2820989
                     66  |   1.722013   .1210444    14.23   0.000     1.484597     1.95943
                     67  |   .5154572   .1826598     2.82   0.005      .157188    .8737263
                     68  |   2.429732   .1200878    20.23   0.000     2.194192    2.665272
                     69  |   1.155452   .1744601     6.62   0.000     .8132655    1.497638
                     70  |  -.7085905   .1305283    -5.43   0.000    -.9646088   -.4525722
                     71  |  -1.383911   .1424502    -9.72   0.000    -1.663313   -1.104509
                     72  |     .05329   .2931417     0.18   0.856    -.5216785    .6282585
                     73  |  -1.298421   .1690985    -7.68   0.000    -1.630091   -.9667508
                     74  |   .5003578   .2904277     1.72   0.085    -.0692874    1.070003
                     75  |   .7969196   .3007545     2.65   0.008     .2070193     1.38682
                     76  |  -.6887154   .2081928    -3.31   0.001    -1.097065   -.2803659
                     77  |   .4512286   .2134082     2.11   0.035     .0326496    .8698076
                     78  |   2.299049   .1607592    14.30   0.000     1.983735    2.614362
                     79  |   -1.65915   .1424995   -11.64   0.000    -1.938648   -1.379651
                     80  |  -.6927098   .2399881    -2.89   0.004    -1.163423   -.2219968
                     81  |  -2.063765   .1682413   -12.27   0.000    -2.393754   -1.733777
                     82  |   1.194205   .1192043    10.02   0.000     .9603975    1.428012
                     83  |  -.2067711   .1178559    -1.75   0.080    -.4379339    .0243917
                     84  |  -.6272589   .1199525    -5.23   0.000    -.8625338    -.391984
                     85  |  -1.051917   .2229921    -4.72   0.000    -1.489294   -.6145397
                     86  |  -1.431981   .3362551    -4.26   0.000    -2.091512   -.7724499
                     87  |  -.9323917   .1314083    -7.10   0.000    -1.190136   -.6746473
                     88  |   .1969192   .1485968     1.33   0.185    -.0945386    .4883771
                     89  |   1.074495    .123347     8.71   0.000      .832562    1.316428
                     90  |  -1.620666   .3096266    -5.23   0.000    -2.227968   -1.013364
                     91  |  -.5895211   .1336493    -4.41   0.000     -.851661   -.3273813
                     92  |   .7053369   .1241024     5.68   0.000     .4619223    .9487515
                     93  |   .7278187   .1917069     3.80   0.000     .3518047    1.103833
                     94  |  -.0949854    .301108    -0.32   0.752    -.6855789    .4956081
                     95  |   1.106798   .1851691     5.98   0.000     .7436068    1.469988
                     96  |  -.4125043   .1531356    -2.69   0.007    -.7128646   -.1121441
                     97  |    1.59232   .1314452    12.11   0.000     1.334503    1.850136
                     98  |    1.24951   .1189909    10.50   0.000     1.016121    1.482899
                     99  |  -.3497385   .1398581    -2.50   0.012    -.6240564   -.0754206
                    100  |   .9162416   .1465169     6.25   0.000     .6288632     1.20362
                    101  |   .1384062   .1520329     0.91   0.363    -.1597913    .4366036
                    102  |   .6066839   .1198815     5.06   0.000     .3715481    .8418196
                    103  |   1.193248   .1889875     6.31   0.000     .8225675    1.563928
                    104  |  -.6520775   .1260154    -5.17   0.000    -.8992441   -.4049108
                    105  |   1.949912   .1593925    12.23   0.000     1.637279    2.262544
                    106  |   .2505819   .1305687     1.92   0.055    -.0055157    .5066795
                    107  |   1.659775   .1215338    13.66   0.000     1.421399    1.898152
                    109  |   .7907077   .1553956     5.09   0.000     .4859146    1.095501
                    110  |   .8805911   .1162018     7.58   0.000     .6526727     1.10851
                    111  |   .2867139   .1762145     1.63   0.104    -.0589134    .6323412
                    112  |   .6727495   .1366451     4.92   0.000     .4047336    .9407653
                    113  |  -1.165727   .1167797    -9.98   0.000    -1.394779   -.9366756
                    114  |   .5822957   .1196374     4.87   0.000     .3476387    .8169527
                    115  |  -.9476041   .1319356    -7.18   0.000    -1.206383   -.6888255
                    116  |  -.1482264   .2601813    -0.57   0.569    -.6585462    .3620934
                    117  |  -.3887539   .4029124    -0.96   0.335    -1.179027    .4015188
                    118  |  -.5947258   .1170233    -5.08   0.000    -.8242555   -.3651962
                    119  |   .6418297   .2253965     2.85   0.004     .1997367    1.083923
                    120  |  -3.449615   .2341935   -14.73   0.000    -3.908962   -2.990268
                    121  |  -.7274559   .1146812    -6.34   0.000    -.9523917   -.5025201
                    122  |    .142638   .1585095     0.90   0.368    -.1682627    .4535387
                    123  |   .8897325   .1400919     6.35   0.000     .6149561    1.164509
                    124  |   -.651834   .1395591    -4.67   0.000    -.9255652   -.3781027
                    125  |   .5332882   .1508371     3.54   0.000     .2374362    .8291402
                    126  |   1.483235    .190713     7.78   0.000      1.10917    1.857299
                    127  |  -4.052616   .1691561   -23.96   0.000    -4.384399   -3.720834
                    128  |  -.4626088   .1964069    -2.36   0.019    -.8478415   -.0773761
                    129  |   1.501019   .1305662    11.50   0.000     1.244926    1.757112
                    130  |  -.3761088   .1405991    -2.68   0.008    -.6518799   -.1003376
                    131  |  -4.628049   .6814847    -6.79   0.000    -5.964713   -3.291384
                    132  |   .5126954    .156409     3.28   0.001     .2059146    .8194762
                    133  |  -.4705743   .1700641    -2.77   0.006    -.8041382   -.1370105
                    134  |  -1.123361   .1461388    -7.69   0.000    -1.409998   -.8367241
                    135  |  -2.997653   .2582703   -11.61   0.000    -3.504224   -2.491081
                    136  |  -2.637256   .1236668   -21.33   0.000    -2.879817   -2.394696
                    137  |   .4270498   .1374181     3.11   0.002     .1575177    .6965818
                    138  |  -2.117111   .3295203    -6.42   0.000    -2.763433    -1.47079
                    139  |   .6620431    .171431     3.86   0.000     .3257981    .9982881
                    140  |   .9625256   .1160075     8.30   0.000     .7349884    1.190063
                    141  |   1.514801   .1245933    12.16   0.000     1.270423    1.759178
                    142  |   .0216277   .1246722     0.17   0.862    -.2229045    .2661599
                    143  |   .2518155   .1508055     1.67   0.095    -.0439746    .5476055
                    144  |   1.270981   .1238505    10.26   0.000      1.02806    1.513901
                    145  |    .550098   .1572068     3.50   0.000     .2417525    .8584435
                    146  |   1.004006    .183866     5.46   0.000     .6433713    1.364641
                    147  |   .7887459   .1931422     4.08   0.000     .4099165    1.167575
                    148  |   .1878241   .2592911     0.72   0.469    -.3207498    .6963979
                    149  |  -.9065014   .1577119    -5.75   0.000    -1.215838   -.5971651
                    150  |    .038087   .1770549     0.22   0.830    -.3091887    .3853627
                    151  |  -1.751648    .140542   -12.46   0.000    -2.027308   -1.475989
                    152  |  -.8616855   .1162276    -7.41   0.000    -1.089654   -.6337166
                    153  |  -.5634213   .1156097    -4.87   0.000    -.7901783   -.3366643
                    154  |   -.038348   .1482548    -0.26   0.796    -.3291351    .2524391
                    155  |   -2.08276   .1489873   -13.98   0.000    -2.374984   -1.790536
                    156  |  -3.526799   .1939292   -18.19   0.000    -3.907172   -3.146426
                    157  |   1.236409   .1403994     8.81   0.000     .9610297    1.511789
                    158  |   1.035856   .2055987     5.04   0.000     .6325947    1.439118
                    159  |   .0966767   .1583903     0.61   0.542    -.2139902    .4073436
                    160  |  -1.456634   .1670271    -8.72   0.000    -1.784241   -1.129027
                    162  |   .0441592   .1357136     0.33   0.745    -.2220296     .310348
                    163  |   .1826074   .1193546     1.53   0.126    -.0514949    .4167097
                    164  |   .8799518    .133243     6.60   0.000     .6186088    1.141295
                    165  |  -.4312003   .1823943    -2.36   0.018    -.7889486   -.0734519
                    166  |  -.0343278    .282608    -0.12   0.903    -.5886354    .5199799
                    167  |  -3.083178   .1473939   -20.92   0.000    -3.372277    -2.79408
                    168  |  -1.005962   .1608727    -6.25   0.000    -1.321498   -.6904264
                    169  |  -2.721686   .1576485   -17.26   0.000    -3.030898   -2.412474
                    170  |   .7662501   .1766148     4.34   0.000     .4198376    1.112663
                    172  |  -.4958833   .1413118    -3.51   0.000    -.7730524   -.2187142
                    173  |   .5210892    .138704     3.76   0.000      .249035    .7931434
                    174  |   .3248953   .1399612     2.32   0.020     .0503753    .5994153
                    175  |   .7163465   .1288107     5.56   0.000     .4636971    .9689958
                         |
                   _cons |   .7164494   .1245576     5.75   0.000     .4721421    .9607568
    --------------------------------------------------------------------------------------
    
    . linktest
    
          Source |       SS           df       MS      Number of obs   =     1,840
    -------------+----------------------------------   F(2, 1837)      =  32823.18
           Model |  4062.06946         2  2031.03473   Prob > F        =    0.0000
        Residual |  113.669992     1,837  .061878058   R-squared       =    0.9728
    -------------+----------------------------------   Adj R-squared   =    0.9727
           Total |  4175.73945     1,839  2.27065767   Root MSE        =    .24875
    
    ------------------------------------------------------------------------------
    protest_level |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
            _hat |   .9994323   .0039746   251.46   0.000     .9916372    1.007227
          _hatsq |  -.0019199   .0025397    -0.76   0.450    -.0069009    .0030611
           _cons |   .0046225   .0085212     0.54   0.588    -.0120898    .0213348
    ------------------------------------------------------------------------------
    Last edited by Enrique Santiago Pajuelo; 02 May 2021, 11:39.

    Comment


    • #17
      Enrigue:
      I'm aware that you cannot run -linktest- after -xtreg-: that's why in #15 I've mentioned a -linktest- like approach, that you can see in the following toy-example (the model is misspecified, as -test- outcome reaches statistical signifcance):
      Code:
      . use "https://www.stata-press.com/data/r16/nlswork.dta"
      (National Longitudinal Survey.  Young Women 14-26 years of age in 1968)
      
      . xtreg ln_wage c.age##c.age i.year, fe vce(robust)
      
      Fixed-effects (within) regression               Number of obs     =     28,510
      Group variable: idcode                          Number of groups  =      4,710
      
      R-sq:                                           Obs per group:
           within  = 0.1162                                         min =          1
           between = 0.1078                                         avg =        6.1
           overall = 0.0932                                         max =         15
      
                                                      F(16,4709)        =      79.11
      corr(u_i, Xb)  = 0.0613                         Prob > F          =     0.0000
      
                                   (Std. Err. adjusted for 4,710 clusters in idcode)
      ------------------------------------------------------------------------------
                   |               Robust
           ln_wage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
               age |   .0728746    .013687     5.32   0.000     .0460416    .0997075
                   |
       c.age#c.age |  -.0010113   .0001076    -9.40   0.000    -.0012224   -.0008003
                   |
              year |
               69  |   .0647054   .0155249     4.17   0.000     .0342693    .0951415
               70  |   .0284423   .0264639     1.07   0.283    -.0234395     .080324
               71  |   .0579959   .0384111     1.51   0.131    -.0173078    .1332996
               72  |   .0510671   .0502675     1.02   0.310    -.0474808     .149615
               73  |   .0424104   .0624924     0.68   0.497    -.0801038    .1649247
               75  |   .0151376    .086228     0.18   0.861    -.1539096    .1841848
               77  |   .0340933   .1106841     0.31   0.758    -.1828994     .251086
               78  |   .0537334   .1232232     0.44   0.663    -.1878417    .2953084
               80  |   .0369475   .1473725     0.25   0.802    -.2519716    .3258667
               82  |   .0391687   .1715621     0.23   0.819    -.2971733    .3755108
               83  |    .058766   .1836086     0.32   0.749    -.3011928    .4187249
               85  |   .1042758   .2080199     0.50   0.616    -.3035406    .5120922
               87  |   .1242272   .2327328     0.53   0.594    -.3320379    .5804922
               88  |   .1904977   .2486083     0.77   0.444    -.2968909    .6778863
                   |
             _cons |   .3937532   .2469015     1.59   0.111    -.0902893    .8777957
      -------------+----------------------------------------------------------------
           sigma_u |  .40275174
           sigma_e |  .30127563
               rho |  .64120306   (fraction of variance due to u_i)
      ------------------------------------------------------------------------------
      
      . predict fitted, xb
      (24 missing values generated)
      
      . g sq_fitted=fitted^2
      (24 missing values generated)
      
      . xtreg ln_wage c.age##c.age i.year fitted sq_fitted , fe vce(robust)
      note: c.age#c.age omitted because of collinearity
      
      Fixed-effects (within) regression               Number of obs     =     28,510
      Group variable: idcode                          Number of groups  =      4,710
      
      R-sq:                                           Obs per group:
           within  = 0.1173                                         min =          1
           between = 0.1121                                         avg =        6.1
           overall = 0.0952                                         max =         15
      
                                                      F(17,4709)        =      76.35
      corr(u_i, Xb)  = 0.0636                         Prob > F          =     0.0000
      
                                   (Std. Err. adjusted for 4,710 clusters in idcode)
      ------------------------------------------------------------------------------
                   |               Robust
           ln_wage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
               age |  -.0004375   .0123334    -0.04   0.972    -.0246168    .0237418
                   |
       c.age#c.age |          0  (omitted)
                   |
              year |
               69  |   -.016534   .0175908    -0.94   0.347    -.0510202    .0179523
               70  |  -.0127288   .0270511    -0.47   0.638    -.0657616    .0403039
               71  |  -.0164466   .0396213    -0.42   0.678    -.0941229    .0612297
               72  |    -.01567   .0511885    -0.31   0.760    -.1160234    .0846835
               73  |  -.0163476   .0631829    -0.26   0.796    -.1402158    .1075205
               75  |  -.0170026   .0864874    -0.20   0.844    -.1865584    .1525532
               77  |  -.0111413   .1109886    -0.10   0.920    -.2287309    .2064483
               78  |  -.0029997   .1236291    -0.02   0.981    -.2453706    .2393712
               80  |  -.0007318   .1475088    -0.00   0.996     -.289918    .2884544
               82  |   .0058067   .1716208     0.03   0.973    -.3306503    .3422638
               83  |   .0158354   .1837029     0.09   0.931    -.3443083     .375979
               85  |     .04142   .2083538     0.20   0.842    -.3670508    .4498909
               87  |   .0523993   .2330342     0.22   0.822    -.4044568    .5092553
               88  |   .0938441   .2496481     0.38   0.707     -.395583    .5832712
                   |
            fitted |   5.201776   1.085644     4.79   0.000     3.073405    7.330147
         sq_fitted |  -1.321262   .3415637    -3.87   0.000    -1.990887   -.6516372
             _cons |  -3.307108    .892101    -3.71   0.000    -5.056043   -1.558172
      -------------+----------------------------------------------------------------
           sigma_u |  .40189262
           sigma_e |   .3011033
               rho |  .64048345   (fraction of variance due to u_i)
      ------------------------------------------------------------------------------
      
      . test sq_fitted
      
       ( 1)  sq_fitted = 0
      
             F(  1,  4709) =   14.96
                  Prob > F =    0.0001
      
      .
      Kind regards,
      Carlo
      (Stata 19.0)

      Comment


      • #18
        Hello Carlo,

        I have tested it manually as you told me and it seems it is not significant (so the model is not misspecified). Fitted is omitted due to collinearity. Should sq_fitted be included as parameter in my -fe- or it is just for testing misspecification?

        Thank you so much for providing the example.

        Code:
        . xtreg $ylist $xlist i.year, fe vce(cluster id)
        
        Fixed-effects (within) regression               Number of obs     =      1,840
        Group variable: id                              Number of groups  =        172
        
        R-sq:                                           Obs per group:
             within  = 0.2135                                         min =          1
             between = 0.2341                                         avg =       10.7
             overall = 0.2236                                         max =         11
        
                                                        F(16,171)         =       5.68
        corr(u_i, Xb)  = -0.1088                        Prob > F          =     0.0000
        
                                                   (Std. Err. adjusted for 172 clusters in id)
        --------------------------------------------------------------------------------------
                             |               Robust
          protest_level |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
        ---------------------+----------------------------------------------------------------
                    ideology |  -.1407932   .0574657    -2.45   0.015    -.2542266   -.0273597
              internet_users |  -.0010012   .0019363    -0.52   0.606    -.0048233    .0028209
                      gdp_pc |   .0000124   8.73e-06     1.42   0.158    -4.84e-06    .0000296
             opposition_size |  -.3005896   .0781382    -3.85   0.000    -.4548293     -.14635
        executive_corruption |  -.9609528   .3637076    -2.64   0.009    -1.678888   -.2430179
                             |
                        year |
                       2011  |   .0051467   .0241086     0.21   0.831     -.042442    .0527354
                       2012  |  -.0048074   .0283033    -0.17   0.865    -.0606762    .0510614
                       2013  |  -.0373195   .0326917    -1.14   0.255    -.1018508    .0272118
                       2014  |  -.0669302   .0367843    -1.82   0.071    -.1395399    .0056795
                       2015  |  -.0752066   .0429393    -1.75   0.082    -.1599661    .0095528
                       2016  |  -.1157768   .0468634    -2.47   0.014    -.2082822   -.0232715
                       2017  |   -.103583   .0508403    -2.04   0.043    -.2039385   -.0032276
                       2018  |  -.1097797   .0546515    -2.01   0.046    -.2176581   -.0019012
                       2019  |   -.136404   .0566913    -2.41   0.017    -.2483088   -.0244991
                       2020  |  -.1664269   .0601279    -2.77   0.006    -.2851154   -.0477383
                             |
                       _cons |   .5787519   .2357694     2.45   0.015     .1133587    1.044145
        ---------------------+----------------------------------------------------------------
                     sigma_u |  1.3059579
                     sigma_e |  .26235264
                         rho |  .96120905   (fraction of variance due to u_i)
        --------------------------------------------------------------------------------------
        
        . predict fitted, xb
        (96 missing values generated)
        
        . g sq_fitted=fitted^2
        (96 missing values generated)
        
        . xtreg $ylist $xlist i.year fitted sq_fitted, fe vce(cluster id)
        note: fitted omitted because of collinearity
        
        Fixed-effects (within) regression               Number of obs     =      1,840
        Group variable: id                              Number of groups  =        172
        
        R-sq:                                           Obs per group:
             within  = 0.2216                                         min =          1
             between = 0.2879                                         avg =       10.7
             overall = 0.2758                                         max =         11
        
                                                        F(17,171)         =       6.78
        corr(u_i, Xb)  = 0.0826                         Prob > F          =     0.0000
        
                                                   (Std. Err. adjusted for 172 clusters in id)
        --------------------------------------------------------------------------------------
                             |               Robust
          protest_level |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
        ---------------------+----------------------------------------------------------------
                    ideology |  -.1615778   .0568517    -2.84   0.005    -.2737992   -.0493564
              internet_users |  -.0008581   .0019342    -0.44   0.658    -.0046761    .0029599
                      gdp_pc |   .0000111   8.41e-06     1.32   0.189    -5.52e-06    .0000277
             opposition_size |  -.2708587   .0840916    -3.22   0.002    -.4368499   -.1048675
        executive_corruption |  -.9956933    .365961    -2.72   0.007    -1.718076   -.2733105
                             |
                        year |
                       2011  |   .0092421    .024527     0.38   0.707    -.0391726    .0576568
                       2012  |   -.003111   .0282376    -0.11   0.912    -.0588502    .0526283
                       2013  |  -.0405085   .0317645    -1.28   0.204    -.1032095    .0221926
                       2014  |  -.0713864   .0358416    -1.99   0.048    -.1421353   -.0006374
                       2015  |  -.0805226   .0418574    -1.92   0.056    -.1631464    .0021012
                       2016  |  -.1235708   .0455471    -2.71   0.007    -.2134776   -.0336639
                       2017  |  -.1089949   .0501099    -2.18   0.031    -.2079086   -.0100813
                       2018  |  -.1134399   .0537501    -2.11   0.036    -.2195391   -.0073407
                       2019  |  -.1417327   .0558545    -2.54   0.012    -.2519857   -.0314797
                       2020  |  -.1757838   .0597359    -2.94   0.004    -.2936985    -.057869
                             |
                      fitted |          0  (omitted)
                   sq_fitted |   -.155211   .0806236    -1.93   0.056    -.3143566    .0039346
                       _cons |   .7460803    .260306     2.87   0.005     .2322534    1.259907
        ---------------------+----------------------------------------------------------------
                     sigma_u |  1.2579572
                     sigma_e |  .26106802
                         rho |  .95870836   (fraction of variance due to u_i)
        --------------------------------------------------------------------------------------
        
        . test sq_fitted
        
         ( 1)  sq_fitted = 0
        
               F(  1,   171) =    3.71
                    Prob > F =    0.0559
        Last edited by Enrique Santiago Pajuelo; 02 May 2021, 12:28.

        Comment


        • #19
          Apparently I did something wrong before, because it now lets me include "fitted". It is still not significant.

          Code:
          xtreg $ylist $xlist i.year fitted sq_fitted, fe vce(cluster id)
          
          Fixed-effects (within) regression               Number of obs     =      1,840
          Group variable: id                              Number of groups  =        172
          
          R-sq:                                           Obs per group:
               within  = 0.2197                                         min =          1
               between = 0.2811                                         avg =       10.7
               overall = 0.2696                                         max =         11
          
                                                          F(18,171)         =       5.97
          corr(u_i, Xb)  = 0.0362                         Prob > F          =     0.0000
          
                                                     (Std. Err. adjusted for 172 clusters in id)
          --------------------------------------------------------------------------------------
                               |               Robust
            protest_level |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
          ---------------------+----------------------------------------------------------------
                      ideology |  -.1449793   .0653867    -2.22   0.028    -.2740483   -.0159103
                internet_users |  -.0001022    .002931    -0.03   0.972    -.0058877    .0056834
                        gdp_pc |   8.62e-06   9.18e-06     0.94   0.349    -9.50e-06    .0000267
               opposition_size |  -.2344934   .2013687    -1.16   0.246     -.631982    .1629952
          executive_corruption |  -.8271186   .8599052    -0.96   0.337    -2.524515    .8702774
                               |
                          year |
                         2011  |   .0058125   .0306111     0.19   0.850    -.0546117    .0662367
                         2012  |   -.005038   .0424948    -0.12   0.906    -.0889199    .0788438
                         2013  |  -.0363563   .0624198    -0.58   0.561     -.159569    .0868563
                         2014  |  -.0648014   .0763637    -0.85   0.397    -.2155383    .0859355
                         2015  |  -.0727037   .0887797    -0.82   0.414     -.247949    .1025417
                         2016  |  -.1103668   .1138252    -0.97   0.334    -.3350502    .1143167
                         2017  |  -.0979376   .1111547    -0.88   0.380    -.3173496    .1214743
                         2018  |  -.1044701   .1153728    -0.91   0.366    -.3322083    .1232682
                         2019  |   -.129198    .132272    -0.98   0.330    -.3902943    .1318983
                         2020  |  -.1574144   .1296286    -1.21   0.226    -.4132927    .0984639
                               |
                        fitted |   .0527947   .4523052     0.12   0.907    -.8400258    .9456152
                     sq_fitted |  -.0695837   .0410363    -1.70   0.092    -.1505866    .0114192
                         _cons |   .6142799   .5086884     1.21   0.229    -.3898374    1.618397
          ---------------------+----------------------------------------------------------------
                       sigma_u |  1.2597131
                       sigma_e |  .26147842
                           rho |  .95869443   (fraction of variance due to u_i)
          --------------------------------------------------------------------------------------
          
          . test sq_fitted
          
           ( 1)  sq_fitted = 0
          
                 F(  1,   171) =    2.88
                      Prob > F =    0.0918

          Comment


          • #20
            Enrique:
            hence there's no evidence that your model is misspecified.
            Go on with the existing predictors.
            Kind regards,
            Carlo
            (Stata 19.0)

            Comment


            • #21
              Hello Carlo,

              Thank you very very much for all your help.

              Comment

              Working...
              X