Announcement

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

  • IV-Regression with ivreg2- Does not save first stage

    Hello there,

    I am instrumenting my governance variable with politics variables. However my code does not save the first stage results.
    Code:
    ivreg2 risk4_w (governance_pillar_score = president congress govenor) company_size_w earnings_smoothing_2_w leverage_w dividend_ratio_w research_development_ratio_w sales_growth_w tangability_ratio_w turnover_rate_w i.sic_2, partial (company_size_w earnings_smoothing_2_w leverage_w dividend_ratio_w research_development_ratio_w sales_growth_w tangability_ratio_w turnover_rate_w i.sic_2) endog(governance_pillar_score) cluster(company_code) first savefirst sfirst
    est store _ivreg2_risk4_w
    est restore _ivreg2_governance_pillar_score
    outreg2 using "IV-Regression", replace word tstat cttop(first)
    est restore _ivreg2_risk4_w
    outreg2 using "IV-Regression", cttop(second) word tstat
    The problem here is the line with est restore _ivreg2_governance_pillar_score

    Code:
    . est restore _ivreg2_governance_pillar_score
    estimation result _ivreg2_governance_pillar_score not found
    Can somebody help me with that?
    Last edited by Patrick Johannes; 01 Jul 2021, 08:52.

  • #2
    Neither the user written -ivreg2- nor -ivregress- store the first stage.

    You need to run the first stage manually, and save what you need this way.

    Comment


    • #3
      outreg2 and ivreg2 are from SSC (FAQ Advice #12). Here is an example that saves the first stage.

      Code:
      sysuse auto, clear
      ivreg2 price i.rep78 (foreign = weight turn trunk), first savefirst
      est restore _ivreg2_foreign
      outreg2 using "myfile", replace
      ivreg2 price i.rep78 (foreign = weight turn trunk)
      outreg2 using "myfile", append

      Comment


      • #4
        I got an error for the following program. The error is "invalid syntax r(198);" which seems to be in the last step. I highly appreciate anyone who can help solve this problem. I think Andrew Musau has expertise. Thank you!

        * Load example dataset

        sysuse auto, clear

        * Run IV regression and save first-stage results
        ivreg2 price i.rep78 (foreign = weight turn trunk), first savefirst savefprefix(fs)

        * Save second-stage regression
        est store second

        * Restore and store first-stage regression
        est restore fsforeign
        est store first

        * Export first-stage regression
        outreg2 [first] using "myfile.rtf", replace dec(2) ///
        title("First Stage Regression")

        * --- Extract statistics for addstat() ---
        scalar cdf1 = e(cdf) // Cragg-Donald F-stat
        scalar sstat1 = e(sstat) // Stock-Yogo S statistic
        scalar r2 = e(r2) // R-squared
        scalar N = e(N) // Sample size

        * Manually compute first-stage F-statistic
        qui reg foreign weight turn trunk i.rep78 if e(sample)
        scalar F1 = e(F)

        * Append second-stage regression with full diagnostics
        outreg2 [second] using "myfile.rtf", append dec(2) ///
        addstat("CD Wald F", cdf1, "SW S stat.", sstat1, ///
        "R-squared", r2, "First Stage F-Stat", F1, "N", N) ///
        title("Second Stage Regression")

        Comment


        • #5
          If interested in #4, see https://www.statalist.org/forums/for...=1748924854453.

          Comment

          Working...
          X