Announcement

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

  • Publishing Regression Coefficients and Elasticity in the same report

    Hi Statalisters! Beginner here.

    I ran several regular (OLS) regressions and calculated the elasticities. I want to display the coefficients and elasticities in the same excel file. I also want the p values to be displayed for the elasticities. How do I do it?

    This is what I am doing right now:

    Code:
    sysuse auto
    eststo one: reg price mpg
    eststo two: margins, eyex(mpg)
    eststo three: reg price mpg rep78
    eststo four: margins, eyex(mpg)
    esttab using "trial.csv", replace
    What I want is something like this:
    (1) (2)
    price price
    mpg -238.9*** -271.6***
    (-4.50) (-4.70)
    rep78 667.0
    (1.95)
    _cons 11253.1*** 9657.8***
    (9.61) (7.17)
    N 74 69
    eyex -.9859019 -1.098493
    (.3341136) (.32538)
    t statistics in parentheses

    What I get is this:
    (1) (2) (3) (4)
    price price price price
    mpg -238.9*** -238.9*** -271.6*** -271.6***
    (-4.50) (-4.50) (-4.70) (-4.70)
    rep78 667.0 667.0
    (1.95) (1.95)
    _cons 11253.1*** 11253.1*** 9657.8*** 9657.8***
    (9.61) (9.61) (7.17) (7.17)
    N 74 74 69 69
    t statistics in parentheses
    ="* p<0.05 ** p<0.01 *** p<0.001"
    (P.S. I tried my best with the table - try as I might, the row borders are not showing)
    Last edited by Uma Ravi; 11 Apr 2021, 06:55.

  • #2
    esttab is from the Stata Journal/ SSC. You need the -post- option after margins to post the results to e(b) and e(V).

    Code:
    sysuse auto
    eststo one: reg price mpg
    eststo two: margins, eyex(mpg) post
    eststo three: reg price mpg rep78
    eststo four: margins, eyex(mpg) post
    esttab using "trial.csv", replace
    This will still give you 4 sets of estimates. If you want to append estimates, see appendmodels by Ben Jann. Otherwise, to include the elasticities and t-statistics as scalars, save these and use estadd to send them to e(). You have to include the coefficients and t-statistics separately. See the attached link for an illustration.

    https://www.statalist.org/forums/for...gression-table

    Comment


    • #3
      Hi Andrew Musau ,

      With this,
      sysuse auto eststo one: reg price mpg eststo two: margins, eyex(mpg) post eststo three: reg price mpg rep78 eststo four: margins, eyex(mpg) post esttab using "trial.csv", replace
      I am still getting
      Code:
       
      (1) (2) (3) (4)
      price price price price
      mpg -238.9*** -238.9*** -271.6*** -271.6***
      (-4.50) (-4.50) (-4.70) (-4.70)
      rep78 667.0 667.0
      (1.95) (1.95)
      _cons 11253.1*** 11253.1*** 9657.8*** 9657.8***
      (9.61) (9.61) (7.17) (7.17)
      N 74 74 69 69
      t statistics in parentheses
      ="* p<0.05 ** p<0.01 *** p<0.001"
      For some reason, one of the regression and one of the margin command's storage is not properly happening.

      Comment


      • #4
        This is what I get:

        Code:
        . esttab
        
        ----------------------------------------------------------------------------
                              (1)             (2)             (3)             (4)   
                            price                           price                   
        ----------------------------------------------------------------------------
        mpg                -238.9***       -0.986**        -271.6***       -1.098** 
                          (-4.50)         (-2.95)         (-4.70)         (-3.38)   
        
        rep78                                               667.0                   
                                                           (1.95)                   
        
        _cons             11253.1***                       9657.8***                
                           (9.61)                          (7.17)                   
        ----------------------------------------------------------------------------
        N                      74              74              69              69   
        ----------------------------------------------------------------------------
        t statistics in parentheses
        * p<0.05, ** p<0.01, *** p<0.001

        2 things that you can do:

        1. Add -estimates clear- to the top of your code
        2. Re-install estout

        Code:
        ssc install estout, replace

        Comment


        • #5
          Andrew Musau Thank you for -estimates clear- command. I think it flushed out the previously stored estimates.
          However, my initial problem persists. I was hoping to display elasticities and regression coefficients in the same file for several regressions, not just one.

          Code:
          sysuse auto
          eststo one: reg price mpg
          margins, eyex(mpg) post
          estadd local elast "`=r(table)[1,1]'"
          esttab using "trial.csv", scalar("elast Elast") replace
          gives the following (without the value of elasticity) - just the placeholder

          Code:
          ----------------------------
                                (1)   
                              price   
          ----------------------------
          mpg                -238.9***
                            (-4.50)   
          
          _cons             11253.1***
                             (9.61)   
          ----------------------------
          N                      74   
          Elast                       
          ----------------------------
          t statistics in parentheses
          * p<0.05, ** p<0.01, *** p<0.001
          And I still am confused about how to add another regression result on the right side of this esttab

          Comment


          • #6
            Code:
            sysuse auto
            qui reg price mpg
            margins, eyex(mpg) post
            local elast "`=r(table)[1,1]'"
            eststo one: reg price mpg
            estadd local elast= `:di %4.3f `elast''
            qui reg price mpg weight
            margins, eyex(mpg) post
            local elast "`=r(table)[1,1]'"
            eststo two: reg price mpg weight
            estadd local elast= `:di %4.3f `elast''
            esttab one two, scalar("elast Elast")
            Res.:

            Code:
            .
            . esttab one two, scalar("elast Elast")
            
            --------------------------------------------
                                  (1)             (2)   
                                price           price   
            --------------------------------------------
            mpg                -238.9***       -49.51   
                              (-4.50)         (-0.57)   
            
            weight                              1.747** 
                                               (2.72)   
            
            _cons             11253.1***       1946.1   
                               (9.61)          (0.54)   
            --------------------------------------------
            N                      74              74   
            Elast               -.986           -.197   
            --------------------------------------------
            t statistics in parentheses
            * p<0.05, ** p<0.01, *** p<0.001
            Last edited by Andrew Musau; 12 Apr 2021, 08:16.

            Comment


            • #7
              This is perfect. Thank you so much!

              Comment

              Working...
              X