Announcement

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

  • Boostrapping system of equations

    Hi, I am trying to bootstrap standard errors for a system of equations (its a 2SLS where I create the first stage fitted values, and use in second stage as regressors; see my code below). But it produces ONLY the second stage output; how do I retrieve the first stage output too with bootstrapped standard errors?

    Many thanks

    * Produce bootstrap standard errors

    capture program drop bootiv
    program bootiv, eclass
    {
    * 1st stage T11 col1
    reg inq d_sob past_rel low_score medium_score high_score male_dum log_age ///
    i.tier i.qtr_yr, cl(fid) /* 1st stage */
    predict xbvar, xb

    ** 2nd stage col 2 t11
    reg default2_360 xbvar past_rel low_score medium_score high_score male_dum log_age ///
    log_loan i.new_acctid i.tier i.qtr_yr if e(sample), cl(fid) /* 2nd stage */
    sum xbvar if e(sample), detail
    drop xbvar
    }

    end

    set seed 1
    bootstrap, reps(5) seed(123): bootiv
    outreg2 using "BS check.xls", append ctitle("Boostrapped SE") bdec(4) tdec(4) se

  • #2
    The easiest is just to cut out the code that starts with ** 2nd stage col 2 t11.

    Comment


    • #3
      Thank you. But would it produce the bootstrapped standard errors for the first stage (that corresponds to bootstrapping the two together?);

      Comment


      • #4
        You can save the matrices of both regressions and then combine them in a vector. Here are some ideas:
        https://www.stata.com/statalist/arch.../msg01020.html
        https://www.stata.com/support/faqs/s...pping-vectors/

        I managed to do it like this but it needs some refinements. Hope it helps.

        Code:
        clear all
        sysuse auto
        
        cap program drop test1
        program define test1, eclass
            tempname reg1 reg2
            reg price mpg
            matrix `reg1' = e(b)
            
            
            reg trunk length foreign
            matrix `reg2' = e(b)
            matrix bb = (`reg1',`reg2')
            matrix colnames bb = "A" "B" "C" "D" "_cons"
            ereturn post bb
            ereturn local cmd="bootstrap"
        end
        
        
        
        bootstrap, reps(100) seed(123): test1
        Best wishes

        (Stata 16.1 MP)

        Comment


        • #5
          @ Felix .. many thanks. I tried the process you suggested; the matrix is showing different coefficients for 2nd stage than what the regression results show (or what is produced without bootstrap). the coefficients should be identical.

          Comment

          Working...
          X