gvegayon / parallel

PARALLEL: Stata module for parallel computing
https://rawgit.com/gvegayon/parallel/master/ado/parallel.html
MIT License
117 stars 26 forks source link

display R-squared on bootstrap #29

Closed alnahedh closed 8 years ago

alnahedh commented 8 years ago

Hello, is there a way to display or extract out (outreg or esttab) the R-Squared when running a "parallel bs" routine? I'm running a basic regression of the form parallel bs, reps(1000): reg y x1 x2 All I'm getting on the results screen is the number of obs and replications..

Help or future implementation of this is appreciated..

Thanks, Saad

gvegayon commented 8 years ago

Hi there,

What I would do is to actually bootstrap the R-squared values as well, here is how:

parallel setclusters 4
sysuse auto
parallel bs, rep(1000) exp(_b e(r2)): reg price foreign rep78 mpg

Which returns something like this:

--------------------------------------------------------------------------------
Parallel Computing with Stata (by GVY)
Clusters   : 4
pll_id     : qw4s1kfp49
Running at : /home/george
Randtype   : datetime
Waiting for the clusters to finish...
cluster 0004 has exited without error...
cluster 0001 has exited without error...
cluster 0003 has exited without error...
cluster 0002 has exited without error...
--------------------------------------------------------------------------------
Enter -parallel printlog #- to checkout logfiles.
--------------------------------------------------------------------------------

parallel bootstrapping                          Number of obs      =        69
                                                Replications       =      1000

      command:  regress price foreign rep78 mpg
  [_eq2]_bs_1:  e(r2)

------------------------------------------------------------------------------
             |   Observed   Bootstrap                         Normal-based
             |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
_eq1         |
     foreign |   1023.208   650.8838     1.57   0.116    -252.5008    2298.917
       rep78 |   432.8004   300.4363     1.44   0.150    -156.0439    1021.645
         mpg |  -292.4342   62.81709    -4.66   0.000    -415.5535    -169.315
       _cons |   10586.48   1610.768     6.57   0.000     7429.438    13743.53
-------------+----------------------------------------------------------------
_eq2         |
       _bs_1 |   .2667079   .0898997     2.97   0.003     .0905077    .4429081
------------------------------------------------------------------------------

So, if you use outreg2, you get

. outreg2 using parallelbs, replace

Which looks something like this

    (1) (2)
VARIABLES   _eq1    _eq2

foreign 1,023   
    (650.9) 
rep78   432.8   
    (300.4) 
mpg -292.4***   
    (62.82) 
_bs_1       0.267***
        (0.0899)
Constant    10,586***   
    (1,611) 

Observations    69  69
Standard errors in parentheses      
*** p<0.01, ** p<0.05, * p<0.1      

Hope it helps!