Announcement

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

  • Add vector of values to regression result output table

    I am storing regression results as in the demonstration example below.

    Code:
     sysuse auto, clear 
    reg price mpg weight length  
    est store cars
    I also store q-values that correspond with this regression as a matrix (toy example).

    Code:
     mat demo = [0.5, 0.2, 0.8]
    I want to export a regression result table where the associated q-values appear below the standard errors, as in the quickly produced table below. The problem is that I cannot figure out how to add the vector of q-values to the stored regression results without turning it into a matrix that becomes incompatible with regression output packages such as esttab. How can I add these q-values to my regression output table?
    Click image for larger version

Name:	Screenshot 2022-03-27 121330.jpg
Views:	2
Size:	17.3 KB
ID:	1656531

    Last edited by Colette Salemi; 27 Mar 2022, 13:32.

  • #2
    I've heard about p values, but not q values. You can install estout from SSC and add the matrix to the estimation results.

    Code:
    sysuse auto, clear 
    reg price mpg weight length  
    est store cars
    mat demo = [0.5, 0.2, 0.8]
    mat colnames demo= "`:colname e(b)'"
    estadd matrix demo
    esttab, cells(b(star fmt(3)) se(par fmt(3)) demo(par([ ]) fmt(a1))) drop(_cons)
    Res.:

    Code:
    . esttab, cells(b(star fmt(3)) se(par fmt(3)) demo(par([ ]) fmt(a1))) drop(_cons)
    
    ----------------------------
                          (1)   
                        price   
                    b/se/demo   
    ----------------------------
    mpg               -86.789   
                     (83.943)   
                        [0.5]   
    weight              4.365***
                      (1.167)   
                        [0.2]   
    length           -104.868*  
                     (39.722)   
                        [0.8]   
    ----------------------------
    N                      74   
    ----------------------------

    Comment


    • #3
      Thank you so much. Q-values test for the probability of rejecting a true null, so they're really useful when you're testing many hypotheses. This fix is going to save me days worth of copy-paste. Thank you!
      Last edited by Colette Salemi; 27 Mar 2022, 15:09.

      Comment

      Working...
      X