Announcement

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

  • Bootstrap estimation including fixed effects.

    Hi all,


    I am bootstrapping a ratio I calculate using several regression estimates from different equations. The objective is to calculate bootstrap standard errors and confidence intervals for that ratio.

    The problem I have is that the bootstrap procedure yields a lot of failed replications providing the message: collinearity in replicate sample is not the same as the full sample, posting missing values insufficient observations to compute bootstrap standard errors no results will be saved.

    I am sure the problem comes from the inclusion of fixed effects in the estimations since when I exclude them I don't get failed replications anymore. However, I am not sure why I get problems with fixed effects since I am specifying block bootstrapping by means of the cluster() option and I am making sure that there is a new variable to identify the bootstrap clusters in each replication by using the id() option.

    Using this options should make sure that there is no more than one unit with the same identificator in the bootstrap replications, so I am not sure why I am getting the error. Any help is more than welcome.

    Find the code I am using below: (originally I used "xtset nohouse year" but I have "xtset id year" at the beginning of my program to make sure the new identificator is used for the bootstrap reps)



    Code:
    program myboot, rclass
    
    xtset id year
    
    qui xtreg leisure unemp $controls, fe
    sum leisure
    scalar x=(r(mean)+_b[unemp])/r(mean)
    
    qui xtreg cook unemp $controls, fe
    sum cook
    scalar k=r(mean)/(r(mean)+_b[unemp])
    
    qui xtreg food_out_hh unemp $controls, fe
    sum food_out_hh
    scalar z=r(mean)/(r(mean)+_b[unemp])
    
    return scalar ratio=log(x)/(log(z)-log(k))
    display ratio
    end
    
    bootstrap ratio=r(ratio), cluster(nohouse) idcluster(id) reps(1000) seed(12345): myboot







    Last edited by Eduard Suari; 20 Dec 2021, 05:38.

  • #2
    One technical note of bootstrap's documentation says

    Similarly, when you have panel (longitudinal) data, all resampled panels must be unique in each of the bootstrap samples to obtain correct bootstrap estimates of statistics. Therefore, both cluster(panelvar) and idcluster(newpanelvar) must be specified with bootstrap, and i(newpanelvar) must be used with the main command. Moreover, you must clear the current xtset settings by typing xtset, clear before calling bootstrap.
    Below is an example strictly following the instruction and working well. Not sure if it can solve your problem.

    Code:
    cap program drop myboot
    program myboot, rclass
    
        qui xtreg ln_wage union, fe i(newid)
        sum ln_wage
        scalar x=(r(mean)+_b[union])/r(mean)
    
        qui xtreg wks_work union, fe i(newid)
        sum wks_work
        scalar k=r(mean)/(r(mean)+_b[union])
    
        qui xtreg hours union, fe i(newid)
        sum hours
        scalar z=r(mean)/(r(mean)+_b[union])
    
        return scalar ratio = x/(z-k)
        xtset, clear
    end
    
    webuse nlswork, clear
    xtset, clear
    
    bootstrap ratio=r(ratio), cluster(idcode) idcluster(newid) reps(50) seed(12345): myboot

    Comment


    • #3
      Dear Fei,

      Thank you very much for your help. I had read the extract that you refer to but had not interpreted it properly. I have now managed to run all bootstrap estimations without failed replications. I realized also that including variables with little or not time variation was causing some replications to fail. I do not fully understand why is that the case (after all stata can just drop a variable when it has no time variation and you are using the fe option), but of course I could remove those variables at a very low cost.

      Eduard

      Comment

      Working...
      X