Announcement

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

  • Update to -estout- available from SSC

    An update to the estout package is available from the SSC Archive. The update fixes a number of issues that were reported on GitHub. To install the update, type
    Code:
    . ssc install estout, replace
    Ben

  • #2
    Dear Ben, Many thanks for updating the useful estout package. I wonder if there is an equivalent option in estout can produce correlation matrix/table where different levels of significance is denoted by different numbers of stars? Please have a look at https://www.statalist.org/forums/for...commands/page6 (#82, and #83). Thanks!
    Ho-Chuan (River) Huang
    Stata 17.0, MP(4)

    Comment


    • #3
      Do you mean something like this?
      Code:
      . sysuse nlsw88.dta, clear
      . estpost corr age ttl_exp hours grade race wage, matrix
      . esttab ., b(3) unstack nonum nomtitle not noobs compress
      
      ----------------------------------------------------------------------------------------
                       age      ttl_exp        hours        grade         race         wage   
      ----------------------------------------------------------------------------------------
      age            1.000                                                                    
      ttl_exp        0.124***     1.000                                                       
      hours         -0.028        0.230***     1.000                                          
      grade         -0.033        0.198***     0.087***     1.000                             
      race          -0.059**      0.022        0.045*      -0.136***     1.000                
      wage          -0.036        0.265***     0.159***     0.325***    -0.081***     1.000   
      ----------------------------------------------------------------------------------------
      * p<0.05, ** p<0.01, *** p<0.001

      Comment


      • #4
        Dear Ben, Yes, it is exactly what I asked for. By the way, in cases where there are "a lot of" variables, it might be better the replace column names (say, age, ttl_exp, and so on) with numbers. A representative table is (from asdoc)
        Click image for larger version

Name:	asdoc-cor.jpg
Views:	1
Size:	28.8 KB
ID:	1501668
        .

        Is it possible for estout/esttab to have this option? Thanks.
        Ho-Chuan (River) Huang
        Stata 17.0, MP(4)

        Comment


        • #5
          There is no automatic option to create such labels, but you can assign custom labels using options eqlabels() for the columns and coeflabels() for the rows. Here is an example that renames the columns and also includes the word "Variables" on the left:
          Code:
          . sysuse nlsw88.dta, clear
          . estpost corr age ttl_exp hours grade race wage, matrix
          . esttab ., b(3) unstack nonum nomtitle not noobs compress ///
          >     eqlabels((1) (2) (3) (4) (5) (6), lhs("Variables"))
          
          ----------------------------------------------------------------------------------------
          Variables        (1)          (2)          (3)          (4)          (5)          (6)   
          ----------------------------------------------------------------------------------------
          age            1.000                                                                    
          ttl_exp        0.124***     1.000                                                       
          hours         -0.028        0.230***     1.000                                          
          grade         -0.033        0.198***     0.087***     1.000                             
          race          -0.059**      0.022        0.045*      -0.136***     1.000                
          wage          -0.036        0.265***     0.159***     0.325***    -0.081***     1.000   
          ----------------------------------------------------------------------------------------
          * p<0.05, ** p<0.01, *** p<0.001
          To avoid excessive typing I would suggest putting together a small program that compiles the labels automatically. Example:
          Code:
          capture program drop mkcorrlbls
          program define mkcorrlbls, rclass
              local vars: coleq e(b)
              local vars: list uniq vars
              local eqlabels
              local coeflabels
              local i 0
              foreach v of local vars {
                  local ++i
                  local eqlabels `eqlabels' (`i')
                  local coeflabels `coeflabels' `v' "(`i') `v'"
              }
              return local eqlabels `eqlabels'
              return local coeflabels `coeflabels'
          end
          
          estpost corr age ttl_exp hours grade race wage, matrix
          mkcorrlbls
          esttab ., b(3) unstack nonum nomtitle not noobs compress varwidth(12) ///
              eqlabels(`r(eqlabels)', lhs("Variables")) ///
              coeflabels(`r(coeflabels)')
          
          ------------------------------------------------------------------------------------------
          Variables          (1)          (2)          (3)          (4)          (5)          (6)   
          ------------------------------------------------------------------------------------------
          (1) age          1.000                                                                    
          (2) ttl_exp      0.124***     1.000                                                       
          (3) hours       -0.028        0.230***     1.000                                          
          (4) grade       -0.033        0.198***     0.087***     1.000                             
          (5) race        -0.059**      0.022        0.045*      -0.136***     1.000                
          (6) wage        -0.036        0.265***     0.159***     0.325***    -0.081***     1.000   
          ------------------------------------------------------------------------------------------
          * p<0.05, ** p<0.01, *** p<0.001

          Comment


          • #6
            Dear Ben, Many thanks for this wonderful solution.
            Ho-Chuan (River) Huang
            Stata 17.0, MP(4)

            Comment


            • #7
              Dear Ben, I did the following.
              Code:
              sysuse auto, clear
              global all "price mpg rep78 headroom trunk weight length turn foreign"
              estpost tabstat $all, listwise statistics(count mean sd p5 p25 p50 p75 p95) columns(statistics)
              esttab using "log\esttab-t1b.rtf", replace cells("count mean(fmt(3)) sd(fmt(3)) p5(fmt(3)) p25(fmt(3)) p50(fmt(3)) p75(fmt(3)) p95(fmt(3))") noobs compress
              and got the results (in word)
              Click image for larger version

Name:	esttab-sum.png
Views:	1
Size:	48.4 KB
ID:	1502562

              My question is: how to make the numbers of this table aligned? Thanks.
              Ho-Chuan (River) Huang
              Stata 17.0, MP(4)

              Comment


              • #8
                you could add option alignment(r) to right-align the numbers.

                Comment


                • #9
                  Dear Ben, Thanks. This is helpful.

                  Ho-Chuan (River) Huang
                  Stata 17.0, MP(4)

                  Comment


                  • #10
                    Dear Ben Jann,

                    Thank you so much for creating and updating the estout package. I am sure many Stata users such as myself are using this package on a regular basis by now.

                    I know that this is an older post/thread, but I'd like to give it a shot since I have searched for hours and hours on Statalist and other sources, but I am still unable to find a solution to my problem. I sincerely apologies if I violate some of the rules on the Statalist FAQ.

                    Related to the discussion above (and please by all means if River Huang could contribute as well, I would be very much grateful), I would like to ask whether there is a way for me to display my own selected vars on the correlation matrix columns.

                    For instance, let's just say I would like to estpost correlate 20 different variables:

                    Code:
                    estpost corr var1-var20, matrix
                    esttab ., b(3) unstack nonum nomtitle not noobs compress eqlabels ((1) (2) (3) (4) (5) (6) (7) (8) (9) (10) (11) (12) (13) (14) (15) (16) (17) (18) (19) (20), lhs("Variables"))
                    I would like the output to look instead of something like this:

                    Code:
                    Variables | (1) | (2) | (3) | (4) | (5) | (6) | (7) | (8) | (9) | (10) | ... | (20)
                    Var1
                    Var2
                    Var3
                    Var4
                    Var5
                    .
                    .
                    .
                    Var20
                    It will look like this below:

                    First Sequence
                    Code:
                    Variables | (1) | (2) | (3) | (4) | (5) | | (6) | (7) | (8) | (9) | (10) |
                    Var1
                    Var2
                    Var3
                    Var4
                    Var5
                    .
                    .
                    .
                    Var20
                    Second Sequence
                    Code:
                    Variables | (11) | (12) | (13) | (14) | (15) | (16) | (17) | (18) | (19) | (20) |
                    Var11
                    Var12
                    Var13
                    Var14
                    Var15
                    Var16
                    Var17
                    Var18
                    Var19
                    Var20
                    Basically, I was wondering if I could manually adjust the column of the correlation results (whether it's 5, 8, or 10 vars, as long as they are in the varlist; and in any order I want). Are there any ways to make output tables like that from estpost/esttab framework? Any help will be very much appreciated.

                    Best,
                    Nampuna
                    Last edited by Nampuna D. Gultom; 30 Mar 2021, 23:32.

                    Comment

                    Working...
                    X