Announcement

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

  • Weave one Latex table containing summary statistics and regression estimates?

    I want to build a standard Latex Asset Pricing table in Stata. Each 2 rows contain information about one trading strategy. And the columns are average returns, sharpe ratio, CAPM alpha and Fama-French 3 factor alpha. The first two are summary statistics, the last two are regression coefficients that come with standard errors. I want the standard error in parenthesis and placed under the corresponding coefficient estimate. The Stata script should write a .tex file that contains something a table fragment like this:

    ```
    portfolio1 & 0.01 & 1.00 & 0.01 & 0.01 \\
    & & & (0.01) & (0.01) \\
    portfolio2 & 0.01 & 1.00 & 0.01 & 0.01 \\
    & & & (0.01) & (0.01) \\
    ```

    I can add the missing Latex header/footer later in my Latex file.

    As a starting point, here is a working example for regression estimates only:

    ```
    sysuse auto, clear

    eststo clear

    eststo: reg price mpg, nocons
    eststo: reg trunk mpg, nocons

    esttab using "test.tex", ///
    fragment noobs nomtitles nonumbers nowrap booktabs nogaps nolines ///
    style(tex) replace collabels(none) ///
    cells(b(star fmt(%9.2f)) se(par)) compress

    eststo clear

    eststo: reg price mpg, nocons
    eststo: reg trunk mpg, nocons

    esttab using "test.tex", ///
    fragment noobs nomtitles nonumbers nowrap booktabs nogaps nolines ///
    style(tex) append collabels(none) ///
    cells(b(star fmt(%9.2f)) se(par)) compress
    ```

    This essentially gives me the alpha columns, but not the average return/sharpe ratio columns. In the working example, any idea on how to add, say the mean of "price" and the mean of "trunk" in separate columns?

    Thank you!

    (I posted this on stack exchange but got shut down with no answer for being of topic.)

  • #2
    esttab/estout is from Stata Journal (FAQ Advice #12)

    Code:
    sysuse auto, clear
    eststo clear
    eststo: reg price mpg, nocons
    eststo: reg trunk mpg, nocons
    eststo: mean price 
    eststo: mean trunk
    esttab est*
    Res.:

    Code:
    . esttab est*
    
    ----------------------------------------------------------------------------
                          (1)             (2)             (3)             (4)   
                        price           trunk            Mean            Mean   
    ----------------------------------------------------------------------------
    mpg                 253.6***        0.573***                                
                      (12.22)         (15.66)                                   
    
    price                                              6165.3***                
                                                      (17.98)                   
    
    trunk                                                               13.76***
                                                                      (27.67)   
    ----------------------------------------------------------------------------
    N                      74              74              74              74   
    ----------------------------------------------------------------------------
    t statistics in parentheses
    * p<0.05, ** p<0.01, *** p<0.001

    Comment


    • #3
      Fantastic! That was easier than I thought. That solves my issue - thank you!

      In case you know - any idea how to suppress the standard errors for the means? (But keep the standard errors for the regression coefficients)
      In my actual application I want to show a Sharpe ratio. And Sharpe ratios don't come with standard errors. So right now I generate a variable

      sum returns
      gen sharpe_ratio = r(mean)/r(sd)
      eststo: mean sharpe_ratio

      Doing this prints (.) for the standard errors. How do I just display nothing instead?
      (I can search and delete the (.) using filefilter. it's just an unelegant solution that creates additional files and clutter)

      Comment


      • #4
        The esttab, substitute option might work for you.

        Comment


        • #5
          Yes, that does it. Thanks!

          Comment

          Working...
          X