Announcement

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

  • Different results for ivreghdfe and reghdfe when using predict after the same regression

    Hi all,

    I run two estimations

    reghdfe y x1 x2, absorb(i t)
    predict yhat1

    and

    ivreghdfe y x1 x2, absorb(i t)
    predict yhat2

    But the predictions are very different for yhat1 and yhat2. What could be the reason here and which gives correct predictions?

    Thank you!
    Bobby

  • #2
    Similarly, I get again different results for predict if I use xtreg

    xtset i t
    xtreg y x1 x2 i.t, fe
    predict yhat3

    Aren't they all supposed to be same?

    Comment


    • #3
      There are different defaults for the prediction, e.g., if the prediction includes the individual effect. See

      Code:
      help xtreg postestimation
      under -predict-

      Comment


      • #4
        And which one is correct if I want to do an IV by hand?

        Comment


        • #5
          Should be with the individual effects.

          Code:
          webuse nlswork
          xtivreg ln_w age c.age#c.age not_smsa (tenure = union south), fe first
          *BY HAND NOT CORRECTING STANDARD ERRORS
          qui xtreg tenure age c.age#c.age not_smsa  union south, fe
          predict tenurehat, xbu
          xtreg ln_w tenurehat age c.age#c.age not_smsa, fe
          Res.:

          Code:
          . xtivreg ln_w age c.age#c.age not_smsa (tenure = union south), fe first
          
          First-stage within regression
          
          Fixed-effects (within) regression               Number of obs     =     19,007
          Group variable: idcode                          Number of groups  =      4,134
          
          R-sq:                                           Obs per group:
               within  = 0.3019                                         min =          1
               between = 0.0578                                         avg =        4.6
               overall = 0.1289                                         max =         12
          
                                                          F(5,14868)        =    1285.83
          corr(u_i, Xb)  = -0.1871                        Prob > F          =     0.0000
          
          ------------------------------------------------------------------------------
                tenure |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
          -------------+----------------------------------------------------------------
                   age |   .0863031   .0343238     2.51   0.012     .0190241    .1535821
                       |
           c.age#c.age |   .0039115    .000549     7.12   0.000     .0028353    .0049876
                       |
              not_smsa |  -.3552488   .1269318    -2.80   0.005    -.6040507   -.1064468
                 union |   .3896861   .0706568     5.52   0.000     .2511901    .5281821
                 south |  -.4296172   .1349122    -3.18   0.001    -.6940618   -.1651726
                 _cons |  -2.554764   .5293374    -4.83   0.000     -3.59233   -1.517197
          -------------+----------------------------------------------------------------
               sigma_u |  3.1334845
               sigma_e |  2.5869529
                   rho |  .59467598   (fraction of variance due to u_i)
          ------------------------------------------------------------------------------
          F test that all u_i=0: F(4133, 14868) = 6.40                 Prob > F = 0.0000
          
          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
                       |
              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 not_smsa union south
          ------------------------------------------------------------------------------
          
          .
          . *BY HAND NOT CORRECTING STANDARD ERRORS
          
          .
          . qui xtreg tenure age c.age#c.age not_smsa  union south, fe
          
          .
          . predict tenurehat, xbu
          (9,527 missing values generated)
          
          .
          . xtreg ln_w tenurehat age c.age#c.age not_smsa, 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.1052                                         min =          1
               between = 0.1304                                         avg =        4.6
               overall = 0.0948                                         max =         12
          
                                                          F(4,14869)        =     437.24
          corr(u_i, Xb)  = -0.8478                        Prob > F          =     0.0000
          
          ------------------------------------------------------------------------------
               ln_wage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
          -------------+----------------------------------------------------------------
             tenurehat |    .240353    .015377    15.63   0.000     .2102122    .2704939
                   age |   .0118437   .0037074     3.19   0.001     .0045767    .0191108
                       |
           c.age#c.age |  -.0012145   .0000811   -14.98   0.000    -.0013733   -.0010556
                       |
              not_smsa |  -.0167178   .0139694    -1.20   0.231    -.0440995    .0106639
                 _cons |   1.678287    .066984    25.06   0.000      1.54699    1.809584
          -------------+----------------------------------------------------------------
               sigma_u |  .70661939
               sigma_e |  .25954812
                   rho |  .88112219   (fraction of variance due to u_i)
          ------------------------------------------------------------------------------
          F test that all u_i=0: F(4133, 14869) = 8.47                 Prob > F = 0.0000
          
          . 

          Comment

          Working...
          X