Announcement

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

  • esttab multiple stored results in disk

    Hello!

    I'm running several panel data regressions with millions of observations that take many hours. I´m unsure of which coefficients I´ll want to report and thus would like the option to store the estimates on disk to export later.

    An example of code would be:

    Code:
    clear
    cd "C:\Users\helder.ascosta\Desktop\tests"
    eststo clear
    sysuse auto
    eststo: reg price weight mpg
    eststo: reg price weight mpg foreign
    eststo: reg gear_ratio
    esttab
    I found this loop in statlist that allows to save multiple results in a single file.

    Code:
    estimates dir
    global estlist `r(names)'
    local j = 0
    foreach est of global estlist{
        est rest `est'
        if `j' > 0 estimates save results, append
        if `j' == 0 estimates save results, replace
        local j = 1
    }
    But if I clear the memory, as I do to run the following set of regressions, and later load the stored estimates, esttab only gives one set of results, although I can choose each one.

    Code:
    est clear
    est use results
    esttab
    est use results, number(2)
    esttab
    Thus, my goal is to be able to clear the memory and still get the same table produced from the first esttab.

    Thank you for your time!
    Best,
    Hélder

  • #2
    estout is from SSC, as you are asked to explain (FAQ Advice #12). After estimates use, again

    Code:
    estimates store result_j
    for \(j= 1, \cdots, n\), before running esttab.

    Comment


    • #3
      Hello Andrew!
      Thank you for your reply.
      I'm unsure of what you mean. I adapted the code in the following way, which is my interpretation of your comment, but the problem remains:

      Code:
      clear
      cd "C:\Users\helder.ascosta\Desktop\tests"
      est clear
      sysuse auto
      reg price weight mpg
      estimates store result_1
      reg price weight mpg foreign
      estimates store result_2
      reg gear_ratio
      estimates store result_3
      esttab _all
      
      estimates dir
      global estlist `r(names)'
      local j = 0
      foreach est of global estlist{
          est rest `est'
          if `j' > 0 estimates save results, append
          if `j' == 0 estimates save results, replace
          local j = 1
      }
      
      
      est clear
      est use results
      esttab
      est use results, number(2)
      esttab
      Best,
      Hélder

      Comment


      • #4
        Code:
        clear
        eststo clear
        sysuse auto
        eststo: reg price weight mpg
        estimates save m1
        reg price weight mpg foreign
        estimates save m2
        eststo: reg gear_ratio
        estimates save m3
        esttab
        estimates clear
        forval j=1/3{
            estimates use m`j'
            estimates store results_`j'
        }
        esttab results_*
        Res.:

        Code:
        . esttab results_*
        
        ------------------------------------------------------------
                              (1)             (2)             (3)  
                            price           price      gear_ratio  
        ------------------------------------------------------------
        weight              1.747**         3.465***                
                           (2.72)          (5.49)                  
        
        mpg                -49.51           21.85                  
                          (-0.57)          (0.29)                  
        
        foreign                            3673.1***                
                                           (5.37)                  
        
        _cons              1946.1         -5853.7           3.015***
                           (0.54)         (-1.73)         (56.84)  
        ------------------------------------------------------------
        N                      74              74              74  
        ------------------------------------------------------------
        t statistics in parentheses
        * p<0.05, ** p<0.01, *** p<0.001

        Comment


        • #5
          Thank you Andrew, it worked!

          Comment

          Working...
          X