Announcement

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

  • Add headers to groups of variables in output from estout?

    I have several specifications that -estout- groups into a coefficient table. I'm using -estout- version 3.20 from the SSC and the March 3, 2016 update of Stata 14.1 MP. So far, I have code like this:
    Code:
    sysuse auto, clear
    
    gen mpg2 = mpg^2
    gen mpg_log = log(mpg)
    
    regress price mpg* headroom
    est store est1
    
    regress price mpg* headroom length
    est store est2
    
    estout est?, drop(headroom)
    which displays
    Code:
    --------------------------------------
                         est1         est2
                            b            b
    --------------------------------------
    mpg              4073.189     4132.779
    mpg2            -33.14309    -33.83749
    mpg_log         -61992.16    -62350.48
    length                        3.698642
    _cons            124383.9     123889.8
    --------------------------------------
    I'd like to have output that looks like this:
    Code:
    --------------------------------------
                         est1         est2
                            b            b
    --------------------------------------
    Mileage variables
    mpg                      4073.189     4132.779
    mpg2                    -33.14309    -33.83749
    mpg_log                 -61992.16    -62350.48
    
    length                        3.698642
    
    _cons                    124383.9     123889.8
    --------------------------------------
    This is a rough approximation because I created it manually, but basically, I'd like to group certain variables under a header, within the first column, and be able to separate groups of variables with empty lines in the table. I'm sure there's a way to do this manually, by creating empty observations, but it's not clear to me from the -estout- documentation if there is a way to use -estout- for this.

  • Nils Enevoldsen
    replied
    The "empty" regressor in order(mpg mpg2 mpg_log "\ ") is the "\ ". If you have order(mpg mpg2 mpg_log foo) then esttab will show the regressors "mpg", "mpg2", "mpg_log", and "foo". "Foo" won't have any coefficients listed, because they don't exist. If you have order(mpg mpg2 mpg_log "\ ") then esttab will show the regressors "mpg", "mpg2", "mpg_log", and " ".

    Leave a comment:


  • Alessio Gaggero
    replied
    Originally posted by Nils Enevoldsen View Post
    Two suggestions, assuming you're exporting to LaTeX:
    1. Put something like \rule{0pt}{4ex} before the category name to add some vertical space
    2. Create a new "empty" regressor with order(mpg mpg2 mpg_log "\ ")
    If you're not using LaTeX, let me know, and we can come up with some other language-specific hack.
    Dear Nils,

    I was wondering if you can expand on this a little bit. How exactly do you create an "empty" regressor?

    thanks or the help
    Alessio

    Leave a comment:


  • Michael Anbar
    replied
    Originally posted by Nils Enevoldsen View Post
    For SMCL, I think adding a regressor named "{break}" will work. Can you try that? I'm still not sure what to do about tab-delimited, though.
    That works for SMCL, but the only solution I can think of for tab-delimited or text files is to load the file into Stata as-is (read the text file into a dataset) and add observations, i.e. table rows, and blank out the lines. That's a clumsy solution at best, though.

    Leave a comment:


  • Nils Enevoldsen
    replied
    For SMCL, I think adding a regressor named "{break}" will work. Can you try that? I'm still not sure what to do about tab-delimited, though.

    Leave a comment:


  • Michael Anbar
    replied
    Nils Enevoldsen Unfortunately, I'm not exporting to LaTeX; I'm exporting to text and tab-delimited files (specifically, the -fixed- style and the -tab- styles) and displaying the table in Stata (so the default SMCL style). Adding an extra regressor doesn't appear to work for these styles.

    Leave a comment:


  • Nils Enevoldsen
    replied
    Two suggestions, assuming you're exporting to LaTeX:
    1. Put something like \rule{0pt}{4ex} before the category name to add some vertical space
    2. Create a new "empty" regressor with order(mpg mpg2 mpg_log "\ ")
    If you're not using LaTeX, let me know, and we can come up with some other language-specific hack.

    Leave a comment:


  • Michael Anbar
    replied
    Nils Enevoldsen Does this support adding line breaks between categories? This code
    Code:
    estout est?, drop(headroom) refcat(mpg "Mileage" length "Other", nolabel)
    displays
    Code:
    --------------------------------------
                         est1         est2
                            b            b
    --------------------------------------
    Mileage                              
    mpg              4073.189     4132.779
    mpg2            -33.14309    -33.83749
    mpg_log         -61992.16    -62350.48
    Other                                
    length                        3.698642
    _cons            124383.9     123889.8
    --------------------------------------
    which is much closer to what I need, but it's not perfect. I thought about adding reference category labels below variables, e.g. -mpg_log- in this case, but the -refcat- option doesn't support placing some labels above variables and other labels below. Compound quotes, i.e.
    Code:
    estout est?, drop(headroom) refcat(mpg `""" "Mileage""' length "Other", nolabel)
    and manual line breaks, i.e. prefixing the string with "\n" or "{break}", don't work either.

    My goal is a table like this (for example):
    Code:
    --------------------------------------
                         est1         est2
                            b            b
    --------------------------------------
    Mileage                          
    mpg              4073.189     4132.779
    mpg2            -33.14309    -33.83749
    mpg_log         -61992.16    -62350.48
    
    Other                          
    length                        3.698642
    _cons            124383.9     123889.8
    --------------------------------------
    Last edited by Michael Anbar; 24 Mar 2016, 10:28.

    Leave a comment:


  • Nils Enevoldsen
    replied
    http://repec.org/bocode/e/estout/hlp_estout.html#refcat

    Leave a comment:

Working...
X