Announcement

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

  • Testing for endogeneity panel data

    Hello!
    I have run the command xtivreg2 y x1 x2 (x3=z) i.year, fe endog(x3)
    It appeared the following error "factor variables not allowed".
    I have taken out the variable "i.year" and could get now the results. Nevertheless, I need the dummy variable for the year to control for year effects.
    How can I overcome this situation?

    Thank you!

  • #2
    Francisco:
    the user-written programme -xtivreg2- does not support -fvvarlist- notation; hence, you have to prefix your code with -xi-.
    Code:
    xi: xtivreg2 y x1 x2 (x3=z) i.year, fe endog(x3)
    Otherwise, you can consider using the built-in command -xtivreg-, which allows factor variables notation (I presume that you use Stata 15; otherwise, as per FAQ, you have to tell the list which Stata release supports your analyses):
    Code:
    use http://www.stata-press.com/data/r14/nlswork
    . xtreg ln_w age c.age#c.age tenure i.not_smsa i.union i.south, fe
    
    Fixed-effects (within) regression               Number of obs     =     19,007
    Group variable: idcode                          Number of groups  =      4,134
    
    R-sq:                                           Obs per group:
         within  = 0.1333                                         min =          1
         between = 0.2375                                         avg =        4.6
         overall = 0.2031                                         max =         12
    
                                                    F(6,14867)        =     381.19
    corr(u_i, Xb)  = 0.2074                         Prob > F          =     0.0000
    
    ------------------------------------------------------------------------------
         ln_wage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
             age |   .0311984   .0033902     9.20   0.000     .0245533    .0378436
                 |
     c.age#c.age |  -.0003457   .0000543    -6.37   0.000    -.0004522   -.0002393
                 |
          tenure |   .0176205   .0008099    21.76   0.000     .0160331    .0192079
      1.not_smsa |  -.0972535   .0125377    -7.76   0.000    -.1218289    -.072678
         1.union |   .0975672   .0069844    13.97   0.000     .0838769    .1112576
         1.south |  -.0620932    .013327    -4.66   0.000    -.0882158   -.0359706
           _cons |   1.091612   .0523126    20.87   0.000     .9890729    1.194151
    -------------+----------------------------------------------------------------
         sigma_u |   .3910683
         sigma_e |  .25545969
             rho |  .70091004   (fraction of variance due to u_i)
    ------------------------------------------------------------------------------
    F test that all u_i=0: F(4133, 14867) = 8.31                 Prob > F = 0.0000
    
    . xtivreg ln_w age c.age#c.age i.not_smsa (tenure = i.union i.south), fe
    
    Fixed-effects (within) IV regression            Number of obs     =     19,007
    Group variable: idcode                          Number of groups  =      4,134
    
    R-sq:                                           Obs per group:
         within  =      .                                         min =          1
         between = 0.1304                                         avg =        4.6
         overall = 0.0897                                         max =         12
    
                                                    Wald chi2(4)      =  147926.58
    corr(u_i, Xb)  = -0.6843                        Prob > chi2       =     0.0000
    
    ------------------------------------------------------------------------------
         ln_wage |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
          tenure |   .2403531   .0373419     6.44   0.000     .1671643    .3135419
             age |   .0118437   .0090032     1.32   0.188    -.0058023    .0294897
                 |
     c.age#c.age |  -.0012145   .0001968    -6.17   0.000    -.0016003   -.0008286
                 |
      1.not_smsa |  -.0167178   .0339236    -0.49   0.622    -.0832069    .0497713
           _cons |   1.678287   .1626657    10.32   0.000     1.359468    1.997106
    -------------+----------------------------------------------------------------
         sigma_u |  .70661941
         sigma_e |  .63029359
             rho |  .55690561   (fraction of variance due to u_i)
    ------------------------------------------------------------------------------
    F  test that all u_i=0:     F(4133,14869) =     1.44      Prob > F    = 0.0000
    ------------------------------------------------------------------------------
    Instrumented:   tenure
    Instruments:    age c.age#c.age 1.not_smsa 1.union 1.south
    ------------------------------------------------------------------------------
    Last edited by Carlo Lazzaro; 21 Jul 2017, 00:44.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Dear Carlo,
      Thank you for your answer. I was able to get the results. However, I am having some doubts when interpreting the results.
      It got this:
      -------------------------------------------------------------------------------------
      Underidentification test (Anderson canon. corr. LM statistic): 8.506
      Chi-sq(1) P-val = 0.0035
      ------------------------------------------------------------------------------
      Weak identification test (Cragg-Donald Wald F statistic): 8.181
      Stock-Yogo weak ID test critical values: 10% maximal IV size 16.38
      15% maximal IV size 8.96
      20% maximal IV size 6.66
      25% maximal IV size 5.53
      Source: Stock-Yogo (2005). Reproduced by permission.
      ------------------------------------------------------------------------------
      Sargan statistic (overidentification test of all instruments): 0.000
      (equation exactly identified)
      -endog- option:
      Endogeneity test of endogenous regressors: 0.365
      Chi-sq(1) P-val = 0.5457
      Regressors tested: unem
      ------------------------------------------------------------------------------
      Instrumented: unem
      Included instruments: materialdeprivation pop inc dens lprisoners _Iyear_2008
      _Iyear_2009 _Iyear_2010 _Iyear_2011 _Iyear_2012
      _Iyear_2013 _Iyear_2014 _Iyear_2015
      Excluded instruments: bankrupt
      ------------------------------------------------------------------------------

      Looking at this results, I think that the p-value obtained for the endogeneity test cannot reject the null hypothesis that the variable is exogenous.
      But I don't know how to interpret the results regarding the weak identification test.

      Thank you very much.

      Best Regards,
      Francisco Nobre

      Comment


      • #4
        Francisco:
        the topics you're interested in are comprehensively covered under -ivregress postestimation- Example 3, Stata .pdf manual.

        -
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment

        Working...
        X