Announcement

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

  • what does estimates store store?

    I've checked resources online but I'm not sure what all things estimates store stores after running a logistic regression. I need to be able to extract the coef, lci, uci, pval from the stored regression output and I'm not sure how to access those. Thanks in advance!

  • #2
    The specific statistics you mention are found in r(table) after an estimation command. But those are not stored with -estimates store-. However, you can still find the coefficients in the pseudo-matrix _b[]. Combining that with the standard errors that are easily accessed in pseudo-matrix _se[], from there you can just calculate the confidence bounds and p-values yourself in the usual way.

    To answer your question more directly, whatever shows up in e() after an estimation command is what -estimates store- stores. If you aren't sure what -e()- has after a certain command, run the command and then run -ereturn list- to see.

    Comment


    • #3
      How do I store the regression output as pseudo-matrix and then retrieve _b[] and _se[] later?

      Comment


      • #4
        You can do that with estimates store and estimates restore, see the following example.
        Code:
        . sysuse auto
        (1978 Automobile Data)
        
        . qui reg price mpg weight
        
        . di _b[mpg]
        -49.512221
        
        . di _se[mpg]
        86.156039
        
        . estimates store M
        
        . 
        . qui reg price headroom i.foreign
        
        . capture noisily di _b[mpg]
        [mpg] not found
        
        . capture noisily di _se[mpg]
        [mpg] not found
        
        . 
        . estimates restore M
        (results M are active now)
        
        . di _b[mpg]
        -49.512221
        
        . di _se[mpg]
        86.156039

        Comment


        • #5
          The model results in r(table) are, as Clyde noted, not included among the "estimation results" that estimates store saves. (The active estimation results it saves are described at the end of the output of, for example, the help logistic command.)

          The community contributed estadd command, part of the estout package written byBen Jann and available from SSC (see the output of ssc describe estout) allows you to add a copy of r(table) to the estimates, so it is then stored by estimates store and retrieved by estimates restore. Here's an example.
          Code:
          sysuse auto, clear
          regress mpg weight i.foreign
          ereturn list
          return list
          matrix list r(table)
          estadd matrix table = r(table)
          estimates store gnxl
          ereturn clear
          estimates restore gnxl
          ereturn list
          matrix list e(table)
          Code:
          . sysuse auto, clear
          (1978 Automobile Data)
          
          . regress mpg weight i.foreign
          
                Source |       SS           df       MS      Number of obs   =        74
          -------------+----------------------------------   F(2, 71)        =     69.75
                 Model |   1619.2877         2  809.643849   Prob > F        =    0.0000
              Residual |  824.171761        71   11.608053   R-squared       =    0.6627
          -------------+----------------------------------   Adj R-squared   =    0.6532
                 Total |  2443.45946        73  33.4720474   Root MSE        =    3.4071
          
          ------------------------------------------------------------------------------
                   mpg |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
          -------------+----------------------------------------------------------------
                weight |  -.0065879   .0006371   -10.34   0.000    -.0078583   -.0053175
                       |
               foreign |
              Foreign  |  -1.650029   1.075994    -1.53   0.130      -3.7955    .4954422
                 _cons |    41.6797   2.165547    19.25   0.000     37.36172    45.99768
          ------------------------------------------------------------------------------
          
          . ereturn list
          
          scalars:
                            e(N) =  74
                         e(df_m) =  2
                         e(df_r) =  71
                            e(F) =  69.74846262000308
                           e(r2) =  .6627029116028815
                         e(rmse) =  3.407059285651584
                          e(mss) =  1619.287698167387
                          e(rss) =  824.1717612920727
                         e(r2_a) =  .6532015851691599
                           e(ll) =  -194.1830643938065
                         e(ll_0) =  -234.3943376482347
                         e(rank) =  3
          
          macros:
                      e(cmdline) : "regress mpg weight i.foreign"
                        e(title) : "Linear regression"
                    e(marginsok) : "XB default"
                          e(vce) : "ols"
                       e(depvar) : "mpg"
                          e(cmd) : "regress"
                   e(properties) : "b V"
                      e(predict) : "regres_p"
                        e(model) : "ols"
                    e(estat_cmd) : "regress_estat"
          
          matrices:
                            e(b) :  1 x 4
                            e(V) :  4 x 4
          
          functions:
                       e(sample)   
          
          . return list
          
          scalars:
                        r(level) =  95
          
          matrices:
                        r(table) :  9 x 4
          
          . matrix list r(table)
          
          r(table)[9,4]
                                      0b.          1.            
                      weight     foreign     foreign       _cons
               b  -.00658789           0  -1.6500291   41.679702
              se   .00063711           .   1.0759941   2.1655472
               t  -10.340218           .  -1.5334927    19.24673
          pvalue   8.283e-16           .    .1295987   6.896e-30
              ll  -.00785825           .  -3.7955004   37.361724
              ul  -.00531752           .   .49544223   45.997681
              df          71          71          71          71
            crit   1.9939434   1.9939434   1.9939434   1.9939434
           eform           0           0           0           0
          
          . estadd matrix table = r(table)
          
          added matrix:
                        e(table) :  9 x 4
          
          . estimates store gnxl
          
          . ereturn clear
          
          . estimates restore gnxl
          (results gnxl are active now)
          
          . matrix list e(table)
          
          e(table)[9,4]
                                      0b.          1.            
                      weight     foreign     foreign       _cons
               b  -.00658789           0  -1.6500291   41.679702
              se   .00063711           .   1.0759941   2.1655472
               t  -10.340218           .  -1.5334927    19.24673
          pvalue   8.283e-16           .    .1295987   6.896e-30
              ll  -.00785825           .  -3.7955004   37.361724
              ul  -.00531752           .   .49544223   45.997681
              df          71          71          71          71
            crit   1.9939434   1.9939434   1.9939434   1.9939434
           eform           0           0           0           0
          
          .

          Comment


          • #6
            Originally posted by William Lisowski View Post
            The community contributed estadd command, part of the estout package [...] allows you to add a copy of r(table) to the estimates, so it is then stored by estimates store and retrieved by estimates restore.
            Not to take away from estadd but this seems unnecessarily complicated. You can just

            Code:
            estimates replay name_of_stored_results
            to bring back* r(table).


            * Technically, the p-values and CIs are re-calculated from the coefficients and covariance matrix, but that only takes a couple of milliseconds.

            Comment

            Working...
            X