Announcement

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

  • P value in outreg2 statistics

    Hi all,

    My question concerns user-written commands boottest and outreg2.

    I would like to display the p-value of boottest in the stats() of outreg2 instead of p-values from the user-written reghdfe command.

    I tried the following code. I believe estadd and erepost are from ssc install.

    Code:
    reghdfe Y X1 X2, abs(i.id) vce(cluster canton)
    boottest X1 =0, seed(1234567890) reps(9999) weighttype(rademacher) bootcluster(canton) boottype(wild) nograph
    estadd scalar pval = r(p)
    mat b=e(pval)
    erepost b=b
    cap n outreg2 using "$results\results.xls", replace   stats(coef pval) nocons
    This gives the error "conformability error" for the line of code "erepost b=b"

    Could someone please let me know where I've gone wrong?

  • #2
    outreg2 is an old command with a lack of flexibility in its options. The error in your code arises from attempting to replace a \(1\times (k+1)\) matrix with a scalar (where \(k\) is the number of RHS variables). You can fix this and output the p-values in place of the coefficients, but the stars change as well as they are computed based on the available statistics, where:

    $$\frac{\hat{\beta}}{SE} = t.$$

    Here is some corrected code based on the Grunfeld dataset that will successfully replace the e(b) matrix. It may be easier to modify the ado of outreg2 to achieve what you want rather than additionally rescaling the variance estimates.


    Code:
    clear all
    webuse grunfeld
    regress invest mvalue kstock, vce(cluster company)
    local res
    foreach var in `:colname e(b)'{
        boottest `var' =0, seed(1234567890) reps(9999) weighttype(rademacher) boottype(wild) bootcluster(company) nograph
        local res "`res' `r(p)'"
    }
    local res= substr(subinstr("`res'", " ", ", ", .), 2,.)
    mat res= [`res']
    mat colnames res= `:colname e(b)'
    erepost b=res, rename
    
    outreg2 using myfile.txt, nose replace seeout

    Comment


    • #3
      Thank you so much Andrew!

      Comment

      Working...
      X