Announcement

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

  • Bootstrapping equations together

    I'm estimating an unbalanced panel data model which first accounts for self-selection bias (xtprobit and derived inverse Mills ratio), for omitted variable bias (xtreg and derived control function CF), and concludes with a structural equation (xtreg SALESGR). To obtain the correct SE in the structural equation, I'd like to bootstrap the three equations together. I used the following code, but received an error message:
    Code:
    program spec10
      xtprobit Select at l.SME_IND SALESGR PROFITGR HHI DAENT CIAE mosRate i.date_fiscal, vce(robust)
      predict phat, xb
      gen mills = exp(-.5*phat^2)/(sqrt(2*_pi)*normprob(phat))
      xtreg SME_1lag at SME_IND_1lag  HHI DAENT CIAE  ROA , fe vce(robust)
      predict res
      rename res CF
      xtreg SALESGR c.SME_1lag##c.AVESIAE_1lag HHI ROA LNCIAE DAENT at AVECD JVPERCENT MKTDIV PARDIV sale mills CF, fe vce(robust)
      drop phat mills CF
    end program
    
    bootstrap, reps(200): spec10

    Bootstrap replications (200)
    ----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5
    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 50
    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 100
    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 150
    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 200
    insufficient observations to compute bootstrap standard errors
    no results will be saved

    The code works if I run each line separately, in other words, not within the program specification. Any suggestions would be greatly appreciated.

  • #2
    Perhaps I should mention that all my variables are continuous with the exception of my DV for xtprobit (Select is binary, 0/1). My data is xtset with my panel variable = gvkey and my time variable = date_fiscal.

    Comment


    • #3
      Hi Annette,
      I think the problem is how you are bootstrapping your data. First I think you should be bootstrapping by entity, and not by observation. and create a new identifier for each sample
      Here is is a code that you could apply to what you are doing
      Code:
      webuse nlswork, clear
      
      xtset idcode
      gen age2=age*age
      xtivreg ln_w age age2 not_smsa (tenure = union south), fe 
      
      **by hand
      capture program drop  bootiv
      program bootiv, eclass
      qui {
        xtset newid
        xtreg tenure age c.age#c.age not_smsa  union south ,fe
        capture drop resid
        predict resid, res
        xtreg ln_w age c.age#c.age not_smsa tenure  resid,fe
      }
      end
      
      bootstrap , cluster(idcode) idcluster(newid) reps(100):bootiv
      the only thing im not sure about its the selection part. Wooldridge Econometrics book provides some explanation how to do heckman type of selection model in panel data. I dont think i have seen using the xtprobit for a model of this type.
      HTH
      Fernando

      Comment


      • #4
        Thank you very much, Fernando, for your assistance.

        I've updated my code to reflect the panel data structure and eliminated the sample-selection correction (mainly to identify issues with the code). My new syntax is


        Code:
        xtset gvkey date_fiscal, yearly
        
        capture program drop spec4
        program spec4, eclass
        gen newid =gvkey
        xtset newid
        xtreg SME_1lag at SME_IND_1lag  HHI DAENT CIAE  ROA , fe vce(robust)
        predict res
        rename res CF
        xtreg SALESGR c.SME_1lag##c.l.AVESIAE HHI ROA LNCIAE DAENT at AVECD JVPERCENT MKTDIV PARDIV sale CF, fe vce(robust)
        drop phat mills CF newid
        end program
        
        bootstrap, cluster(gvkey) idcluster(newid) reps(200): spec4
        However, I receive the following error:

        (running spec4 on estimation sample)
        variable newid already defined
        an error occurred when bootstrap executed spec4
        r(110);

        I'm not sure why this is the case. If I would receive this after the first iteration, I would assume it's an issue with newid not being dropped after the first iteration. However, as you can see, the program does not even complete an iteration - at least I don't see a "dot" which indicates a successful run.

        Comment


        • #5
          Try the following code:

          Code:
          xtset gvkey date_fiscal, yearly
          capture program drop spec4
          program spec4, eclass
          *sets the panel using the newid created by the cluster program
          xtset newid date_fiscal
          xtreg SME_1lag at SME_IND_1lag HHI DAENT CIAE ROA , fe vce(robust)
          * For control function you need to use the residuals instead of the predictions
          predict CF,res
          xtreg SALESGR c.SME_1lag##c.l.AVESIAE HHI ROA LNCIAE DAENT at AVECD JVPERCENT MKTDIV PARDIV sale CF, fe vce(robust)
          drop CF
          end program
          bootstrap, cluster(gvkey) idcluster(newid) reps(200): spec4

          Comment


          • #6
            Thank you, Fernando. I was able to bootstrap two equations based on your suggestions.

            Comment

            Working...
            X