Home » excel » stata – Export p-values from reghdfe to Excel

stata – Export p-values from reghdfe to Excel

Posted by: admin May 14, 2020 Leave a comment

Questions:

I am trying to export p-values to Excel from the Stata community-contributed command reghdfe:

// get data
use "http://www.stata-press.com/data/r9/nlswork.dta", clear
xtset idcode year

// run regression
reghdfe ttl_exp age not_smsa msp nev_mar, abs(idcode year) cluster(idcode)

// store numbers
local rmse = `e(rmse)'  

// export
putexcel A1 = (`rmse') using "export.xlsx" , modify // this works

How can I get the p-value of a given variable (say msp) exported to the same Excel document?

The ereturn list does not suggest any helpful info, e(V) contains only the covariance matrix.

Cross posted on Statalist.

How to&Answers:

The following works for me:

use "http://www.stata-press.com/data/r9/nlswork.dta", clear
xtset idcode year

reghdfe ttl_exp age not_smsa msp nev_mar, abs(idcode year) cluster(idcode)

------------------------------------------------------------------------------
             |               Robust
     ttl_exp |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
         age |   -.008044   .0618821    -0.13   0.897     -.129366    .1132781
    not_smsa |  -.1616256   .0812134    -1.99   0.047    -.3208472   -.0024039
         msp |   -.004893   .0634814    -0.08   0.939    -.1293505    .1195645
     nev_mar |    -.36351   .0955207    -3.81   0.000    -.5507816   -.1762384
------------------------------------------------------------------------------

local pval = (2 * ttail(e(df_r), abs(_b[msp] / _se[msp]) ) )

display `pval'
.93856498

putexcel A1 = (`pval') using "export.xlsx", modify