Announcement

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

  • IV , 2SLS estimation problem

    Dear all,

    Hello! I am using panel data and I did an Instrumental Variable estimation using the -xtivreg- command.
    However, when I use the command -estat endog- to perform the test for endogeneity and the command -estat firststage- , Stata says that my commands are invalid but I am sure they are correct. Is there a way I can overcome this issue?
    Thank you in advance.


    Kind Regards,
    Katerina
    ( Stata/SE 16.0)

  • #2
    However, when I use the command -estat endog- to perform the test for endogeneity and the command -estat firststage- , Stata says that my commands are invalid but I am sure they are correct.
    These post estimation commands are available for ivregress and not xtivreg. If you are estimating a fixed effects IV model and the number of panels is not too large, you can include the fixed effects using dummies in ivregress.

    Comment


    • #3
      Andrew Musau Thank you so much for your answer... I didn't know that I am sorry. I will definitely do it again using ivregress.
      Can you please explain to me how can I include the fixed effects using dummies?

      Comment


      • #4
        Code:
        webuse abdata
        *PANEL IDENTIFIER= id
        xtset id year
        xtivreg n l2.n l(0/1).w l(0/2).(k ys) yr1981-yr1984 (l.n = l3.n), fe
        *FIXED EFFECTS = i.id
        ivregress 2sls n l2.n l(0/1).w l(0/2).(k ys) yr1981-yr1984 (l.n = l3.n) i.id, small
        Res.:

        Code:
        . xtivreg n l2.n l(0/1).w l(0/2).(k ys) yr1981-yr1984 (l.n = l3.n), fe
        
        Fixed-effects (within) IV regression            Number of obs     =        611
        Group variable: id                              Number of groups  =        140
        
        R-sq:                                           Obs per group:
             within  = 0.7288                                         min =          4
             between = 0.9913                                         avg =        4.4
             overall = 0.9856                                         max =          6
        
                                                        Wald chi2(14)     =   54443.61
        corr(u_i, Xb)  = 0.6854                         Prob > chi2       =     0.0000
        
        ------------------------------------------------------------------------------
                   n |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
        -------------+----------------------------------------------------------------
                   n |
                 L1. |   1.041278   .3025634     3.44   0.001      .448265    1.634292
                 L2. |  -.3426033   .1621362    -2.11   0.035    -.6603845   -.0248221
                     |
                   w |
                 --. |  -.6101005   .0708995    -8.61   0.000     -.749061   -.4711401
                 L1. |   .5289202   .2060096     2.57   0.010     .1251488    .9326917
                     |
                   k |
                 --. |   .3796942   .0497241     7.64   0.000     .2822368    .4771517
                 L1. |  -.1949596   .1069424    -1.82   0.068    -.4045628    .0146436
                 L2. |   .0020901   .0420389     0.05   0.960    -.0803046    .0844847
                     |
                  ys |
                 --. |   .5587552   .1356942     4.12   0.000     .2927996    .8247109
                 L1. |  -.9432021   .2605708    -3.62   0.000    -1.453912   -.4324927
                 L2. |   .1832405   .2157935     0.85   0.396     -.239707     .606188
                     |
              yr1981 |  -.0446299   .0175524    -2.54   0.011    -.0790319   -.0102279
              yr1982 |  -.0575767   .0221038    -2.60   0.009    -.1008994    -.014254
              yr1983 |  -.0647932   .0265031    -2.44   0.014    -.1167382   -.0128481
              yr1984 |  -.0589397   .0307644    -1.92   0.055    -.1192368    .0013573
               _cons |   1.618841   1.085379     1.49   0.136    -.5084637    3.746146
        -------------+----------------------------------------------------------------
             sigma_u |  .17858284
             sigma_e |  .10448489
                 rho |  .74498093   (fraction of variance due to u_i)
        ------------------------------------------------------------------------------
        F  test that all u_i=0:     F(139,457) =     0.54         Prob > F    = 1.0000
        ------------------------------------------------------------------------------
        Instrumented:   L.n
        Instruments:    L2.n w L.w k L.k L2.k ys L.ys L2.ys yr1981 yr1982 yr1983
                        yr1984 L3.n
        ------------------------------------------------------------------------------
        
        
        . ivregress 2sls n l2.n l(0/1).w l(0/2).(k ys) yr1981-yr1984 (l.n = l3.n) i.id, small
        
        
        Instrumental variables (2SLS) regression
        
              Source |       SS       df       MS         Number of obs   =        611
        -------------+------------------------------      F(153,   457)   =     654.67
               Model |  1094.25433   153  7.15198907      Prob > F        =     0.0000
            Residual |  4.98911115   457  .010917092      R-squared       =     0.9955
        -------------+------------------------------      Adj R-squared   =     0.9939
               Total |  1099.24344   610  1.80203842      Root MSE        =     .10448
        
        ------------------------------------------------------------------------------
                   n |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
        -------------+----------------------------------------------------------------
                   n |
                 L1. |   1.041278   .3025634     3.44   0.001     .4466903    1.635866
                 L2. |  -.3426033   .1621362    -2.11   0.035    -.6612283   -.0239783
                     |
                   w |
                 --. |  -.6101005   .0708995    -8.61   0.000      -.74943   -.4707711
                 L1. |   .5289202   .2060096     2.57   0.011     .1240766    .9337639
                     |
                   k |
                 --. |   .3796942   .0497241     7.64   0.000      .281978    .4774105
                 L1. |  -.1949596   .1069424    -1.82   0.069    -.4051194    .0152002
                 L2. |   .0020901   .0420389     0.05   0.960    -.0805234    .0847035
                     |
                  ys |
                 --. |   .5587552   .1356942     4.12   0.000     .2920934    .8254171
                 L1. |  -.9432021   .2605708    -3.62   0.000    -1.455268   -.4311366
                 L2. |   .1832405   .2157935     0.85   0.396    -.2408301    .6073111
                     |
              yr1981 |  -.0446299   .0175524    -2.54   0.011    -.0791232   -.0101366
              yr1982 |  -.0575767   .0221038    -2.60   0.009    -.1010144   -.0141389
              yr1983 |  -.0647932   .0265031    -2.44   0.015    -.1168761   -.0127102
              yr1984 |  -.0589397   .0307644    -1.92   0.056    -.1193969    .0015174
                     |
                  id |
                  2  |   .2517751   .1806031     1.39   0.164    -.1031405    .6066907
                  3  |   .0742088   .1449075     0.51   0.609    -.2105589    .3589765
                  4  |   .1305803   .1380529     0.95   0.345    -.1407169    .4018775
                  5  |   .2172429   .1983619     1.10   0.274    -.1725716    .6070575
                  6  |  -.1555884   .1218008    -1.28   0.202    -.3949475    .0837706
                  7  |  -.2962532   .1296279    -2.29   0.023    -.5509938   -.0415126
                  8  |  -.0871508   .1383186    -0.63   0.529    -.3589702    .1846686
                  9  |  -.0067442   .1202581    -0.06   0.955    -.2430715    .2295832
                 10  |  -.1124819   .0980315    -1.15   0.252    -.3051303    .0801666
                 11  |  -.2698972   .1240247    -2.18   0.030    -.5136266   -.0261678
                 12  |  -.1306666   .1559439    -0.84   0.403    -.4371227    .1757895
                 13  |  -.0659484   .1142375    -0.58   0.564    -.2904443    .1585475
                 14  |  -.0076793   .1323763    -0.06   0.954     -.267821    .2524623
                 15  |  -.0111962   .1011815    -0.11   0.912    -.2100349    .1876425
                 16  |  -.0872834   .1137412    -0.77   0.443     -.310804    .1362372
                 17  |   .0252075   .1513951     0.17   0.868    -.2723094    .3227245
                 18  |   .0474451   .1317335     0.36   0.719    -.2114335    .3063237
                 19  |   .1131747   .1829626     0.62   0.537    -.2463776    .4727271
                 20  |   -.189771   .1195843    -1.59   0.113    -.4247742    .0452322
                 21  |  -.1305493   .1112797    -1.17   0.241    -.3492327    .0881341
                 22  |  -.1091228   .1394027    -0.78   0.434    -.3830725    .1648269
                 23  |   .0783809   .1578123     0.50   0.620    -.2317467    .3885086
                 24  |  -.1745129   .1015761    -1.72   0.086     -.374127    .0251012
                 25  |  -.0655963   .1928929    -0.34   0.734    -.4446634    .3134708
                 26  |  -.0514218   .1305443    -0.39   0.694    -.3079633    .2051196
                 27  |   .0531983   .1167084     0.46   0.649    -.1761532    .2825499
                 28  |  -.1240193   .1327934    -0.93   0.351    -.3849808    .1369422
                 29  |  -.0954574   .1609571    -0.59   0.553    -.4117653    .2208505
                 30  |  -.1799296   .1283232    -1.40   0.162    -.4321063    .0722471
                 31  |  -.1120499   .1172216    -0.96   0.340    -.3424101    .1183104
                 32  |   .0694667   .1611438     0.43   0.667     -.247208    .3861413
                 33  |   .0560435    .166368     0.34   0.736    -.2708977    .3829846
                 34  |   .0018361   .1196153     0.02   0.988    -.2332282    .2369004
                 35  |   .0577946   .1551659     0.37   0.710    -.2471326    .3627217
                 36  |  -.4621035   .1629334    -2.84   0.005     -.782295    -.141912
                 37  |   .1129081   .2028406     0.56   0.578    -.2857078     .511524
                 38  |  -.0122633   .1247676    -0.10   0.922    -.2574527    .2329261
                 39  |  -.1969665   .1141827    -1.73   0.085    -.4213547    .0274217
                 40  |   .2244004   .1926922     1.16   0.245    -.1542722    .6030729
                 41  |   .2039286   .1998806     1.02   0.308    -.1888706    .5967277
                 42  |  -.2274981   .1022853    -2.22   0.027    -.4285059   -.0264903
                 43  |   .1804178   .1357542     1.33   0.185    -.0863621    .4471976
                 44  |   -.217986   .1248449    -1.75   0.081    -.4633273    .0273554
                 45  |   .1387278   .1819521     0.76   0.446    -.2188387    .4962943
                 46  |  -.1330853   .1013107    -1.31   0.190    -.3321779    .0660074
                 47  |  -.1849615   .1036917    -1.78   0.075    -.3887332    .0188101
                 48  |  -.0882266   .1088925    -0.81   0.418    -.3022187    .1257656
                 49  |   -.119241   .0931294    -1.28   0.201    -.3022559    .0637739
                 50  |   .1521085   .1958487     0.78   0.438    -.2327671    .5369841
                 51  |   -.211424   .1319087    -1.60   0.110    -.4706468    .0477989
                 52  |   .0760409   .1366742     0.56   0.578     -.192547    .3446288
                 53  |   .0548175   .1212921     0.45   0.652    -.1835419    .2931769
                 54  |   .0380241   .1340204     0.28   0.777    -.2253486    .3013967
                 55  |   .2472499    .312324     0.79   0.429    -.3665193    .8610192
                 56  |   -.076495   .1036926    -0.74   0.461    -.2802686    .1272785
                 57  |   -.011134   .1129377    -0.10   0.922    -.2330755    .2108076
                 58  |   .0009457   .1481525     0.01   0.995    -.2901989    .2920902
                 59  |   .1179909   .1089414     1.08   0.279    -.0960974    .3320791
                 60  |  -.1371243   .1153977    -1.19   0.235    -.3639003    .0896516
                 61  |  -.0958465    .099463    -0.96   0.336    -.2913081    .0996152
                 62  |    .146384   .1645385     0.89   0.374    -.1769619    .4697299
                 63  |  -.3517004   .1430039    -2.46   0.014    -.6327271   -.0706738
                 64  |   .0785623    .169338     0.46   0.643    -.2542153    .4113399
                 65  |   .0883213   .1752025     0.50   0.614     -.255981    .4326237
                 66  |  -.1588166   .1429613    -1.11   0.267    -.4397596    .1221264
                 67  |   .3281458   .2203723     1.49   0.137     -.104923    .7612145
                 68  |  -.2390496   .1534602    -1.56   0.120    -.5406248    .0625255
                 69  |  -.2080735   .1132986    -1.84   0.067    -.4307245    .0145774
                 70  |  -.1627025   .1043485    -1.56   0.120    -.3677648    .0423599
                 71  |  -.1923052   .1025127    -1.88   0.061      -.39376    .0091495
                 72  |   .0978864   .1998232     0.49   0.624    -.2947999    .4905727
                 73  |  -.2119449   .1373973    -1.54   0.124    -.4819537    .0580639
                 74  |   -.045933   .1017244    -0.45   0.652    -.2458387    .1539726
                 75  |  -.1109454   .1024858    -1.08   0.280    -.3123473    .0904565
                 76  |   .0346132   .1362435     0.25   0.800    -.2331283    .3023547
                 77  |    .030702   .0904099     0.34   0.734    -.1469687    .2083726
                 78  |   .1450491   .1713988     0.85   0.398    -.1917784    .4818766
                 79  |  -.2445013    .119748    -2.04   0.042    -.4798262   -.0091763
                 80  |  -.1153298   .0962545    -1.20   0.231     -.304486    .0738265
                 81  |  -.1811491   .1210509    -1.50   0.135    -.4190345    .0567364
                 82  |    .187199   .2518328     0.74   0.458    -.3076949    .6820929
                 83  |  -.0328778   .1152103    -0.29   0.775    -.2592855    .1935299
                 84  |   .0373874   .1222552     0.31   0.760    -.2028647    .2776396
                 85  |   .0945172     .14233     0.66   0.507    -.1851852    .3742197
                 86  |   .1603459   .2021749     0.79   0.428    -.2369617    .5576536
                 87  |   .1695656   .1902668     0.89   0.373    -.2043407    .5434719
                 88  |   .0537142   .1625898     0.33   0.741    -.2658021    .3732305
                 89  |  -.4377228   .1791594    -2.44   0.015    -.7898012   -.0856444
                 90  |  -.0972459   .1467031    -0.66   0.508    -.3855422    .1910503
                 91  |   -.432329   .1709619    -2.53   0.012     -.768298   -.0963601
                 92  |  -.2886952   .1839772    -1.57   0.117    -.6502413    .0728509
                 93  |   .2189444    .207467     1.06   0.292    -.1887632    .6266521
                 94  |  -.0731296   .1368757    -0.53   0.593    -.3421134    .1958541
                 95  |  -.2033389   .1233175    -1.65   0.100    -.4456787    .0390008
                 96  |   .2295656    .214939     1.07   0.286    -.1928257    .6519569
                 97  |   .1539901   .1735061     0.89   0.375    -.1869787    .4949589
                 98  |  -.1097122   .1501563    -0.73   0.465    -.4047945    .1853702
                 99  |  -.2204389   .1188276    -1.86   0.064    -.4539552    .0130775
                100  |    .058274   .1111775     0.52   0.600    -.1602086    .2767565
                101  |  -.0139588   .0918845    -0.15   0.879    -.1945274    .1666098
                102  |  -.3098431    .134527    -2.30   0.022    -.5742115   -.0454748
                103  |  -.3786854   .1405813    -2.69   0.007    -.6549513   -.1024195
                104  |  -.3601789   .1595082    -2.26   0.024    -.6736394   -.0467184
                105  |  -.5829487   .2156984    -2.70   0.007    -1.006832   -.1590649
                106  |  -.1918637   .1731304    -1.11   0.268    -.5320941    .1483666
                107  |  -.2754172   .2114836    -1.30   0.193    -.6910182    .1401838
                108  |  -.5198031   .2396777    -2.17   0.031    -.9908102   -.0487959
                109  |  -.0582931   .1237696    -0.47   0.638    -.3015213     .184935
                110  |  -.0143063   .1073836    -0.13   0.894    -.2253332    .1967207
                111  |  -.0578274   .1152043    -0.50   0.616    -.2842234    .1685685
                112  |  -.0363783   .1164905    -0.31   0.755    -.2653017    .1925451
                113  |  -.1281844   .1265843    -1.01   0.312     -.376944    .1205751
                114  |  -.0482467   .1479883    -0.33   0.745    -.3390687    .2425752
                115  |   .0007824    .111764     0.01   0.994    -.2188527    .2204175
                116  |  -.0213621   .0985384    -0.22   0.828    -.2150066    .1722825
                117  |  -.0335467   .0986006    -0.34   0.734    -.2273134    .1602201
                118  |   .0995199   .0837558     1.19   0.235    -.0650743    .2641142
                119  |  -.1028155   .1214693    -0.85   0.398    -.3415232    .1358921
                120  |  -.0898806   .1128328    -0.80   0.426    -.3116161     .131855
                121  |  -.1221363   .1107666    -1.10   0.271    -.3398112    .0955387
                122  |  -.0695613   .1179351    -0.59   0.556    -.3013236     .162201
                123  |  -.2156587   .1184343    -1.82   0.069     -.448402    .0170846
                124  |  -.5070985   .1990999    -2.55   0.011    -.8983635   -.1158336
                125  |  -.2471386   .1402292    -1.76   0.079    -.5227126    .0284353
                126  |  -.3741152   .1782221    -2.10   0.036    -.7243516   -.0238789
                127  |  -.3558652   .1997056    -1.78   0.075    -.7483203    .0365899
                128  |  -.2319358     .12087    -1.92   0.056    -.4694657     .005594
                129  |  -.3654399   .2424295    -1.51   0.132    -.8418546    .1109749
                130  |  -.3891675   .2588038    -1.50   0.133    -.8977606    .1194257
                131  |  -.0717827     .10572    -0.68   0.497    -.2795403    .1359748
                132  |  -.1216998   .1172277    -1.04   0.300    -.3520719    .1086723
                133  |   .0041288   .1323812     0.03   0.975    -.2560226    .2642803
                134  |   .2516704   .1398313     1.80   0.073    -.0231218    .5264625
                135  |  -.0935282   .0845209    -1.11   0.269    -.2596261    .0725696
                136  |  -.2371663   .1395315    -1.70   0.090    -.5113692    .0370365
                137  |  -.2474227   .1188542    -2.08   0.038    -.4809911   -.0138542
                138  |  -.0144718   .1459152    -0.10   0.921    -.3012199    .2722762
                139  |  -.1841477   .0972079    -1.89   0.059    -.3751776    .0068821
                140  |  -.2335365   .1131343    -2.06   0.040    -.4558644   -.0112087
                     |
               _cons |   1.702652   1.052304     1.62   0.106    -.3653019    3.770606
        ------------------------------------------------------------------------------
        Instrumented:  L.n
        Instruments:   L2.n w L.w k L.k L2.k ys L.ys L2.ys yr1981 yr1982 yr1983
                       yr1984 2.id 3.id 4.id 5.id 6.id 7.id 8.id 9.id 10.id 11.id
                       12.id 13.id 14.id 15.id 16.id 17.id 18.id 19.id 20.id 21.id
                       22.id 23.id 24.id 25.id 26.id 27.id 28.id 29.id 30.id 31.id
                       32.id 33.id 34.id 35.id 36.id 37.id 38.id 39.id 40.id 41.id
                       42.id 43.id 44.id 45.id 46.id 47.id 48.id 49.id 50.id 51.id
                       52.id 53.id 54.id 55.id 56.id 57.id 58.id 59.id 60.id 61.id
                       62.id 63.id 64.id 65.id 66.id 67.id 68.id 69.id 70.id 71.id
                       72.id 73.id 74.id 75.id 76.id 77.id 78.id 79.id 80.id 81.id
                       82.id 83.id 84.id 85.id 86.id 87.id 88.id 89.id 90.id 91.id
                       92.id 93.id 94.id 95.id 96.id 97.id 98.id 99.id 100.id 101.id
                       102.id 103.id 104.id 105.id 106.id 107.id 108.id 109.id
                       110.id 111.id 112.id 113.id 114.id 115.id 116.id 117.id
                       118.id 119.id 120.id 121.id 122.id 123.id 124.id 125.id
                       126.id 127.id 128.id 129.id 130.id 131.id 132.id 133.id
                       134.id 135.id 136.id 137.id 138.id 139.id 140.id L3.n
        
        .
        Last edited by Andrew Musau; 28 Mar 2020, 07:34.

        Comment


        • #5
          Andrew Musau Thank you so much for your answer but I am a bit confused as I am not an expert in Stata.
          Before I used the command:
          xtivreg lngdp (tariff=tariff_L1), fe


          So, now, should I use this?
          ivregress 2sls lngdp (tariff=tariff_L1) i.id, small

          Comment


          • #6
            Katerina: Unfortunately, Stata has not incorporated some simple tests for endogeneity for xtivregress. But it is easy to obtain a control function version of the test, and also make it robust to serial correlation and heteroskedasticity, as you should. To obtain the FEIV estimates and proper standard errors, with w endogenous:

            Code:
            xtivreg y (w = z1 ... zM) x1 ... xK i.year, vce(cluster id)
            x1 ... xK are included exogenous variables, z1 ... zM are excluded instruments. Here is how to test the null that w is exogenous:

            Code:
            xtreg w z1 ... zM x1 ... xK i.year
            predict vhat, e
            xtreg y w vhat x1 ... xK i.year, vce(cluster id)
            The robust t statistic on vhat is the test of the null that w is exogenous. This test is described in Chapter 11 of my 2010 MIT Press book. As a check that you did it properly, the second xtreg command should produce the same estimates as xtivreg (except for the coefficient on vhat, of course, since there is no comparable coefficient with xtivreg). If the panel is unbalanced you have to be careful to use only the complete cases in the two xtreg commands.

            Andrew's idea probably works, too, but I'm hesitant to just add dummies and use traditional commands.

            Comment


            • #7
              xtivreg lngdp (tariff=tariff_L1), fe

              So, now, should I use this?
              ivregress 2sls lngdp (tariff=tariff_L1) i.id, small
              Yes, make sure you get the same estimates for the regression coefficients (see #4). You should implement Jeff Wooldridge's approach and only use this as a check, but I think the results will be consistent.

              Comment


              • #8
                Jeff Wooldridge Thank you so much for your answer, I really appreciate it.
                I have tried everything you said and for vhat I got:
                | Robust
                lngdp | Coef. Std. Err. z P>|z| [95% Conf. Interval]
                -------------+----------------------------------------------------------------
                vhat | .0069672 .0056433 1.23 0.217 -.0040935 .0180279

                Is this a good thing? I am not completely sure.

                Comment


                • #9
                  Andrew Musau Thank you for your answer.
                  Unfortunately, I have tried both commands in
                  #5 and
                  the first gives me a negative coefficient and the second one gives me a positive one.
                  What I prefer is the negative one. Is there something I can do about it?
                  I like the idea using the postestimation tests after the ivregress but I get a positive coefficient.

                  Comment


                  • #10
                    Unfortunately, I have tried both commands in
                    #5 and
                    the first gives me a negative coefficient and the second one gives me a positive one.

                    Something is not right. You should get the same coefficient. Can you copy and paste all the commands that you entered (including the xtset) and the regression outputs. Post this between CODE delimiters

                    \(\text{[CODE ]}\)
                    STATA OUTPUT
                    \(\text{[/CODE ]}\)

                    Comment


                    • #11

                      Andrew Musau , you can find them below.


                      Code:
                       xtset ifscode year
                             panel variable:  ifscode (strongly balanced)
                              time variable:  year, 1960 to 2014
                                      delta:  1 unit
                      
                      . gen lngdp = ln(ngdp_r)
                      (45 missing values generated)
                      
                      . gen tariff_L1=tariff[_n-1]
                      (374 missing values generated)
                      
                      
                      . xtivreg lngdp (tariff=tariff_L1) ,fe
                      
                      Fixed-effects (within) IV regression            Number of obs     =      1,303
                      Group variable: ifscode                         Number of groups  =         31
                      
                      R-sq:                                           Obs per group:
                           within  = 0.4551                                         min =         12
                           between = 0.0795                                         avg =       42.0
                           overall = 0.0029                                         max =         55
                      
                                                                      Wald chi2(1)      =  356535.87
                      corr(u_i, Xb)  = -0.2300                        Prob > chi2       =     0.0000
                      
                      ------------------------------------------------------------------------------
                             lngdp |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
                      -------------+----------------------------------------------------------------
                            tariff |  -.0649125   .0020939   -31.00   0.000    -.0690166   -.0608084
                             _cons |   6.633049   .0162812   407.40   0.000     6.601138     6.66496
                      -------------+----------------------------------------------------------------
                           sigma_u |  2.6785784
                           sigma_e |  .37814296
                               rho |  .98045962   (fraction of variance due to u_i)
                      ------------------------------------------------------------------------------
                      F  test that all u_i=0:     F(30,1271) =  1835.74         Prob > F    = 0.0000
                      ------------------------------------------------------------------------------
                      Instrumented:   tariff
                      Instruments:    tariff_L1
                      ------------------------------------------------------------------------------
                      
                      
                      
                      
                      
                      
                      . ivregress 2sls lngdp (tariff=tariff_L1) i.year, small
                      
                      
                      Instrumental variables (2SLS) regression
                      
                            Source |       SS       df       MS         Number of obs   =      1,303
                      -------------+------------------------------      F( 55,  1247)   =       1.33
                             Model |  446.622692    55  8.12041259      Prob > F        =     0.0579
                          Residual |  7691.93207  1247   6.1683497      R-squared       =     0.0549
                      -------------+------------------------------      Adj R-squared   =     0.0132
                             Total |  8138.55476  1302  6.25081011      Root MSE        =     2.4836
                      
                      ------------------------------------------------------------------------------
                             lngdp |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
                      -------------+----------------------------------------------------------------
                            tariff |   .0788904    .012817     6.16   0.000     .0537452    .1040356
                                   |
                              year |
                             1961  |   .8159265   1.052261     0.78   0.438    -1.248471    2.880324
                             1962  |   .9066259   1.052922     0.86   0.389    -1.159069     2.97232
                             1963  |   1.022899   1.054032     0.97   0.332    -1.044974    3.090771
                             1964  |   1.129749   1.055028     1.07   0.284    -.9400761    3.199574
                             1965  |    1.17065   1.054509     1.11   0.267    -.8981581    3.239458
                             1966  |   1.300966    1.05629     1.23   0.218    -.7713353    3.373268
                             1967  |   1.350423   1.056441     1.28   0.201    -.7221758    3.423022
                             1968  |   1.438245   1.057128     1.36   0.174    -.6357014    3.512192
                             1969  |   1.584886   1.059023     1.50   0.135    -.4927783     3.66255
                             1970  |    1.70358   1.060723     1.61   0.109     -.377418    3.784578
                             1971  |   1.813983    1.06223     1.71   0.088    -.2699728    3.897938
                             1972  |   1.839835   1.042215     1.77   0.078    -.2048535    3.884524
                             1973  |   1.878615   1.041403     1.80   0.071    -.1644813     3.92171
                             1974  |   1.969647   1.028279     1.92   0.056     -.047701    3.986994
                             1975  |   1.902601   1.025975     1.85   0.064    -.1102258    3.915428
                             1976  |   1.906318   1.024307     1.86   0.063     -.103237    3.915873
                             1977  |   1.924006   1.015972     1.89   0.058    -.0691979    3.917209
                             1978  |   2.051024    1.01865     2.01   0.044     .0525668     4.04948
                             1979  |   2.163197   1.020961     2.12   0.034      .160207    4.166187
                             1980  |   2.255895   1.023258     2.20   0.028     .2483981    4.263391
                             1981  |   2.044908   1.016989     2.01   0.045     .0497101    4.040105
                             1982  |   2.138942   1.012479     2.11   0.035     .1525929    4.125292
                             1983  |   2.165623   1.003052     2.16   0.031     .1977681    4.133478
                             1984  |   2.219384   1.003405     2.21   0.027     .2508366    4.187932
                             1985  |   2.297833   1.005184     2.29   0.022     .3257952    4.269872
                             1986  |   2.290426   1.003539     2.28   0.023     .3216143    4.259238
                             1987  |   2.302778   1.002334     2.30   0.022     .3363314    4.269225
                             1988  |   2.538044   1.009816     2.51   0.012     .5569183    4.519169
                             1989  |   2.522015   .9836492     2.56   0.010      .592225    4.451805
                             1990  |   2.572993   .9783864     2.63   0.009     .6535278    4.492458
                             1991  |   2.602052   .9791122     2.66   0.008     .6811634    4.522941
                             1992  |   2.642177   .9804672     2.69   0.007     .7186299    4.565725
                             1993  |   2.680798   .9815611     2.73   0.006     .7551042    4.606491
                             1994  |   2.718264   .9813699     2.77   0.006      .792946    4.643583
                             1995  |   2.651862   .9768231     2.71   0.007     .7354635     4.56826
                             1996  |   2.798248   .9816321     2.85   0.004      .872415    4.724081
                             1997  |   2.881779   .9835265     2.93   0.003     .9522297    4.811328
                             1998  |   2.939394   .9847516     2.98   0.003     1.007441    4.871347
                             1999  |   3.006955    .985953     3.05   0.002     1.072646    4.941265
                             2000  |   3.039028   .9852042     3.08   0.002     1.106187    4.971869
                             2001  |   3.011187   .9830183     3.06   0.002     1.082634    4.939739
                             2002  |   3.081831   .9851914     3.13   0.002     1.149015    5.014647
                             2003  |   3.111047   .9854794     3.16   0.002     1.177667    5.044428
                             2004  |   3.158497   .9858609     3.20   0.001     1.224368    5.092626
                             2005  |   3.213008   .9867248     3.26   0.001     1.277184    5.148832
                             2006  |   3.259604   .9869905     3.30   0.001     1.323259     5.19595
                             2007  |   3.305041   .9871903     3.35   0.001     1.368304    5.241778
                             2008  |    3.32016   .9876214     3.36   0.001     1.382577    5.257743
                             2009  |   3.278594   .9875772     3.32   0.001     1.341098     5.21609
                             2010  |   3.305102   .9910403     3.33   0.001     1.360812    5.249393
                             2011  |   3.335885   .9916146     3.36   0.001     1.390468    5.281303
                             2012  |   3.430579    .992699     3.46   0.001     1.483034    5.378123
                             2013  |   3.425289   .9920791     3.45   0.001     1.478961    5.371618
                             2014  |   4.583692   1.058543     4.33   0.000      2.50697    6.660414
                                   |
                             _cons |   3.219413    .889112     3.62   0.000     1.475092    4.963733
                      ------------------------------------------------------------------------------
                      Instrumented:  tariff
                      Instruments:   1961.year 1962.year 1963.year 1964.year 1965.year 1966.year
                                     1967.year 1968.year 1969.year 1970.year 1971.year 1972.year
                                     1973.year 1974.year 1975.year 1976.year 1977.year 1978.year
                                     1979.year 1980.year 1981.year 1982.year 1983.year 1984.year
                                     1985.year 1986.year 1987.year 1988.year 1989.year 1990.year
                                     1991.year 1992.year 1993.year 1994.year 1995.year 1996.year
                                     1997.year 1998.year 1999.year 2000.year 2001.year 2002.year
                                     2003.year 2004.year 2005.year 2006.year 2007.year 2008.year
                                     2009.year 2010.year 2011.year 2012.year 2013.year 2014.year
                                     tariff_L1

                      Comment


                      • #12
                        Katerina: You have a couple of mistakes. First, you will want to put i.year in the xtivreg command. What xtivreg does is account for cross-sectional fixed effects. Second, you forgot i.id in the ivregress command. That is how you include the cross-sectional fixed effects. So, the way to do this, generically, is

                        Code:
                        xtset ifscode year
                        xtivreg y (w = z1 ... zM) x1 ... xK i.year, fe
                        ivregress 2sls y (w = z1 ... zM) x1 ... xK i.year i.ifscode
                        The standard errors might not be the same because of different conventions with degrees of freedom, but the estimates should be.

                        Your results from xtivreg are not believable until you include id.year and also cluster the standard errors. Even then, it seems odd you don't have more control variables.

                        And I just noticed that your T is bigger than your N. This is not the traditional panel data setup, and computing standard errors can be tricky. Is this a research project for a dissertation?

                        Comment


                        • #13
                          Jeff Wooldridge Thank you very much for the code. Now I get the same coefficients!

                          Yes, T is bigger than N...I thought that this was ok but it seems it isn't...Should I proceed with the IV estimation?
                          and yes this a research project for an undergraduate dissertation.

                          Comment


                          • #14
                            Using the estimator is fine. although there may be problems with unit roots. But clustering by ifscode when N = 31 is borderline.

                            Comment


                            • #15
                              Jeff Wooldridge I will definitely have this in mind now. Thank you very much!

                              Comment

                              Working...
                              X