Announcement

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

  • Recovery and manipulation of coefficients from xtabond estimates for bootstrap

    Hi all,

    I'm encountering issues recovering the estimated coefficients from an xtabond estimation for use in a postestimation bootstrapping procedure. I am using Stata 18. When I run the code below, I get the error message: "insufficient observations to compute bootstrap standard errors // no results will be saved r(2000)".


    Code:
    gen temp2 = .
    
     program myel, rclass
         version 18
        quietly xtivreg lmshr3 ebacc4 eb4_n6 excel4 ex4_n6 excel5 ex5_n2 mi_ks4 mi_ks5 i.year (fee_sc feeg = w1 w2 w3 w4 w5 w6 h1 h2 h3 h4 h5 h6 pw1 pw2 ph1 ph2 sw3 sw4 sh3 sh4 gw1 gw2 gw3 gw4 gw5 gw6 gh1 gh2 gh3 gh4 gh5 gh6 gpw1 gpw2 gsw3 gsw4 gph1 gph2 gsw3 gsw4) if cat_age>2, fe vce(robust)
        replace temp2 = _b[fee_scm]
        summarize temp2, meanonly
        return scalar e = r(mean)
     end
    
    bootstrap e = r(e), nodrop reps(10): myel0
    However, if I replace the xtabond estimation in the program above with a slightly different specification estimated using xtivreg, Stata provides the results without issue. I feel rather silly for asking this, but: can someone help me understand what I need to change in order to call and use the xtabond coefficient estimates in a postestimation bootstrap?

  • #2
    You do not show any output or the xtabond command. Start by getting rid of the quietly command and run the regression outside the loop to see if you are getting any output to start with.

    Comment


    • #3
      Removing the quietly command from the code provided yields no output; however, I also tested the code with quietly suppressed using a different estimation command in place of xtabond. This also yields no output, but (critically) the bootstrap command successfully executes the program and provides the bootstrapped estimate.

      For what it's worth, please find the xtabond command below. When executed outside of the custom program environment (i.e., at the command line), it completes the estimation procedure.
      Code:
      xtabond lmshr ebacc4 eb4_n6 excel4 ex4_n6 excel5 ex5_n2 mi_ks4 mi_ks5 yr2018 yr2019 yr2020 yr2021 if cat_age >2, endogenous(fee_scm) inst( w1 w2 w3 w4 w5 w6 h1 h2 h3 h4 h5 h6 pw1 pw2 ph1 ph2 sw3 sw4 sh3 sh4) twostep vce(robust)

      Comment


      • #4
        The problem is that you are resampling observations when you should be resampling panels. You have panel data, see https://www.stata.com/support/faqs/s...th-panel-data/.

        Code:
        clear all
        webuse abdata, clear
        
        gen temp2 = .
        
        cap prog drop myel
        program myel, rclass
        version 18
        xtabond n l(0/2).ys yr1980-yr1984, lags(2) endogenous(w, lag(1,.)) endogenous(k, lag(2,.))
        replace temp2 = _b[w]
        summarize temp2, meanonly
        return scalar e= r(mean)
        end
        
        gen newid= id
        xtset newid year
        bootstrap e=r(e),rep(10) seed(123) cluster(id) idcluster(newid) nowarn:myel
        Res.:

        Code:
        . bootstrap e=r(e),rep(10) seed(123) cluster(id) idcluster(newid) nowarn:myel
        (running myel on estimation sample)
        
        Bootstrap replications (10): .........10 done
        
        Bootstrap results                                          Number of obs = 751
                                                                   Replications  =  10
        
              Command: myel
                    e: r(e)
        
                                            (Replications based on 140 clusters in id)
        ------------------------------------------------------------------------------
                     |   Observed   Bootstrap                         Normal-based
                     | coefficient  std. err.      z    P>|z|     [95% conf. interval]
        -------------+----------------------------------------------------------------
                   e |  -.7806016   .1736728    -4.49   0.000    -1.120994   -.4402092
        ------------------------------------------------------------------------------

        Comment

        Working...
        X