Announcement

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

  • Multiple scalars and esttab

    How could we add multiple scalars for creating table using esttab? Not using estout!

  • #2
    Perhaps reviewing the output of help estadd will show you a way to add the scalars to the estimates reusults prior to calling esttab, so that they can be included in the same way as scalars normally part of the estimates results.

    Comment


    • #3
      It works for only one scalar, but not for multiple scalars!

      Comment


      • #4
        Here is an example with two scalars added to the end of the esttab output. Do I misunderstand what you are trying to accomplish?
        Code:
        . sysuse auto, clear
        (1978 Automobile Data)
        
        . reg price mpg
        
              Source |       SS           df       MS      Number of obs   =        74
        -------------+----------------------------------   F(1, 72)        =     20.26
               Model |   139449474         1   139449474   Prob > F        =    0.0000
            Residual |   495615923        72  6883554.48   R-squared       =    0.2196
        -------------+----------------------------------   Adj R-squared   =    0.2087
               Total |   635065396        73  8699525.97   Root MSE        =    2623.7
        
        ------------------------------------------------------------------------------
               price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
        -------------+----------------------------------------------------------------
                 mpg |  -238.8943   53.07669    -4.50   0.000    -344.7008   -133.0879
               _cons |   11253.06   1170.813     9.61   0.000     8919.088    13587.03
        ------------------------------------------------------------------------------
        
        . estadd scalar wl_1 = 42
        
        added scalar:
                       e(wl_1) =  42
        
        . estadd scalar wl_2 = 8
        
        added scalar:
                       e(wl_2) =  8
        
        . esttab ., stats(wl_1 wl_2)
        
        ----------------------------
                              (1)  
                            price  
        ----------------------------
        mpg                -238.9***
                          (-4.50)  
        
        _cons             11253.1***
                           (9.61)  
        ----------------------------
        wl_1                   42  
        wl_2                    8  
        ----------------------------
        t statistics in parentheses
        * p<0.05, ** p<0.01, *** p<0.001
        
        .
        If this is not what you want, please review the Statalist FAQ linked to from the top of the page, as well as from the Advice on Posting link on the page you used to create your post. Note especially sections 9-12 on how to best pose your question. Sample code that demonstrates the use of esttab to which you want to add scalars would make your intent clearer. The more you help others understand your problem, the more likely others are to be able to help you solve your problem.

        Comment


        • #5
          Sorry I did not explain properly. I want exactly like this. But I need to add one more regression.
          . eststo clear

          . eststo : reg price mpg

          Source | SS df MS Number of obs = 74
          -------------+---------------------------------- F(1, 72) = 20.26
          Model | 139449474 1 139449474 Prob > F = 0.0000
          Residual | 495615923 72 6883554.48 R-squared = 0.2196
          -------------+---------------------------------- Adj R-squared = 0.2087
          Total | 635065396 73 8699525.97 Root MSE = 2623.7

          ------------------------------------------------------------------------------
          price | Coef. Std. Err. t P>|t| [95% Conf. Interval]
          -------------+----------------------------------------------------------------
          mpg | -238.8943 53.07669 -4.50 0.000 -344.7008 -133.0879
          _cons | 11253.06 1170.813 9.61 0.000 8919.088 13587.03
          ------------------------------------------------------------------------------
          (est1 stored)

          . estadd scalar wl_1 = 42

          added scalar:
          e(wl_1) = 42

          . estadd scalar wl_2 = 8

          added scalar:
          e(wl_2) = 8

          . eststo : reg price mpg

          Source | SS df MS Number of obs = 74
          -------------+---------------------------------- F(1, 72) = 20.26
          Model | 139449474 1 139449474 Prob > F = 0.0000
          Residual | 495615923 72 6883554.48 R-squared = 0.2196
          -------------+---------------------------------- Adj R-squared = 0.2087
          Total | 635065396 73 8699525.97 Root MSE = 2623.7

          ------------------------------------------------------------------------------
          price | Coef. Std. Err. t P>|t| [95% Conf. Interval]
          -------------+----------------------------------------------------------------
          mpg | -238.8943 53.07669 -4.50 0.000 -344.7008 -133.0879
          _cons | 11253.06 1170.813 9.61 0.000 8919.088 13587.03
          ------------------------------------------------------------------------------
          (est2 stored)

          . estadd scalar wl_1 = 42

          added scalar:
          e(wl_1) = 42

          . estadd scalar wl_2 = 8

          added scalar:
          e(wl_2) = 8

          . esttab, stats(wl_1 wl_2)

          --------------------------------------------
          (1) (2)
          price price
          --------------------------------------------
          mpg -238.9*** -238.9***
          (-4.50) (-4.50)

          _cons 11253.1*** 11253.1***
          (9.61) (9.61)
          --------------------------------------------
          wl_1 42 42
          wl_2
          --------------------------------------------
          t statistics in parentheses
          * p<0.05, ** p<0.01, *** p<0.001

          . eststo clear

          Comment


          • #6
            Sorry I did not explain properly. I want exactly like this. But I need to add one more regression.
            eststo clear
            eststo : reg price mpg
            estadd scalar wl_1 = 42
            estadd scalar wl_2 = 8
            eststo : reg price mpg
            estadd scalar wl_1 = 42
            estadd scalar wl_2 = 8
            esttab, stats(wl_1 wl_2)
            eststo clear

            Comment


            • #7
              When I run
              Code:
              cls
              sysuse auto, clear
              eststo clear
              eststo : reg price mpg
              estadd scalar wl_1 = 42
              estadd scalar wl_2 = 101
              eststo : reg price mpg
              estadd scalar wl_1 = 41
              estadd scalar wl_2 = 102
              esttab, stats(wl_1 wl_2)
              eststo : reg price mpg
              estadd scalar wl_1 = 40
              estadd scalar wl_2 = 103
              esttab, stats(wl_1 wl_2)
              eststo clear
              the results are
              Code:
              . esttab, stats(wl_1 wl_2)
              
              ------------------------------------------------------------
                                    (1)             (2)             (3)  
                                  price           price           price  
              ------------------------------------------------------------
              mpg                -238.9***       -238.9***       -238.9***
                                (-4.50)         (-4.50)         (-4.50)  
              
              _cons             11253.1***      11253.1***      11253.1***
                                 (9.61)          (9.61)          (9.61)  
              ------------------------------------------------------------
              wl_1                   42              41              40  
              wl_2                  101             102             103  
              ------------------------------------------------------------
              t statistics in parentheses
              * p<0.05, ** p<0.01, *** p<0.001
              I do not understand your problem. I note that your initial post included sample output, part of which appeared in the email I received (because I am subscribed to this topic). Your output would have been helpful so I could have seen what you are seeing. The FAQ does explain using CODE delimiters to allow Stata code and output to appear readably, as I did in post #4. For example, the following:

              [code]
              . sysuse auto, clear
              (1978 Automobile Data)

              . describe make price

              storage display value
              variable name type format label variable label
              -----------------------------------------------------------------
              make str18 %-18s Make and Model
              price int %8.0gc Price
              [/code]

              will be presented in the post as the following:
              Code:
              . sysuse auto, clear
              (1978 Automobile Data)
              
              . describe make price
              
                            storage   display    value
              variable name   type    format     label      variable label
              -----------------------------------------------------------------
              make            str18   %-18s                 Make and Model
              price           int     %8.0gc                Price
              Perhaps you have an older version of some code that is not as capable. This is what I have installed.
              Code:
              . which eststo
              /Users/lisowskiw/Library/Application Support/Stata/ado/plus/e/eststo.ado
              *! version 1.1.0  05nov2008  Ben Jann
              
              . which estadd
              /Users/lisowskiw/Library/Application Support/Stata/ado/plus/e/estadd.ado
              *! version 2.3.5  05feb2016  Ben Jann
              
              . which esttab
              /Users/lisowskiw/Library/Application Support/Stata/ado/plus/e/esttab.ado
              *! version 2.0.9  06feb2016  Ben Jann
              *! wrapper for estout
              
              . about
              
              Stata/SE 15.1 for Mac (64-bit Intel)
              Revision 02 Apr 2018
              [...]
              Last edited by William Lisowski; 09 Apr 2018, 06:09.

              Comment


              • #8
                Thanks William! I had older version of the code. I have updated those. Now it is working.

                Comment


                • #9
                  Hi Statalist,

                  I have a similar issue where I am trying to save two scalars and output them using estout. Specifically, I am running a regression followed by a Bruesch Pagan test and would like to save both the Chi-Square and it's p-value within the saved model. I am also looping these commands across levels of a program identifier. Below is the code I am using, however the resulting file only includes the first of the two added scalars (the chi-square) but not the second (accompanying p-value). Any advice is greatly appreciated.

                  estimates clear
                  levelsof pair_tx, local(site)
                  foreach l of local site {
                  eststo: qui: reg shootrt treat if pair_tx=="`l'"
                  actest
                  estadd scalar ac_x2 = r(chi2)
                  estadd scalar ac_p = r(p)
                  }
                  estout * using "$fileloc\03_Results\ARIMA\01_Shooting_Program_AC_ Test.txt", cells(b(star fmt(4)) ci(par fmt(4))) starlevels(* 0.10 ** 0.05 *** 0.01) stats( ac_x2 ac_p) replace nolz



                  Best,
                  Kevin

                  Comment


                  • #10
                    Hi Kevin,

                    I had the same problem and the cause is an older version of the package. Type --ssc install estout, replace-- into the Stata window to update the package. Rerun the estimation from the beginning and that should allow you to output more than one added scalar.

                    Best,
                    Allison

                    Comment

                    Working...
                    X