Announcement

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

  • Is it possible to do nice LaTeX/Excel/Word tables with -reghdfe-?

    Hi everyone,

    I am trying to produce some nice tables with -reghdfe- by Sergio Correia.
    I am trying to follow his advices on his website. Here is what I am trying:

    Code:
    reghdfe ln_p engine_cap, absorb(brand model)
    estimates store model1
    *
    reghdfe ln_p engine_cap power_kw, absorb(brand model)
    estimates store model2
    *
    reghdfe ln_p engine_cap power_kw, absorb(brand model year)
    estimates store model3
    *
    reghdfe ln_p engine_cap power_kw i.ev_type_encode, absorb(brand model)
    estimates store model4
    *
    reghdfe ln_p engine_cap power_kw i.ev_type_encode i.regulation_mad##i.ev_type_encode, absorb(brand model)
    estimates store model5
    *
    reghdfe ln_q ln_p, absorb(brand model ev_type_encode)
    estimates store model6
    *
    reghdfe ln_q ln_p i.ev_type_encode i.regulation_mad##i.ev_type_encode, ///
    absorb(muni_code brand model) vce(cluster muni_code)
    estimates store model7
    
    *
    * Prepare estimates for -estout-
    estfe . model*, labels(brand "Brand FE" brand#model "Brand-Model FE" year "Year FE" ev_type_encode "EV FE")
    return list
    
    * Run estout/esttab
    esttab . model* using "C:/Users/miduarte/Desktop/reghdfe_tables_test.xlsx", indicate(`r(indicate_fe)') r2 replace
    
    * Return stored estimates to their previous state
    estfe . model*, restore

    But the tables produced are not very nice.

    Here is a small -dataex-:


    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str23 brand str60 model str4 fuel long(engine_cap muni_code) double power_kw float(fiscal_power mad_dum regulation_mad mad_prov ln_p ln_q) int year long ev_type_encode
    "ALFA ROMEO" "4C"     "0" 1742 28093 177 12.25 1 0 28  11.03489 1.3862944 2015 3
    "ALFA ROMEO" "4C"     "0" 1742 37274 177 12.25 0 0 37  11.03489 1.3862944 2015 3
    "ALFA ROMEO" "4C"     "0" 1742 47231 177 12.25 0 0 47  11.03489 1.3862944 2015 3
    "ALFA ROMEO" "4C"     "0" 1742  3031 177 12.25 0 0  3  11.03489 1.3862944 2015 3
    "ALFA ROMEO" "GIULIA" "1" 2143 47155 100 13.88 0 0 47 10.210972  2.397895 2016 3
    "ALFA ROMEO" "GIULIA" "1" 2143 47052 100 13.88 0 0 47 10.210972  2.397895 2016 3
    "ALFA ROMEO" "GIULIA" "1" 2143 46256 100 13.88 0 0 46 10.210972  2.397895 2016 3
    end
    label values ev_type_encode ev_type_encode
    label def ev_type_encode 3 "combustion", modify

    Any suggestions to improve my code, please?

    Thank you very much in advance!

  • #2
    1. The documentation has typos that you have copied. (Reported here.) You can omit the periods in -. model*-, so you're just running -esttab model*-.
    2. You don't have "brand#model" fixed effects. Replace that argument with simply "model" fixed effects. (The documentation is misleading on that point as well.) You may also want to add an argument for "muni_code" fixed effects.
    3. You are not actually exporting an .xlsx file, but a plain text file with a .xlsx extension. (Reported here.) If you want the results in a Word document, try exporting to a .rtf file. If you want the results in an Excel spreadsheet, try exporting to a .csv file. If you want the results in a LaTeX file, try exporting to a .tex file. IMHO, LaTeX produces by far the best results, and I would recommend that if it fits into your workflow.
    4. If the results are still not to your liking, address the above issues, post a screenshot of the results you got, and tell us in what way you think the tables are "not very nice". estout/esttab is quite customizable, and your specific concerns are probably addressable if we know what they are.

    Comment


    • #3
      Hi Nils Enevoldsen,

      Everything is solved and works perfectly!

      Thank you so much for your clear explanations.
      All the best Nils.

      Michael

      Comment

      Working...
      X