Announcement

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

  • ivregress vs. ivreg2: discrepant estimates

    I'm using Stata 13.1 and ivreg2 3.1.08. When I estimate a simple 2SLS model with ivregress (or ivreg) and ivreg2, I get discrepant estimates. Here is an example:

    Code:
    webuse set "https://s3.amazonaws.com/miscFileSharing/"
    webuse "example.dta", clear
    ivregress 2sls eqwlth yearYoung (educ = CA10)
    ivreg2         eqwlth yearYoung (educ = CA10)
    In this example, the differences between the two sets of estimates are minimal. But they are very large in more complex examples.

    The discrepancies vanish when I use the noconstant option.

    How can I make sense of these differences? I've looked to the documentation and to previous Statalist postings, but I haven't found any answers.

    [Cross-posted to http://stackoverflow.com/q/24896510/697473.]


  • #2
    Hi John,

    not sure what you did but using your code, I do NOT obtain different estimates. The only thing that differs between ivregress and ivreg2 in the results is the test statistic against the null model.


    Code:
    clear all
    
    webuse set "https://s3.amazonaws.com/miscFileSharing/"
    webuse "example.dta", clear
    
    ivregress 2sls eqwlth yearYoung (educ = CA10)
    estimates store ivregress
    
    ivregress 2sls eqwlth yearYoung (educ = CA10), noconstant
    estimates store ivregressnoc
    
    ivreg2 eqwlth yearYoung (educ = CA10)
    estimates store ivreg2
    
    ivreg2 eqwlth yearYoung (educ = CA10), noconstant
    estimates store ivreg2noc
    
    estimates table iv*, b se stats(r2 F chi2)
    
    estout iv* using "ivreg_compare.xls", replace cells(b se) stats(r2 F chi2)
    ivregress ivregressnoc ivreg2 ivreg2noc
    b/se b/se b/se b/se
    educ 0.0091198 -0.1287089 0.0091198 -0.1287089
    0.3992889 0.0486875 0.3992889 0.0486875
    yearYoung -0.0033483 0.0027588 -0.0033483 0.0027588
    0.0160922 0.0003219 0.0160922 0.0003219
    _cons 10.19741 10.19741
    26.40686 26.40686
    r2 0.00581 0.00581 0.761853
    F 10.53602 40927.95
    chi2 21.07459

    I also used different data but have not encountered any problems.

    Cheers,
    Martin

    Comment


    • #3
      Hi, Martin,

      Thank you. This is curious: I re-ran my code and found the same discrepancies. A Stack Overflow poster also found them when using ivreg2 3.1.08. When he used ivreg2 2.2.08, they disappeared. (See http://stackoverflow.com/q/24896510/697473.)

      A little more detail: I am using Stata/SE 13.1 for Windows (64-bit x86-64, revision 03 July 2014). Here are the specific discrepancies that I observe:

      Code:
      webuse set "https://s3.amazonaws.com/miscFileSharing/"
      webuse "example.dta", clear
      ivregress 2sls eqwlth yearYoung (educ = CA10)
      estimates store ivregress
      ivreg2         eqwlth yearYoung (educ = CA10)
      estimates store ivreg2
      estimate table iv*, b se stats(r2 F chi2)
      estout iv* using "ivreg_compare.xls", replace cells(b se) stats(r2 F chi2)
      ivregress ivreg2
      b/se b/se
      educ 0.00912 0.009119
      0.399289 0.399287
      yearYoung -0.00335 -0.00335
      0.016092 0.016092
      _cons 10.19741 10.19736
      26.40686 26.40675
      r2 0.00581 0.00581
      F 10.53602
      chi2 21.07459

      The most notable discrepancy lies with the constant. It's small here, but I observe larger differences in more complex examples that involve other variables.

      Can you think of anything that might explain these differences in the estimates and the standard errors?

      Thank you again. ivreg2 is a great package.

      John

      Comment


      • #4
        Rounding may be throwing the comparisons off. Here is what I get. This is hardly anything I would worry about. Maybe John could post his code and output from the runs that concern him

        Code:
        . estimates table iv*, b se stats(r2 F chi2)
        
        ------------------------------------------------------------------
            Variable | ivregress    ivregres~c     ivreg2     ivreg2noc   
        -------------+----------------------------------------------------
                educ |  .00911975   -.12870886    .00911902   -.12870886  
                     |  .39928893    .04868749    .39928736    .04868749  
           yearYoung | -.00334826    .00275884   -.00334823    .00275884  
                     |  .01609221    .00032186    .01609215    .00032186  
               _cons |  10.197412                 10.197363               
                     |  26.406859                 26.406755               
        -------------+----------------------------------------------------
                  r2 |  .00581002                 .00580961    .76185299  
                   F |                            10.536019    40927.953  
                chi2 |  21.074592                                         
        ------------------------------------------------------------------
                                                              legend: b/se
        -------------------------------------------
        Richard Williams, Notre Dame Dept of Sociology
        Stata Version: 17.0 MP (2 processor)

        EMAIL: [email protected]
        WWW: https://www3.nd.edu/~rwilliam

        Comment


        • #5
          Thank you, Richard. It does look as though rounding error may be the culprit in my previous example—although it still seems noteworthy that you and I and the Stack Overflow poster get estimates that differ from Martin's. (And if rounding error is at issue, how might it be fixed?)

          Here is an example in which I observe much bigger differences between ivregress and ivreg2:

          Code:
          webuse set "https://s3.amazonaws.com/miscFileSharing/"
          webuse "example2.dta", clear
          ivregress 2sls eqwlth female i.yearInt_fac yearYoung age (educ = CA10)
          estimates store ivregress
          xi:ivreg2      eqwlth female i.yearInt_fac yearYoung age (educ = CA10)
          estimates store ivreg2
          estimate table iv*, keep(educ _cons) b se stats(r2 F chi2)

          Code:
          ----------------------------------------
              Variable | ivregress      ivreg2    
          -------------+--------------------------
                  educ |  .14855169    .00194942  
                       |  .33970699     .3450602  
                 _cons |  240.08429    183.16973  
                       |  79.546067    80.627928  
          -------------+--------------------------
                    r2 |  .05051654    .05087311  
                     F |               19.107363  
                  chi2 |  438.94529               
          ----------------------------------------
                                      legend: b/se
          These differences seem too big to be due to rounding error in any simple way. In this example, too, the differences vanish when I add the noconstant option.

          Thanks again,
          John

          Comment


          • #6
            There is an older version called ivreg29 that you can download from SSC. Download and try this:

            Code:
            webuse set "https://s3.amazonaws.com/miscFileSharing/"
            webuse "example2.dta", clear
            xi:ivregress 2sls eqwlth female i.yearInt_fac yearYoung age (educ = CA10)
            estimates store ivregress
            xi:ivreg29      eqwlth female i.yearInt_fac yearYoung age (educ = CA10)
            estimates store ivreg29
            estimate table iv*, keep(educ _cons) b se stats(r2 F chi2)
            Output:

            Code:
            . estimate table iv*, keep(educ _cons) b se stats(r2 F chi2)
            
            ----------------------------------------
                Variable | ivregress     ivreg29    
            -------------+--------------------------
                    educ |  .14855169    .14774287  
                         |  .33970699    .33969388  
                   _cons |  240.08429    239.77831  
                         |  79.546067    79.542996  
            -------------+--------------------------
                      r2 |  .05051654    .05058984  
                       F |               19.934099  
                    chi2 |  438.94529               
            ----------------------------------------
                                        legend: b/se
            Not a perfect match, but very close.

            I suggest you write to the authors, perhaps including a link to this thread.
            -------------------------------------------
            Richard Williams, Notre Dame Dept of Sociology
            Stata Version: 17.0 MP (2 processor)

            EMAIL: [email protected]
            WWW: https://www3.nd.edu/~rwilliam

            Comment


            • #7
              Complete comparison of ivregress, ivreg29, and ivreg2:

              Code:
              clear all
              webuse set "https://s3.amazonaws.com/miscFileSharing/"
              webuse "example2.dta", clear
              xi:ivregress 2sls eqwlth female i.yearInt_fac yearYoung age (educ = CA10)
              estimates store ivregress
              xi:ivreg29      eqwlth female i.yearInt_fac yearYoung age (educ = CA10)
              estimates store ivreg29
              xi:ivreg2      eqwlth female i.yearInt_fac yearYoung age (educ = CA10)
              estimates store ivreg2
              estimate table iv*, keep(educ _cons) b se stats(r2 F chi2)
              Code:
              . estimate table iv*, keep(educ _cons) b se stats(r2 F chi2)
              
              -----------------------------------------------------
                  Variable | ivregress     ivreg29       ivreg2    
              -------------+---------------------------------------
                      educ |  .14855169    .14774287    .00194942  
                           |  .33970699    .33969388     .3450602  
                     _cons |  240.08429    239.77831    183.16973  
                           |  79.546067    79.542996    80.627928  
              -------------+---------------------------------------
                        r2 |  .05051654    .05058984    .05087311  
                         F |               19.934099    19.107363  
                      chi2 |  438.94529                            
              -----------------------------------------------------
                                                       legend: b/se
              EDIT: If you add the noconst option, all three programs give exactly identical results:

              Code:
              . estimate table iv*, keep(educ ) b se stats(r2 F chi2)
              
              -----------------------------------------------------
                  Variable | ivregress     ivreg29       ivreg2    
              -------------+---------------------------------------
                      educ |  .12397097    .12397097    .12397097  
                           |  .33479445    .33479445    .33479445  
              -------------+---------------------------------------
                        r2 |               .79596685    .79596685  
                         F |               4360.0473    4360.0473  
                      chi2 |                                       
              -----------------------------------------------------
                                                       legend: b/se
              Last edited by Richard Williams; 24 Jul 2014, 17:53.
              -------------------------------------------
              Richard Williams, Notre Dame Dept of Sociology
              Stata Version: 17.0 MP (2 processor)

              EMAIL: [email protected]
              WWW: https://www3.nd.edu/~rwilliam

              Comment


              • #8
                Thank you again, Richard. I wrote to the authors of ivreg2 to let them know about your results. I heard back from one of them, Mark Schaffer. If you let the instruments in the example that I provided be Z, it turns out that Z'Z is computationally difficult to work with. (It has a high condition number.) Mark adds this:

                If you partial out the constant with the partial option, ivreg2 agrees with the others - the condition number is only 27 million in that case - so this is the short run solution. But we should definitely revisit these numerical issues.

                Comment


                • #9
                  Dear John and Richard,
                  sorry for getting back late. This is indeed curious, I have now updated to what apparently is version 3.1.09 and still find no discrepancies (maybe the authors already updated something?) I have the same Stata version as John installed. Unfortunately, i could not webuse your example dataset anymore (has somebody removed it?). Instead, I used the same dataset for comparison as before, which is from Cameron/Trivedi on returns to schooling, mus06kling.dta, since I use it for teaching purposes.

                  Code:
                  . ivregress 2sls lwage76 black smsa76 south76 exp76 exp762 ///
                  >         (ed76 = momed daded nearc4)
                  
                  . ivreg2 lwage76 black smsa76 south76 exp76 exp762 ///
                  >         (ed76 = momed daded nearc4)   
                  
                  
                  . estimates table ivregress ivreg2 ///
                  >         , b se stats(r2 F chi2)
                  
                  ----------------------------------------
                      Variable | ivregress      ivreg2    
                  -------------+--------------------------
                          ed76 |  .09384369    .09384369  
                               |  .01208606    .01208606  
                         black | -.16960972   -.16960972  
                               |   .0212013     .0212013  
                        smsa76 |   .1511791     .1511791  
                               |  .01673919    .01673919  
                       south76 | -.11806809   -.11806809  
                               |  .01568892    .01568892  
                         exp76 |  .09173059    .09173059  
                               |  .00818818    .00818818  
                        exp762 | -.00225558   -.00225558  
                               |  .00031927    .00031927  
                         _cons |   4.399835     4.399835  
                               |  .20609734    .20609734  
                  -------------+--------------------------
                            r2 |  .28294129    .28294129  
                             F |               139.28791  
                          chi2 |  837.67554               
                  ----------------------------------------
                                              legend: b/se
                  Thanks anyway for pointing this out, so at least I will be more careful in the future when working with these commands. At least, the authors of ivreg2 seem to have an explanation.

                  Martin

                  Comment


                  • #10
                    In case anyone else is confused about the results from ivreg2 and ivregress, I use stata 15 and I get the same results for both.

                    Comment


                    • #11
                      Hi,

                      I wonder what the corresponding ivreg2 command is for

                      ivregress 2sls dependentvar explanatories (endogvar=instrument) , vce(hac nwest)

                      From the description I thought it should be

                      ivreg2 dependentvar explanatories (endogvar=instrument) , bw(auto)

                      However, the latter gives me much larger SE.

                      Thanks in advance.

                      Comment

                      Working...
                      X