Announcement

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

  • xtivreg re, weakiv and xtoverid

    Dear all,

    Currently, I am running into some trouble with xtivreg in combination with random effects.

    I am researching the effect of bilateral tax treaties on FDI inflow, with several control variables and fixed effects for the source and resident country and year. As instruments I am using two dummies on common language and colonial relationship, a continuous variable on the number of treaties closed prior to the year of interest and the GDP of the source country. My regression is formulated as follows:
    Code:
    xtivreg ln_FDI (tt_d= comlang_off colony treaties_s ln_GDP_1) ln_Openness_1 ln_GDP_pc_1 ln_Telephone_1 PS_1 ln_Gov_exp_1 ln_GDP_Growth_1 ln_av_CPI_5 ln_M2_growth_1 i.Country_e i.cou_e i.year, re first

    I want to test whether my instruments are weak or overidentified. However, the commands
    Code:
    weakivtest
    and
    Code:
    xtoverid
    do not appear to work in combination with re.


    With regards to weakiv I get the following error:
    error - unsupported xtivreg model g2sls
    r(198);

    Does anyone know how to circumvent this/knows of a different command that allows for testing weak iv for re models?


    With regards to xtoverid, I have already tried to circumvent the issue of xtoverid being unable to deal with factor variables (my fixed effect variables) by coding the following:

    Code:
    fvrevar i.Country_e i.cou_e i.year
    xi: xtivreg ln_FDI (tt_d= comlang_off colony treaties_s ln_GDP_1) ln_Openness_1 ln_GDP_pc_1 ln_Telephone_1 PS_1 ln_Gov_exp_1 ln_GDP_Growth_1 ln_av_CPI_5 ln_M2_growth_1 `r(varlist)', re first
    xtoverid, cluster(country_pair_c)
    However, I run into the problem that because of collinearity lot of factor variable dummies made by xi: are dropped in the second stage. This leads Stata to give the following error after xtoverid:
    o. operator not allowed
    r(101);

    Does anyone know how to solve this?



    I am using StataMP 17 (64-bit) on a Windows10 Enterprise OS.

    My data looks as follows;

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    
    input float(ln_FDI tt_d) double Openness_1 float(ln_GDP_pc_1 ln_Telephone_1) double PS_1 float(ln_Gov_exp_1 ln_GDP_Growth_1 ln_av_CPI_5 ln_M2_growth_1) double(Source WHTrates PE Other UN) byte(comlang_off colony) int treaties_s float ln_GDP_1
             0 0 . 6.931498    .317376 -2.671054 .  1.554339 2.1304839  2.970524 . . . . . 0 0 .  24.31324
             0 0 . 7.013929   .3144341 -2.571222 . 1.1674504 2.1967888 1.8431436 . . . . . 0 0 .  24.36789
             0 0 . 6.931498    .317376 -2.671054 .  1.554339 2.1304839  2.970524 . . . . . 0 0 .  24.31324
             0 0 . 6.940572   .3216475 -2.801084 . 1.7004848 1.7526053 2.1170902 . . . . . 0 0 .  24.34779
             0 0 . 7.152811  .28499976 -2.418561 . 3.2403915 3.0799816 2.8629184 . . . . . 0 0 .   24.4075
             0 0 . 7.129804  .29258543 -2.519349 .  2.423923  2.570989 2.9896774 . . . . . 0 0 .  24.41944
             0 0 . 7.113506    .300889 -2.411068 .  1.727542  2.480182  2.793149 . . . . . 0 0 . 24.436697
             0 0 . 7.013929   .3144341 -2.571222 . 1.1674504 2.1967888 1.8431436 . . . . . 0 0 .  24.36789
             0 0 . 6.931498    .317376 -2.671054 .  1.554339 2.1304839  2.970524 . . . . . 0 0 .  24.31324
             0 0 . 6.940572   .3216475 -2.801084 . 1.7004848 1.7526053 2.1170902 . . . . . 0 0 .  24.34779
             0 0 . 6.878675   .3373562 -2.763864 . 1.0090588 1.5797658 1.6744245 . . . . . 0 0 .  24.30974
             0 0 . 6.896047   .3469158 -2.655531 . 2.0730472 1.7911087  2.441974 . . . . . 0 0 .  24.35024
             0 0 .  6.04682          . -2.296179 . 1.1461606         .         . . . . . . 0 0 .  23.07021
       1.65107 0 . 6.182219          . -2.070934 .  3.113687         .         . . . . . . 0 0 . 23.242435
     -2.401703 0 .  6.26809          . -2.221302 . 2.3802252         .         . . . . . . 0 0 . 23.358213
     1.1734915 0 . 6.578401          . -2.410581 .  3.321026         . 4.4403205 . . . . . 0 0 .  23.69346
             0 0 . 6.592124          . -2.690477 .  2.076356         . 4.1396933 . . . . . 0 0 .  23.72987
             0 0 . 6.773696 .018065697 -2.712689 . 3.7566414   3.08054 4.1912484 . . . . . 0 0 .  23.93541
             0 0 . 6.990822  .05691534 -2.579152 . 3.3589735  3.109101  3.987368 . . . . . 0 0 . 24.180004
    -3.0489736 0 . 7.075285  .04483942  -2.50206 .  .4143925   3.10329  3.752835 . . . . . 0 0 .   24.2959
      .7900314 0 . 7.152811  .28499976 -2.418561 . 3.2403915 3.0799816 2.8629184 . . . . . 0 0 .   24.4075
     -2.735222 0 . 7.129804  .29258543 -2.519349 .  2.423923  2.570989 2.9896774 . . . . . 0 0 .  24.41944
      .0842044 0 . 7.113506    .300889 -2.411068 .  1.727542  2.480182  2.793149 . . . . . 0 0 . 24.436697
     .03095823 0 . 7.013929   .3144341 -2.571222 . 1.1674504 2.1967888 1.8431436 . . . . . 0 0 .  24.36789
     1.1697117 0 . 6.931498    .317376 -2.671054 .  1.554339 2.1304839  2.970524 . . . . . 0 0 .  24.31324
     -.9001914 0 . 6.940572   .3216475 -2.801084 . 1.7004848 1.7526053 2.1170902 . . . . . 0 0 .  24.34779
      .3031813 0 . 6.878675   .3373562 -2.763864 . 1.0090588 1.5797658 1.6744245 . . . . . 0 0 .  24.30974
     -.7834536 0 . 6.896047   .3469158 -2.655531 . 2.0730472 1.7911087  2.441974 . . . . . 0 0 .  24.35024
             0 0 . 7.129804  .29258543 -2.519349 .  2.423923  2.570989 2.9896774 . . . . . 0 0 .  24.41944
    -1.7108308 0 . 7.113506    .300889 -2.411068 .  1.727542  2.480182  2.793149 . . . . . 0 0 . 24.436697
    -2.3509212 0 . 7.013929   .3144341 -2.571222 . 1.1674504 2.1967888 1.8431436 . . . . . 0 0 .  24.36789
             0 0 . 6.931498    .317376 -2.671054 .  1.554339 2.1304839  2.970524 . . . . . 0 0 .  24.31324
             0 0 . 6.940572   .3216475 -2.801084 . 1.7004848 1.7526053 2.1170902 . . . . . 0 0 .  24.34779
             0 0 . 6.878675   .3373562 -2.763864 . 1.0090588 1.5797658 1.6744245 . . . . . 0 0 .  24.30974
             0 0 . 6.896047   .3469158 -2.655531 . 2.0730472 1.7911087  2.441974 . . . . . 0 0 .  24.35024
             0 0 . 6.931498    .317376 -2.671054 .  1.554339 2.1304839  2.970524 . . . . . 0 0 .  24.31324
             0 0 .  6.04682          . -2.296179 . 1.1461606         .         . . . . . . 0 0 .  23.07021
             0 0 . 6.182219          . -2.070934 .  3.113687         .         . . . . . . 0 0 . 23.242435
             0 0 .  6.26809          . -2.221302 . 2.3802252         .         . . . . . . 0 0 . 23.358213
             0 0 . 6.592124          . -2.690477 .  2.076356         . 4.1396933 . . . . . 0 0 .  23.72987
             0 0 . 6.773696 .018065697 -2.712689 . 3.7566414   3.08054 4.1912484 . . . . . 0 0 .  23.93541
             0 0 . 6.990822  .05691534 -2.579152 . 3.3589735  3.109101  3.987368 . . . . . 0 0 . 24.180004
             0 0 . 7.075285  .04483942  -2.50206 .  .4143925   3.10329  3.752835 . . . . . 0 0 .   24.2959
             0 0 . 7.152811  .28499976 -2.418561 . 3.2403915 3.0799816 2.8629184 . . . . . 0 0 .   24.4075
             0 0 . 7.129804  .29258543 -2.519349 .  2.423923  2.570989 2.9896774 . . . . . 0 0 .  24.41944
             0 0 . 7.113506    .300889 -2.411068 .  1.727542  2.480182  2.793149 . . . . . 0 0 . 24.436697
             0 0 . 7.013929   .3144341 -2.571222 . 1.1674504 2.1967888 1.8431436 . . . . . 0 0 .  24.36789
             0 0 . 6.931498    .317376 -2.671054 .  1.554339 2.1304839  2.970524 . . . . . 0 0 .  24.31324
             0 0 . 6.940572   .3216475 -2.801084 . 1.7004848 1.7526053 2.1170902 . . . . . 0 0 .  24.34779
             0 0 . 6.878675   .3373562 -2.763864 . 1.0090588 1.5797658 1.6744245 . . . . . 0 0 .  24.30974
             0 0 . 6.896047   .3469158 -2.655531 . 2.0730472 1.7911087  2.441974 . . . . . 0 0 .  24.35024
             0 0 . 7.152811  .28499976 -2.418561 . 3.2403915 3.0799816 2.8629184 . . . . . 0 0 .   24.4075
             0 0 . 7.129804  .29258543 -2.519349 .  2.423923  2.570989 2.9896774 . . . . . 0 0 .  24.41944
             0 0 . 7.113506    .300889 -2.411068 .  1.727542  2.480182  2.793149 . . . . . 0 0 . 24.436697
             0 0 . 6.931498    .317376 -2.671054 .  1.554339 2.1304839  2.970524 . . . . . 0 0 .  24.31324
             0 0 . 6.940572   .3216475 -2.801084 . 1.7004848 1.7526053 2.1170902 . . . . . 0 0 .  24.34779
             0 0 . 6.878675   .3373562 -2.763864 . 1.0090588 1.5797658 1.6744245 . . . . . 0 0 .  24.30974
             0 0 . 6.896047   .3469158 -2.655531 . 2.0730472 1.7911087  2.441974 . . . . . 0 0 .  24.35024
             0 0 . 7.113506    .300889 -2.411068 .  1.727542  2.480182  2.793149 . . . . . 0 0 . 24.436697
             0 0 . 7.013929   .3144341 -2.571222 . 1.1674504 2.1967888 1.8431436 . . . . . 0 0 .  24.36789
    -.56430537 0 . 6.896047   .3469158 -2.655531 . 2.0730472 1.7911087  2.441974 . . . . . 0 0 .  24.35024
             0 0 . 7.152811  .28499976 -2.418561 . 3.2403915 3.0799816 2.8629184 . . . . . 0 0 .   24.4075
             0 0 . 7.129804  .29258543 -2.519349 .  2.423923  2.570989 2.9896774 . . . . . 0 0 .  24.41944
             0 0 . 7.113506    .300889 -2.411068 .  1.727542  2.480182  2.793149 . . . . . 0 0 . 24.436697
             0 0 . 7.013929   .3144341 -2.571222 . 1.1674504 2.1967888 1.8431436 . . . . . 0 0 .  24.36789
             0 0 . 6.931498    .317376 -2.671054 .  1.554339 2.1304839  2.970524 . . . . . 0 0 .  24.31324
             0 0 . 6.940572   .3216475 -2.801084 . 1.7004848 1.7526053 2.1170902 . . . . . 0 0 .  24.34779
             0 0 . 6.878675   .3373562 -2.763864 . 1.0090588 1.5797658 1.6744245 . . . . . 0 0 .  24.30974
             0 0 . 6.896047   .3469158 -2.655531 . 2.0730472 1.7911087  2.441974 . . . . . 0 0 .  24.35024
             0 0 . 7.113506    .300889 -2.411068 .  1.727542  2.480182  2.793149 . . . . . 0 0 . 24.436697
             0 0 . 7.013929   .3144341 -2.571222 . 1.1674504 2.1967888 1.8431436 . . . . . 0 0 .  24.36789
             0 0 . 6.931498    .317376 -2.671054 .  1.554339 2.1304839  2.970524 . . . . . 0 0 .  24.31324
             0 0 . 6.940572   .3216475 -2.801084 . 1.7004848 1.7526053 2.1170902 . . . . . 0 0 .  24.34779
             0 0 . 6.878675   .3373562 -2.763864 . 1.0090588 1.5797658 1.6744245 . . . . . 0 0 .  24.30974
             0 0 . 6.896047   .3469158 -2.655531 . 2.0730472 1.7911087  2.441974 . . . . . 0 0 .  24.35024
             0 0 . 7.075285  .04483942  -2.50206 .  .4143925   3.10329  3.752835 . . . . . 0 0 .   24.2959
             0 0 . 7.152811  .28499976 -2.418561 . 3.2403915 3.0799816 2.8629184 . . . . . 0 0 .   24.4075
             0 0 . 7.129804  .29258543 -2.519349 .  2.423923  2.570989 2.9896774 . . . . . 0 0 .  24.41944
             0 0 . 7.113506    .300889 -2.411068 .  1.727542  2.480182  2.793149 . . . . . 0 0 . 24.436697
             0 0 . 7.013929   .3144341 -2.571222 . 1.1674504 2.1967888 1.8431436 . . . . . 0 0 .  24.36789
             0 0 . 6.931498    .317376 -2.671054 .  1.554339 2.1304839  2.970524 . . . . . 0 0 .  24.31324
             0 0 . 6.940572   .3216475 -2.801084 . 1.7004848 1.7526053 2.1170902 . . . . . 0 0 .  24.34779
             0 0 . 6.878675   .3373562 -2.763864 . 1.0090588 1.5797658 1.6744245 . . . . . 0 0 .  24.30974
             0 0 . 6.896047   .3469158 -2.655531 . 2.0730472 1.7911087  2.441974 . . . . . 0 0 .  24.35024
             0 0 . 7.152811  .28499976 -2.418561 . 3.2403915 3.0799816 2.8629184 . . . . . 0 0 .   24.4075
             0 0 . 7.129804  .29258543 -2.519349 .  2.423923  2.570989 2.9896774 . . . . . 0 0 .  24.41944
             0 0 . 7.113506    .300889 -2.411068 .  1.727542  2.480182  2.793149 . . . . . 0 0 . 24.436697
             0 0 . 7.013929   .3144341 -2.571222 . 1.1674504 2.1967888 1.8431436 . . . . . 0 0 .  24.36789
             0 0 . 6.931498    .317376 -2.671054 .  1.554339 2.1304839  2.970524 . . . . . 0 0 .  24.31324
             0 0 . 6.940572   .3216475 -2.801084 . 1.7004848 1.7526053 2.1170902 . . . . . 0 0 .  24.34779
             0 0 . 6.878675   .3373562 -2.763864 . 1.0090588 1.5797658 1.6744245 . . . . . 0 0 .  24.30974
             0 0 . 6.896047   .3469158 -2.655531 . 2.0730472 1.7911087  2.441974 . . . . . 0 0 .  24.35024
    -2.7105775 0 . 7.152811  .28499976 -2.418561 . 3.2403915 3.0799816 2.8629184 . . . . . 0 0 .   24.4075
      .9476042 0 . 7.129804  .29258543 -2.519349 .  2.423923  2.570989 2.9896774 . . . . . 0 0 .  24.41944
      .3676981 0 . 7.113506    .300889 -2.411068 .  1.727542  2.480182  2.793149 . . . . . 0 0 . 24.436697
     -.3913492 0 . 7.013929   .3144341 -2.571222 . 1.1674504 2.1967888 1.8431436 . . . . . 0 0 .  24.36789
     .06083497 0 . 6.931498    .317376 -2.671054 .  1.554339 2.1304839  2.970524 . . . . . 0 0 .  24.31324
    -.10954122 0 . 6.940572   .3216475 -2.801084 . 1.7004848 1.7526053 2.1170902 . . . . . 0 0 .  24.34779
     .06934997 0 . 6.878675   .3373562 -2.763864 . 1.0090588 1.5797658 1.6744245 . . . . . 0 0 .  24.30974
     .02848618 0 . 6.896047   .3469158 -2.655531 . 2.0730472 1.7911087  2.441974 . . . . . 0 0 .  24.35024
    end


    Thank you in advance!

    Kind regards,

    David




  • #2
    David:
    as far as the problem with the community-contributed module -xtoverid- is concerned, you should remove the omitted (o.) predictor(s) by hand, re-run the regression and finally invoke -xtoverid-.
    Last edited by Carlo Lazzaro; 27 Jul 2022, 12:25.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Dear Carlo,

      Thank you for your quick answer. The omitted predictors consist of dummies made for the different fixed effects, e.g., Zimbabwe or 2015 etc.
      Do I understand it correctly that I then have to delete these individual predictors in order to resolve the issue? Would that not partially beat the point of controlling for these fixed effects and/or limit what one can say about the full model with regards to overidentification and the strength of the iv?

      On an aside, the number of dummies (129) made for the fixed effects variables with
      Code:
       fvrevar i.Country_e i.cou_e i.year xi: xtivreg ln_FDI (tt_d= comlang_off colony treaties_s ln_GDP_1) ln_Openness_1 ln_GDP_pc_1 ln_Telephone_1 PS_1 ln_Gov_exp_1 ln_GDP_Growth_1 ln_av_CPI_5 ln_M2_growth_1 `r(varlist)', re first
      exceeds the total number of countries and years involved (198), should this be the case?

      Best,

      David
      Last edited by David Jacobsz; 27 Jul 2022, 13:40.

      Comment


      • #4
        David:
        yes, you're correct. There's no way to move forward with the community-contributed module -xtoverid- without deleting the -o.- culprit manually.
        The limitations you mention are the consequences of -xtoverid- being a glorious but a bit old-fashioned module (i sincerely hope that its Authors can find the time to update it, as it is a wonderful command).
        As far as your last question is concerned, I do not think that the number of categorical predictors (that you should better reduce anyway) has any bearing on that, as you ca see from the following toy-example:
        Code:
        . use "https://www.stata-press.com/data/r17/nlswork.dta"
        (National Longitudinal Survey of Young Women, 14-24 years old in 1968)
        
        . g race2=race
        
        . xi:xtreg ln_wage i.race i.race2 age, re
        i.race            _Irace_1-3          (naturally coded; _Irace_1 omitted)
        i.race2           _Irace2_1-3         (naturally coded; _Irace2_1 omitted)
        note: _Irace2_2 omitted because of collinearity.
        note: _Irace2_3 omitted because of collinearity.
        
        Random-effects GLS regression                   Number of obs     =     28,510
        Group variable: idcode                          Number of groups  =      4,710
        
        R-squared:                                      Obs per group:
             Within  = 0.1026                                         min =          1
             Between = 0.1032                                         avg =        6.1
             Overall = 0.0945                                         max =         15
        
                                                        Wald chi2(3)      =    3242.34
        corr(u_i, X) = 0 (assumed)                      Prob > chi2       =     0.0000
        
        ------------------------------------------------------------------------------
             ln_wage | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
        -------------+----------------------------------------------------------------
            _Irace_2 |  -.1209428   .0129079    -9.37   0.000    -.1462418   -.0956439
            _Irace_3 |   .0981941   .0538424     1.82   0.068    -.0073351    .2037233
           _Irace2_2 |          0  (omitted)
           _Irace2_3 |          0  (omitted)
                 age |    .018534    .000331    55.99   0.000     .0178852    .0191828
               _cons |    1.15423   .0118069    97.76   0.000     1.131089    1.177371
        -------------+----------------------------------------------------------------
             sigma_u |  .36581626
             sigma_e |  .30349389
                 rho |  .59231394   (fraction of variance due to u_i)
        ------------------------------------------------------------------------------
        
        . xtoverid
        o. operator not allowed
        r(101);
        
        .
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          Dear Carlo,

          Thank you for the response. The example is really helpful.

          On the reduction of categorical predictors, those are all countries and years involved as I would like to address unobserved country and year between variation (I have to use re, as the within variation of the data is very low. It's not perfect but have not found a way around this issue but using re with these fixed effects). So therefore, it feels odd to reduce this. Is it then better to use a different fixed effects variable, e,g, categories indicating which income group, as defined by the World Bank, countries are in? Then the number of categorical would be limited to 4 different income groups and 15 years instead of 114 countries and 15 years.


          Best,
          David

          Comment


          • #6
            David:
            yes, using World Bank categories instead of nations sounds helpful here.
            The only issue that may creep up with this fix is that you panel switch from a N>T to T:>N dataset.
            If this were the case, you should consider -xtgls- or -xtregar- instead on -xtreg-.
            Kind regards,
            Carlo
            (Stata 19.0)

            Comment


            • #7
              Dear Carlo,

              If I understand the commands -xtgls- and -xtregar- correctly, they do not allow for IV estimations. However, based on literature, I am quite certain that the tax treaty dummy is endogenous and should be replaced with one or more instruments.
              Therefore, I think these commands will be of no help.

              Would it be an option to maintain N>T by setting
              Code:
              xtset country_pairs year
              instead of setting it to
              Code:
              xtset income_level_pairs year
              ?

              In total there are 3615 country pairs and 15 years, whereas there are only 4 World Bank income levels in total and 6 World Bank income level pairs in my dataset.
              Or will it then be problematic to use the WB income level fixed effect?

              Best,
              David
              Last edited by David Jacobsz; 28 Jul 2022, 05:33. Reason: typo

              Comment


              • #8
                David:
                you're right that T>N panel command do not have -iv- cousins.
                That said, the first code can be the way to go, provided it is acceptable in your research field.
                Last edited by Carlo Lazzaro; 28 Jul 2022, 07:40.
                Kind regards,
                Carlo
                (Stata 19.0)

                Comment


                • #9
                  Dear Carlo,

                  Ok, thank you for helping out. Really appreciated!

                  Best,
                  David

                  Comment

                  Working...
                  X