Announcement

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

  • How do I obtain _b[] and _se[] at the same time from Bootstrap with panel data ?

    The structure of my data is a panel, under the command "xtreg", how can I derive _b[] and _se[] at the same time with 200 repetition?
    code:
    xtreg F`i'.g exp0bp rec0bp $bpnlxlist, fe vce(bootstrap)

    gen bgexph`i' = _b[exp0bp]
    gen bgrech`i' = _b[rec0bp]

    gen segexph`i' = _se[exp0bp]
    gen segrech`i' = _se[rec0bp]
    Last edited by Ning Wei; 14 Sep 2020, 02:13.

  • #2
    Try:

    Code:
    .  webuse nlswork
    (National Longitudinal Survey.  Young Women 14-26 years of age in 1968)
    
    .         . xtset idcode
           panel variable:  idcode (unbalanced)
    
    . bootstrap _b _se, saving(TEMP, replace): xtreg ln_w age south, fe
    (running xtreg on estimation sample)
    
    Bootstrap replications (50)
    ----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5 
    ..................................................    50
    
    Bootstrap results                               Number of obs     =     28,502
                                                    Replications      =         50
    
    ------------------------------------------------------------------------------
                 |   Observed   Bootstrap                         Normal-based
                 |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
    b            |
             age |   .0181924   .0003541    51.38   0.000     .0174985    .0188864
           south |  -.0774963   .0153928    -5.03   0.000    -.1076655    -.047327
           _cons |   1.178256    .011039   106.74   0.000      1.15662    1.199892
    -------------+----------------------------------------------------------------
    se           |
             age |   .0003475   3.78e-06    91.97   0.000     .0003401    .0003549
           south |   .0112551   .0002045    55.02   0.000     .0108542     .011656
           _cons |   .0111487   .0001361    81.94   0.000      .010882    .0114154
    ------------------------------------------------------------------------------
    
    . use TEMP
    (bootstrap: xtreg)
    
    . des
    
    Contains data from TEMP.dta
      obs:            50                          bootstrap: xtreg
     vars:             6                          14 Sep 2020 09:32
     size:         1,200                          
    ----------------------------------------------------------------------------------------------------
                  storage   display    value
    variable name   type    format     label      variable label
    ----------------------------------------------------------------------------------------------------
    _b_age          float   %9.0g                 _b[age]
    _b_south        float   %9.0g                 _b[south]
    _b_cons         float   %9.0g                 _b[_cons]
    _se_age         float   %9.0g                 _se[age]
    _se_south       float   %9.0g                 _se[south]
    _se_cons        float   %9.0g                 _se[_cons]
    ----------------------------------------------------------------------------------------------------
    Sorted by: 
    
    . summ
    
        Variable |        Obs        Mean    Std. Dev.       Min        Max
    -------------+---------------------------------------------------------
          _b_age |         50    .0182427    .0003541   .0174261   .0192864
        _b_south |         50    -.076995    .0153928  -.1069007  -.0536908
         _b_cons |         50    1.176522     .011039   1.143865   1.197643
         _se_age |         50    .0003396    3.78e-06   .0003308   .0003494
       _se_south |         50     .011177    .0002045   .0108174   .0117697
    -------------+---------------------------------------------------------
        _se_cons |         50    .0109135    .0001361   .0106551   .0112061
    
    .

    Comment


    • #3
      Thank you very much for this detailed answer!

      Comment


      • #4
        You are welcome. It can also be passed as an option as you tried the first time around:

        Code:
        . xtreg ln_w age south, fe vce(bootstrap _b _se, saving(TEMP, replace))
        Originally posted by Ning Wei View Post
        Thank you very much for this detailed answer!

        Comment


        • #5
          That 's great! Thanks very much.

          Comment


          • #6
            Hello,

            I'd like to follow up on this post. Would using
            Code:
            bootstrap, seed(1): xtreg ln_w age south, fe
            be justified? In the above example, the standard errors are higher under
            Code:
            xtreg ln_w age south, fe vce(bootstrap, seed(1))
            Code:
            . bootstrap, seed(1): xtreg ln_w age south, fe
            (running xtreg on estimation sample)
            
            Bootstrap replications (50): .........10.........20.........30.........40.........50 done
            
            Fixed-effects (within) regression               Number of obs     =     28,502
            Group variable: idcode                          Number of groups  =      4,710
            
            R-squared:                                      Obs per group:
                 Within  = 0.1044                                         min =          1
                 Between = 0.1233                                         avg =        6.1
                 Overall = 0.1062                                         max =         15
            
                                                            Wald chi2(2)      =    1977.76
            corr(u_i, Xb) = 0.0818                          Prob > chi2       =     0.0000
            
                                              (Replications based on clustering on idcode)
            ------------------------------------------------------------------------------
                         |   Observed   Bootstrap                         Normal-based
                 ln_wage | coefficient  std. err.      z    P>|z|     [95% conf. interval]
            -------------+----------------------------------------------------------------
                     age |   .0181924   .0004156    43.77   0.000     .0173779     .019007
                   south |  -.0774963   .0131054    -5.91   0.000    -.1031824   -.0518101
                   _cons |   1.178256   .0136785    86.14   0.000     1.151446    1.205065
            -------------+----------------------------------------------------------------
                 sigma_u |  .39998991
                 sigma_e |  .30322383
                     rho |  .63504833   (fraction of variance due to u_i)
            ------------------------------------------------------------------------------
            F test that all u_i=0: F(4709, .) = 8.22                     Prob > F =      .
            
            . xtreg ln_w age south, fe vce(bootstrap, seed(1))
            (running xtreg on estimation sample)
            
            Bootstrap replications (50): .........10.........20.........30.........40.........50 done
            
            Fixed-effects (within) regression               Number of obs     =     28,502
            Group variable: idcode                          Number of groups  =      4,710
            
            R-squared:                                      Obs per group:
                 Within  = 0.1044                                         min =          1
                 Between = 0.1233                                         avg =        6.1
                 Overall = 0.1062                                         max =         15
            
                                                            Wald chi2(2)      =    1188.57
            corr(u_i, Xb) = 0.0818                          Prob > chi2       =     0.0000
            
                                          (Replications based on 4,710 clusters in idcode)
            ------------------------------------------------------------------------------
                         |   Observed   Bootstrap                         Normal-based
                 ln_wage | coefficient  std. err.      z    P>|z|     [95% conf. interval]
            -------------+----------------------------------------------------------------
                     age |   .0181924   .0005292    34.38   0.000     .0171552    .0192297
                   south |  -.0774963   .0174753    -4.43   0.000    -.1117473   -.0432453
                   _cons |   1.178256   .0154093    76.46   0.000     1.148054    1.208457
            -------------+----------------------------------------------------------------
                 sigma_u |  .39998991
                 sigma_e |  .30322383
                     rho |  .63504833   (fraction of variance due to u_i)
            ------------------------------------------------------------------------------
            F test that all u_i=0: F(4709, .) = 8.22                     Prob > F =      .

            Comment


            • #7
              Marco Tacchi is missing some necessary options to bootstrap for it to properly resample the panel data, please see the FAQ https://www.stata.com/support/faqs/s...th-panel-data/

              Comment


              • #8
                In other words, if a standard command does accept vce(bootstrap), there is not need to handle it manually. The VCE way is the easy and correct one. So you might want to go with
                Code:
                xtreg ln_w age south, fe vce(bootstrap, seed(1))
                Best wishes

                Stata 18.0 MP | ORCID | Google Scholar

                Comment

                Working...
                X