Announcement

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

  • Regression table with output from many different regressions

    I want to run 12 different regressions and display the estimated betas, standard errors, and significance stars in the same table. The regressions I want to run are:

    loc covars “x2 x3 x4” // control variables

    forval v = 1 / 4 {

    reg y1`v’ x `covars’, r
    reg y2`v’ x `covars’, r
    reg y3`v’ x `covars’, r

    }

    The table that I want to produce is of the following format:
    beta_x11
    (se_x11)
    beta_x21
    (se_x21)
    beta_x31
    (se_x31)
    beta_x12
    (se_x12)
    beta_x22
    (se_x22)
    beta_x32
    (se_x32)
    beta_x13
    (se_x13)
    beta_x23
    (se_x23)
    beta_x33
    (se_x33)
    beta_x14
    (se_x14)
    beta_x24
    (se_x24)
    beta_x34
    (se_x34)

    where beta_x11 is the estimated beta on x from the regression of y11 on x, and se_x11 is the SE of the estimate, and so on.

    What is the best way to accomplish this? I have tried using outreg2, but I can only successfully produce the first row. Do I have to produce rows 2, 3 and 4 in a separate file and then merge the tables somehow? Or how do I accomplish this? I am not dead set on using outreg2 if there is another better tool. I was thinking of just saving the regression output in a matrix, but then I can’t figure out how to make it display the stars for significance level.

    Thanks in advance for help.


  • #2
    So something like this:

    Code:
    capture postutil clear
    tempfile results
    postfile handle int i int j float b float se using `results'
    
    forvalues i = 1/3 {
        forvalues j = 1/4 {
            regress y`i'`j' x `covars'
            post handle (`i') (`j') (`=_b[x]') (`=_se[x]')
        }
    }
    postclose handle
    
    use `results', clear
    isid i j, sort
    tabdisp i j, c(b se)
    Notes: Not tested. There may be errors, but this is the gist of it. It does not put the standard errors within parentheses, it will just display them below the coefficients.

    Added: Actually, you can simplify `=_b[x]' to just _b[x], and analogously for se in the -post handle- command of the above code.
    Last edited by Clyde Schechter; 12 Apr 2018, 12:30.

    Comment


    • #3
      Hi Clyde, thanks for the response! The code works well, but it doesn't display stars for significance, or as you said, put the standard errors in parentheses. It would be nice to find a way to accomplish this so that I don't have to do it by hand, or produce a different outreg file for each row and then cut and paste them together.

      Is there any way to stack output from outreg2, or another package? E.g., in this case, to produce the first row by "appending", and then stacking the next three rows? Or maybe using eststo / esttab would work?

      Comment


      • #4
        I don't actually use -outreg2- or -esttab- myself. So I'm afraid I can't help you there. Sorry.

        Comment

        Working...
        X