Announcement

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

  • Update p-values outputted by esttab

    I am running a series of regressions for which I generate p-values using a randomization inference procedure and then export my results using esttab. Rather than add these to my regression table at the bottom using estadd, what I would like to do is overwrite the stored p-values so that they are included beneath each corresponding coefficient in the output table.

    In the following example code, I generate a create a vector of two p-values which I then attempt to add to the table. The issue is that rather than displaying below the first/second variable, the first/second p-values show up as separate variables called c1, c2. Is if possible to amend the code such that the value for "c1" displays as the p-value for "mpg" and the value for "c2" appears as the p-value for "_cons"?

    Example:

    Code:
    clear all
    set more off
    sysuse auto
    reg price mpg  
    est store example_reg
    mat pval= (0.123,0.456)
    estadd matrix pval= pval, replace
    esttab example_reg, cells(b(star fmt(%9.2f)) pval(par fmt(%9.3f)))
    Output:

    Click image for larger version

Name:	output.png
Views:	1
Size:	18.5 KB
ID:	1733085


  • #2
    Figured it out after a little experimentation, code here in case anyone else runs into this issue:

    Code:
    clear all
    set more off
    sysuse auto
    reg price mpg  
    est store example_reg
    mat pval= (0.123,0.456)
    mat colnames pval = "mpg" "_cons"
    estadd matrix newmat=pval, replace
    esttab example_reg, cells(b(star pvalue(newmat)) newmat(par))

    Comment


    • #3
      I would like to do exactly the same, but also report the original pvalues: In the first column have the estimates (beta with stars) according to the reg output and the p-values in parenthesis. And in the second column have estimates (beta with stars according to randomization inference) and then randomization inference p-values.

      clear all
      set more off
      sysuse auto
      eststo r1 : reg price mpg
      local t = _b[mpg]/_se[mpg]
      local p1 = round(2*ttail(e(df_r),abs(`t')), 0.001)
      local t = _b[_cons]/_se[_cons]
      local p2 = round(2*ttail(e(df_r),abs(`t')), 0.001)
      mat pval= ( `p1' , `p2' , 0.123,0.456)
      mat colnames pval = "mpg" "_cons" "mpg" "_cons"
      estadd matrix newmat=pval, replace
      esttab example_reg, cells(b(star pvalue(newmat)) newmat(par))



      However, the output is all messed up. I have also tried:


      mat pval= ( `p1' , `p2' \ 0.123,0.456) mat colnames pval = "mpg" "_cons"



      But it doesn't help;

      Comment


      • #4
        Let's ignore what "some randomization procedure" means for now and assume that we have some set of p-values, then an approach would involve duplicating estimates.

        Code:
        sysuse auto
        eststo r1 : reg price mpg
        eststo r2 : reg price mpg
        local t = _b[mpg]/_se[mpg]
        local p1 = round(2*ttail(e(df_r),abs(`t')), 0.001)
        local t = _b[_cons]/_se[_cons]
        local p2 = round(2*ttail(e(df_r),abs(`t')), 0.001)
        mat pval= ( `p1' , `p2' )
        mat colname pval= `:colnames e(b)'
        estadd mat pval: r1
        mat pval= (0.123,0.456)
        mat colname pval= `:colnames e(b)'
        estadd mat pval: r2
        esttab, cells(b(star pvalue(pval)) pval(par fmt(3)))
        Res.:

        Code:
        . esttab, cells(b(star pvalue(pval)) pval(par fmt(3)))
        
        --------------------------------------------
                              (1)             (2)   
                            price           price   
                           b/pval          b/pval   
        --------------------------------------------
        mpg             -238.8943***    -238.8943   
                          (0.000)         (0.123)   
        _cons            11253.06***     11253.06   
                          (0.000)         (0.456)   
        --------------------------------------------
        N                      74              74   
        --------------------------------------------

        Comment

        Working...
        X