Announcement

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

  • How specify number of digits for stats in -esttab-?

    Dear listers,

    After running a number of regressions using -reghdfe-, I output the estimates into Excel using -esttab-,
    To later compare the effects of different explanatory variables in different samples, I want to discuss the marginal effect of 1 standard deviation (SD) of the explanatory variable of interest, hence add to the bottom of each table column the SD in the estimation sample, as well as its product with the marginal effect estimated. I also want to add a cell specifying whether or not the estimations displayed in that column did include year fixed effects. For now, I use the following code:

    Code:
    eststo clear
    eststo: reghdfe y x
       sum x if e(sample)
       estadd local sd = r(sd)
       estadd local sdeff = r(sd)*_b[x] 
       estadd local YFE "No" 
    esttab using "table", scsv b(3) se(3) replace star(* 0.1 ** 0.05 *** 0.01) stats(N r2 SD sdeff YFE, fmt(%9.0f %9.3f %9.3f %9.3f %9.3f))
    Follow-up questions on this:
    1. The most obvious weakness for now is that while the number of observations is displayed with 0 and the R2 with 3 digits after the comma, as intended, the following 2 statistics are displayed with far more columns although I have specified the desired number of digits in the same way. Would anyone happen to see how I have to change the code to get the desired number of digits?
    2. Ideally I'd like the number of observations to be didplayed not only with 0 after comma digits but also with some separation between every 3 pre comma digits to improve readability. How can I specify this?
    3. I am not sure what format I should specify for the local YFE, which is a text, although here it seems not to matter much that I just specify a number format?
    4. Any other things I should improve in this code?

    Thank you so much!
    PM

  • #2
    Ideally I'd like the number of observations to be didplayed [sic] not only with 0 after comma digits but also with some separation between every 3 pre comma digits to improve readability.
    First, some caveats. I don't use -esttab-, so the advice I'm giving here is based on the generic use of display formats in Stata. Official Stata commands almost always handle these things as expected; user-written commands might not.

    Since you refer to digits "after comma" I assume that you have -set dp comma-. To get separation bteween every 3 pre-comma digits, change the display format for N to %12.0fc. This will give you a period between groups of three digits to the left of the comma and no digits to the right. Note that you need to enlarge the width of the format from 9 to 12 to allow enough characters to include the periods: if you fail to do that, with a large number, Stata will omit the periods so as to fit the result into the width specified. Since you specified a width of 9, there would be at most 2 periods needed as separators, and I'm allowing an additional character "just in case," which is how I arrived at 12.

    I do not know the answers to your questions 1 and 3. I note that N and r2 come from -e()-, whereas the other statistics do not. It my be that -estadd-, a user-written package, does not process display formatting in the Stata standard way when the statistics are not taken from e() or r().

    Comment

    Working...
    X