Announcement

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

  • Two fixed effects in OLS and IV regression

    Hi everyone, I really need your help. I'm doing some OLS and IV regressions on stata and I have a problem with inserting fixed effects.

    The data I have available are:
    1) for each trio municipality sector year: the number of active companies
    2) coverage of the UBB network for each joint pair.

    The aim is to estimate the random effect of the UBB network on the log of active companies.
    I have to introduce 2 fixed effects:
    1) on a joint variable region-year
    2) on a joint variable municipality-sector.

    I used the areg + absorb command in OLS regress and it worked fine on single fixed effect.
    The problem is when I have to introduce all 2 of them into the same regression analysis. They told me to create the dummy vector for the joint variable region-year with the command "ta joint_region_year, generate (dummy_joint_region_year)" and to insert this vector inside the regression as a simple control variable and use absorb with the joint variable city-sector. I tried to add it using * (dummy_joint_region_year *) but the result is a regression with hundreds of lines and the robust standard error = 0. I also tried to use the xtset and xtreg commands, but I can't define the panel, I get the error 451: repeated time values ​​within panel.
    Also I don't know how to introduce the fixed effects into IV regression except with the xtivreg command (that I can't use for the same panel problem).

    I have been using stata for a few weeks, I don't have much time available and I don't know what to do.
    Thank you in advance.
    Last edited by Chiara Ricci; 25 Sep 2020, 13:49.

  • #2
    If you install reghdfe from SSC, you can absorb both fixed effects without having to create indicators.Same syntax as areg, except that you include absorb(FE_1 FE_2).

    Code:
    ssc install reghdfe

    Also, you have ivreghdfe, also from SSC for IV fixed effects absorbng indicators.

    Comment


    • #3
      Thank you for the answer. I installed reghdfe, but I get this error:

      Error: Stata versions 12 or earlier require the boottest package
      To install, from within Stata type

      I installed it with the command: ssc install boottest

      but if I try to use reghdfe the same error comes out again.

      Comment


      • #4
        Try running

        Code:
        mata mata mlib index

        and see if Stata can find the command. What version of Stata do you have?

        Comment


        • #5
          I have Stata 12. I entered your code but the reghdfe command keeps reporting the same error. If i look for the command in help i find it, but it still doesn't work.

          Comment


          • #6
            Try following the steps here.

            http://scorreia.com/software/reghdfe/install.html

            Once you do this, restart Stata and see if it solves the problem.

            Comment


            • #7
              You can also fit the model with the user written -ivreg2-, but be prepared to wait forever:

              Code:
              .  webuse nlswork, clear
              (National Longitudinal Survey.  Young Women 14-26 years of age in 1968)
              
              . ivreghdfe ln_wage ( tenure = age hours), absorb(idcode year)
              (dropped 556 singleton observations)
              (MWFE estimator converged in 8 iterations)
              
              IV (2SLS) estimation
              --------------------
              
              Estimates efficient for homoskedasticity only
              Statistics consistent for homoskedasticity only
              
                                                                    Number of obs =    27480
                                                                    F(  1, 23323) =     9.54
                                                                    Prob > F      =   0.0020
              Total (centered) SS     =  2127.693601                Centered R2   =   0.0268
              Total (uncentered) SS   =  2127.693601                Uncentered R2 =   0.0268
              Residual SS             =   2070.72438                Root MSE      =     .298
              
              ------------------------------------------------------------------------------
                   ln_wage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
              -------------+----------------------------------------------------------------
                    tenure |   .0262586   .0085027     3.09   0.002     .0095927    .0429245
              ------------------------------------------------------------------------------
              Underidentification test (Anderson canon. corr. LM statistic):         246.118
                                                                 Chi-sq(2) P-val =    0.0000
              ------------------------------------------------------------------------------
              Weak identification test (Cragg-Donald Wald F statistic):              105.383
              Stock-Yogo weak ID test critical values: 10% maximal IV size             19.93
                                                       15% maximal IV size             11.59
                                                       20% maximal IV size              8.75
                                                       25% maximal IV size              7.25
              Source: Stock-Yogo (2005).  Reproduced by permission.
              ------------------------------------------------------------------------------
              Sargan statistic (overidentification test of all instruments):           1.522
                                                                 Chi-sq(1) P-val =    0.2174
              ------------------------------------------------------------------------------
              Instrumented:         tenure
              Excluded instruments: age hours
              Partialled-out:       _cons
                                    nb: total SS, model F and R2s are after partialling-out;
                                        any small-sample adjustments include partialled-out
                                        variables in regressor count K
              ------------------------------------------------------------------------------
              
              Absorbed degrees of freedom:
              -----------------------------------------------------+
               Absorbed FE | Categories  - Redundant  = Num. Coefs |
              -------------+---------------------------------------|
                    idcode |      4142           0        4142     |
                      year |        15           1          14     |
              -----------------------------------------------------+
              
              . timeit 1: ivreg2 ln_wage ( tenure = age hours) i.idcode i.year, partial(i.idcode i.year)
              
              IV (2SLS) estimation
              --------------------
              
              Estimates efficient for homoskedasticity only
              Statistics consistent for homoskedasticity only
              
                                                                    Number of obs =    28036
                                                                    F(  1, 23323) =     9.54
                                                                    Prob > F      =   0.0020
              Total (centered) SS     =  2127.693601                Centered R2   =   0.0268
              Total (uncentered) SS   =  2127.693601                Uncentered R2 =   0.0268
              Residual SS             =   2070.72438                Root MSE      =    .2718
              
              ------------------------------------------------------------------------------
                   ln_wage |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
              -------------+----------------------------------------------------------------
                    tenure |   .0262586   .0077552     3.39   0.001     .0110587    .0414585
              ------------------------------------------------------------------------------
              Underidentification test (Anderson canon. corr. LM statistic):         251.098
                                                                 Chi-sq(2) P-val =    0.0000
              ------------------------------------------------------------------------------
              Weak identification test (Cragg-Donald Wald F statistic):              105.383
              Stock-Yogo weak ID test critical values: 10% maximal IV size             19.93
                                                       15% maximal IV size             11.59
                                                       20% maximal IV size              8.75
                                                       25% maximal IV size              7.25
              Source: Stock-Yogo (2005).  Reproduced by permission.
              ------------------------------------------------------------------------------
              Sargan statistic (overidentification test of all instruments):           1.552
                                                                 Chi-sq(1) P-val =    0.2128
              ------------------------------------------------------------------------------
              Instrumented:         tenure
              Excluded instruments: age hours
              Partialled-out:   -omitted-
              
              . timer list
                 1:   9602.67 /        1 =    9602.6710

              Comment

              Working...
              X