Announcement

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

  • Bootstrap standard error

    I want to bootstrap the standard errors with 1000 replications. In my regression specification standard errors are clustered. How can I do this?
    Last edited by kamalesh pahurkar; 26 Aug 2023, 02:11.

  • #2
    Try the cluster() option of bootstrap.

    For example, using the auto dataset
    Code:
    regress mpg c.displacement, vce(cluster rep78)
    would become
    Code:
    regress mpg c.displacement, vce(bootstrap, reps(1000) cluster(rep78))
    Don't forget to set the seed beforehand.

    Comment


    • #3
      Thanks Joseph, what is seed? Why we have to set it?

      Comment


      • #4
        Kamalesh:
        setting the -seed- makes your data being the same every time you run the code:
        Code:
        . use "C:\Program Files\Stata17\ado\base\a\auto.dta"
        (1978 automobile data)
        
        . regress price mpg, vce(bootstrap, reps(200) seed(12345) dots(1))
        (running regress on estimation sample)
        
        Bootstrap replications (200)
        ----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5 
        ..................................................    50
        ..................................................   100
        ..................................................   150
        ..................................................   200
        
        Linear regression                                    Number of obs =        74
                                                             Replications  =       200
                                                             Wald chi2(1)  =     18.91
                                                             Prob > chi2   =    0.0000
                                                             R-squared     =    0.2196
                                                             Adj R-squared =    0.2087
                                                             Root MSE      = 2623.6529
        
        ------------------------------------------------------------------------------
                     |   Observed   Bootstrap                         Normal-based
               price | coefficient  std. err.      z    P>|z|     [95% conf. interval]
        -------------+----------------------------------------------------------------
                 mpg |  -238.8943    54.9405    -4.35   0.000    -346.5758   -131.2129
               _cons |   11253.06   1319.023     8.53   0.000     8667.824     13838.3
        ------------------------------------------------------------------------------
        
        . regress price mpg, vce(bootstrap, reps(200) seed(12345) dots(1))
        (running regress on estimation sample)
        
        Bootstrap replications (200)
        ----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5 
        ..................................................    50
        ..................................................   100
        ..................................................   150
        ..................................................   200
        
        Linear regression                                    Number of obs =        74
                                                             Replications  =       200
                                                             Wald chi2(1)  =     18.91
                                                             Prob > chi2   =    0.0000
                                                             R-squared     =    0.2196
                                                             Adj R-squared =    0.2087
                                                             Root MSE      = 2623.6529
        
        ------------------------------------------------------------------------------
                     |   Observed   Bootstrap                         Normal-based
               price | coefficient  std. err.      z    P>|z|     [95% conf. interval]
        -------------+----------------------------------------------------------------
                 mpg |  -238.8943    54.9405    -4.35   0.000    -346.5758   -131.2129
               _cons |   11253.06   1319.023     8.53   0.000     8667.824     13838.3
        ------------------------------------------------------------------------------
        
        . regress price mpg, vce(bootstrap, reps(200)  dots(1))
        (running regress on estimation sample)
        
        Bootstrap replications (200)
        ----+--- 1 ---+--- 2 ---+--- 3 ---+--- 4 ---+--- 5 
        ..................................................    50
        ..................................................   100
        ..................................................   150
        ..................................................   200
        
        Linear regression                                    Number of obs =        74
                                                             Replications  =       200
                                                             Wald chi2(1)  =     18.65
                                                             Prob > chi2   =    0.0000
                                                             R-squared     =    0.2196
                                                             Adj R-squared =    0.2087
                                                             Root MSE      = 2623.6529
        
        ------------------------------------------------------------------------------
                     |   Observed   Bootstrap                         Normal-based
               price | coefficient  std. err.      z    P>|z|     [95% conf. interval]
        -------------+----------------------------------------------------------------
                 mpg |  -238.8943   55.31386    -4.32   0.000    -347.3075   -130.4812
               _cons |   11253.06   1316.147     8.55   0.000      8673.46    13832.66
        ------------------------------------------------------------------------------
        
        .
        Last edited by Carlo Lazzaro; 26 Aug 2023, 03:20.
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          Thank you for clarifying, Dr. Carlo

          Comment


          • #6
            Kamalesh:
            Carlo (who just exploited Joseph's enlightening nitty gritty on this topic) is enough. Thanks.
            Kind regards,
            Carlo
            (Stata 19.0)

            Comment


            • #7
              I'm using ivreghdfe, facing an errror - option vce() not allowed

              Comment

              Working...
              X