Announcement

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

  • -bootstrap- command with panel data

    I'm having trouble running the bootstrap over a user written command on panel data.
    The example bellow replicates the error I get using xtreg on a balanced dataset.


    Code:
    * simulate a dataset
    version 12.1
    clear
    set seed 12345
    set obs 200
    gen id = _n
    gen ui = rnormal()
    expand 10
    sort id
    bysort id: gen t = _n
    gen x = rnormal()
    gen y = ui +2*x + rnormal()
    xtset id t
    
    * bootstrapped clustered SEs 
    xtreg y x, fe vce(bootstrap, seed(22)) cluster(id)
    
    * equivalent using -bootstrap- 
    bootstrap, cluster(id) idcluster(newid) seed(22): xtreg y x, fe
    
    *Error: 
    . repeated time values within panel
    . the most likely cause for this error is misspecifying the cluster(),
    . idcluster(), or group() option

    How can I fix the error above, replicating the results of "xtreg y x, fe vce(bootstrap...)" with "bootstrap, cluster(id) idcluster(newid) : xtreg y x, fe ?"
    More generally, how can I use the -bootstrap- command to sample by cluster without generating newid-year duplicates?

    OBS: similar issues have been discussed in this tread, http://hsphsun3.harvard.edu/cgi-bin/...ticle-395.html, I did not find a definitive solution in it though.







  • #2
    If you are going to cluster on id and have bootstrap identify
    the replicated groups with newid then you need to xtset
    with the newid variable.

    Code:
    gen newid = id
    xtset newid t
    There is a similar worked example in the following FAQ.

    http://www.stata.com/support/faqs/st...th-panel-data/

    Comment


    • #3
      Than you.

      Comment

      Working...
      X