Announcement

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

  • Predicting residuals from instrumental regression

    Model : ivreghdfe itotf (qt = lagqt lagcfo) cfo, absorb(gvkey fyear) endog(qt) cluster(gvkey) resid

    ----- Resid is not allowed

    Another way I can find residuals is by predicting yhat and measuring the difference between DV and yhat. Though I can predict yhat from the above regression,
    the yhat values are wrong.

    Can any one help me either predict yhat correctly or residuals?

  • #2
    - ivreghdfe- is a user written command, and you should read the help file how you generate residuals with it.

    If it follows standard syntax, it would be something like


    Code:
     ivreghdfe itotf (qt = lagqt lagcfo) cfo, absorb(gvkey fyear) endog(qt) cluster(gvkey) 
    
    predict myresiduals, resid

    Comment


    • #3
      Thanks, Joro

      For reghdfe this is not possible. That's the problem

      Comment


      • #4
        Write to the authors, and tell them that what they have done does not really make sense :-).

        Indeed, you are right, -ivreghdfe- takes us in circles, and it does not seem possible to generate residuals after it
        Code:
        . sysuse auto, clear
        (1978 Automobile Data)
        
        . qui ivreghdfe price (mpg = weight length), absorb(rep)
        
        . predict myres, resid
        you must add the resid option to reghdfe before running this prediction
        r(9);
        
        . ivreghdfe price (mpg = weight length), absorb(rep) resid
        option resid not allowed
        r(198);



        Originally posted by Raja Hasan View Post
        Thanks, Joro

        For reghdfe this is not possible. That's the problem

        Comment


        • #5
          This might be what you need

          Code:
          . sysuse auto, clear
          (1978 Automobile Data)
          
          . qui ivreghdfe price (mpg = weight length), absorb(rep)
          
          . predict pricehat
          (option xb assumed; fitted values)
          
          . gen resid = price - pricehat

          Comment


          • #6
            Hi Joro,

            Thank you very much.
            Could you please tell me how I can do the #1 model using ivreg2?


            Comment


            • #7
              Try the following, Raja:

              Code:
              ivreghdfe itotf (qt = lagqt lagcfo) cfo i.gvkey i.fyear, partial(i.gvkey i.fyear) cluster(gvkey)
              It did work on the Mickey Mouse dataset. I do not know whether it is going to work on your large dataset.

              Code:
              . sysuse auto, clear
              (1978 Automobile Data)
              
              . ivreg2 price (mpg = weight length) i.rep, partial(i.rep)
              
              IV (2SLS) estimation
              --------------------
              
              Estimates efficient for homoskedasticity only
              Statistics consistent for homoskedasticity only
              
                                                                    Number of obs =       69
                                                                    F(  1,    63) =    22.20
                                                                    Prob > F      =   0.0000
              Total (centered) SS     =  568436416.2                Centered R2   =   0.2135
              Total (uncentered) SS   =  568436416.2                Uncentered R2 =   0.2135
              Residual SS             =  447080951.8                Root MSE      =     2545
              
              ------------------------------------------------------------------------------
                     price |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
              -------------+----------------------------------------------------------------
                       mpg |   -384.088   77.88926    -4.93   0.000    -536.7482   -231.4279
              ------------------------------------------------------------------------------
              Underidentification test (Anderson canon. corr. LM statistic):          41.152
                                                                 Chi-sq(2) P-val =    0.0000
              ------------------------------------------------------------------------------
              Weak identification test (Cragg-Donald Wald F statistic):               45.809
              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):          13.035
                                                                 Chi-sq(1) P-val =    0.0003
              ------------------------------------------------------------------------------
              Instrumented:         mpg
              Excluded instruments: weight length
              Partialled-out:       2.rep78 3.rep78 4.rep78 5.rep78 _cons
                                    nb: total SS, model F and R2s are after partialling-out;
                                        any small-sample adjustments include partialled-out
                                        variables in regressor count K
              ------------------------------------------------------------------------------
              
              .

              Originally posted by Raja Hasan View Post
              Hi Joro,

              Thank you very much.
              Could you please tell me how I can do the #1 model using ivreg2?

              Comment


              • #8
                Thanks Joro, For large dataset, this is a problem

                Comment


                • #9
                  Try this:

                  Code:
                  xtset gvkey fyear
                  xtivreg itotf (qt = lagqt lagcfo) cfo i.fyear, fe
                  predict resid, e

                  Comment


                  • #10
                    Thank you very much Jeff. It has been extremely helpful.

                    Comment


                    • #11
                      Hi, I was returned the same error message when trying to run the ivreghdfe command with a resid(res) option to save residuals.

                      What worked for me was to re-install the packages via the installation codes available in the github code source (https://github.com/sergiocorreia/ivreghdfe#installation).

                      I had previously used the ssc install syntax to install all these packages, and the net install alternative suggested in github solved the issue.
                      My impression is that some updates available in github are not available in the ssc repo.

                      Comment

                      Working...
                      X