Announcement

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

  • –etable– in the Nov. 17 update for v17.0

    Users who create post-estimation tables might take note of –etable– in the Nov. 17 update for v17.0. On a quick inspection and test drive it looks rather powerful.

  • #2
    It is the most useful function. It will be great if Stata can have a predefined table format (e.g. tables in the leading medical journals like JAMA, Lancet) under the etable function.
    The current Stata 17 Table function is too complicated. In my opinion, the user-written table1_mc is more user friendly to create Table 1 than the examples in Stata blog.

    Comment


    • #3
      I think #2 misses the point. A command focused on a specific thing you want to do will usually have the edge of convenience over a more general and complicated command that allows that specific thing to be done with complicated syntax, just as you wouldn't (I guess) try to write your own histogram command using twoway to calculate bin densities (or whatever) and draw each bar as a series of line segments given that a histogram command exists already.

      table is in effect a language of its own that allows people to write specific routines to do what they want. If users are not able or willing to invest the effort in learning how to do that for their specific goals, then, fine, their choice, and they will have to await someone else doing it first.

      You couldn't use table1_mc (SSC) unless the author had written the best part of a thousand lines of code to make it easier to do things that you want to do. Conversely, "Table 1" rings cheerful bells of recognition with many users but bears no resemblance at all to what many others ever want, which should be fine with everybody.

      The analogy with graphics is strong here. Many people can say "All I want is a simple graph" except that so does almost everybody else, and the simple graphs are typically different. and not always as simple as the user implies. The solution has to be on several levels:

      1. A very general command that allows programming of most things that someone might want,

      2. Specific commands for common needs.

      3. Options so that people can tweak cosmetic and other details.

      table in Stata 17 is comparable to graph since Stata 8.

      Comment


      • #4
        is etable working correctly when displaying results from multiple models?
        i have run 3 regressions ans stored the results using est sto mod1...
        est table mod1 mod2 mod3 shows model coefficients in 3 columns
        etable displays results appended and in separate columns, not in horizontally-aligned columns
        the .pdf documentation suggests to me that the coefficients should appear aligned in rows

        PHP Code:
        etableest(svols rso2cols rso2rolscstat(_r_b)

        ------------------------------------------
                                 
        sv   rso2c  rso2r
        ------------------------------------------
        SpO2                   0.598              
        Mean Arterial Pressure 0.183              
        Intercept              2.650              
        SpO2                          0.555       
        Mean Arterial Pressure        0.055       
        Intercept                    16.713       
        SpO2                                 0.420
        Mean Arterial Pressure               0.165
        Intercept                           32.769
        Number of observations  7211   7806   7769
        ------------------------------------------

        est table svols rso2cols rso2rols

        -----------------------------------------------------
            
        Variable |   svols       rso2cols     rso2rols   
        -------------+---------------------------------------
                  
        sa |  .59843087    .55522465    .42013389  
                  bp 
        |  .18339393    .05497271     .1650317  
               _cons 
        |  2.6503611    16.712968    32.769461  
        -----------------------------------------------------


        what am i doing wrong?
        Last edited by George Hoffman; 20 Nov 2021, 06:54. Reason: included example output

        Comment


        • #5
          I still haven't worked through all the documentation so it's quite possible that there's an option setting that resolves the issue. But here's an additional illustration of the issue identified in #1
          Code:
          est clear
          sysuse auto
          reg price mpg foreign
          est store e1
          reg price mpg foreign rep
          est store e2
          etable, est(e1 e2)
          yields
          Code:
          --------------------------------------------
                                    price      price  
          --------------------------------------------
          Mileage (mpg)            -294.196   -292.434
                                   (55.692)   (60.227)
          Car origin               1767.292   1023.208
                                  (700.158)  (866.086)
          Repair record 1978                   432.800
                                             (394.705)
          Intercept               11905.415  10586.485
                                 (1158.634) (1555.745)
          Number of observations         74         69
          --------------------------------------------
          whereas
          Code:
          est clear
          sysuse auto
          reg price mpg foreign
          est store e1
          reg headroom mpg foreign rep
          est store e2
          etable, est(e1 e2)
          yields
          Code:
          ------------------------------------------
                                    price   headroom
          ------------------------------------------
          Mileage (mpg)            -294.196         
                                   (55.692)         
          Car origin               1767.292         
                                  (700.158)         
          Intercept               11905.415         
                                 (1158.634)         
          Mileage (mpg)                       -0.049
                                             (0.018)
          Car origin                          -0.495
                                             (0.265)
          Repair record 1978                   0.126
                                             (0.121)
          Intercept                            3.763
                                             (0.475)
          Number of observations         74       69
          ------------------------------------------

          Comment


          • #6
            For me, I only see the second example of what John shows in #5, and try as I might, I cannot align variables by name.

            Comment


            • #7
              so i guess the dependent variable has to be the same to yield row alignment of independent variables.
              i'm not sure this is a 'feature' or a bug!
              Last edited by George Hoffman; 20 Nov 2021, 11:16.

              Comment


              • #8
                -help Tables Builder- may help to replace the default row specification.
                Code:
                sysuse auto
                reg price mpg foreign
                est store e1
                reg headroom mpg foreign rep78
                est store e2
                etable, est(e1 e2)
                
                collect layout
                
                Collection: ETable
                      Rows: coleq#colname[]#result[_r_b _r_se] result[N]
                   Columns: etable_depvar#stars[value]
                   Table 1: 15 x 2
                Code:
                collect layout (colname#result[_r_b _r_se] result[N]) (etable_depvar#stars[value])
                
                Collection: ETable
                      Rows: colname#result[_r_b _r_se] result[N]
                   Columns: etable_depvar#stars[value]
                   Table 1: 9 x 2
                
                ------------------------------------------
                                          price   headroom
                ------------------------------------------
                Mileage (mpg)            -294.196   -0.049
                                         (55.692)  (0.018)
                Car origin               1767.292   -0.495
                                        (700.158)  (0.265)
                Repair record 1978                   0.126
                                                   (0.121)
                Intercept               11905.415    3.763
                                       (1158.634)  (0.475)
                Number of observations         74       69
                ------------------------------------------
                Last edited by Bjarte Aagnes; 20 Nov 2021, 14:07.

                Comment


                • #9
                  Thanks Bjarte. This is good to know.

                  Even so, however, a simple option in the –etable– command could presumably be implemented to accomplish what you did in #8 without the extra steps of referring to the collection.

                  I imagine that many people wanting to use –etable– to report the results of two or more model estimates would have the same objective as #4, i.e. reporting models that have different LHS variables with either the same or different sets of RHS variables.

                  For instance, something like
                  Code:
                  etable, est(e1 e2) alignrhsvars

                  Comment


                  • #10
                    Thanks John, maybe the default definition will be changed. The arguments for changing a collect definition via etable options may be made closer to the underlying collect maybe something like:
                    Code:
                    collect_layout_rows("colname#result[_r_b _r_se]")
                    BTW the behaviour of etable option name() seems not to meet my expectations, the following will use the row settings of ETable, not the row settings of the etableprefered saved to etableprefered.stjson ("rows": "colname#result[_r_b _r_se] result[N]"):
                    Code:
                    reg price mpg foreign
                    est store e1
                    reg headroom mpg foreign rep78
                    est store e2
                     
                    etable, est(e1 e2)
                    
                    collect layout (colname#result[_r_b _r_se] result[N]) (etable_depvar#stars[value])
                    
                    collect style save etableprefered, replace
                    
                    collect clear
                    collect use etableprefered etableprefered.stjson
                    
                    etable, est(e1 e2) name(etableprefered)
                    Code:
                    . collect use etableprefered etableprefered.stjson
                    (collection etableprefered read from file etableprefered.stjson)
                    
                    . 
                    . etable, est(e1 e2) name(etableprefered) 
                    
                    ------------------------------------------
                                              price   headroom
                    ------------------------------------------
                    Mileage (mpg)            -294.196         
                                             (55.692)         
                    Car origin               1767.292         
                                            (700.158)         
                    Intercept               11905.415         
                                           (1158.634)         
                    Mileage (mpg)                       -0.049
                                                       (0.018)
                    Car origin                          -0.495
                                                       (0.265)
                    Repair record 1978                   0.126
                                                       (0.121)
                    Intercept                            3.763
                                                       (0.475)
                    Number of observations         74       69
                    ------------------------------------------

                    Comment


                    • #11
                      Most commands like logit use the dependent variable as the first
                      equation name. regress is one of the rare commands that does not
                      post an equation name to e(b), however collect (and hence
                      etable) automatically consumes the variable in e(depvar)
                      as the column equation in this case.

                      Bjarte shows that you can take control of the layout using
                      collect and the Tables Builder. However, etable will
                      always overwrite the layout. So the name() option did not have
                      the effect Bjarte expected.

                      etable option eqrecode() allows you to realign equations
                      by recoding the column equations as you collect results. Options
                      showeq and novarlabel will help you see the equation names
                      to recode.

                      Here is how these options might be used:

                      Code:
                      sysuse auto
                      regress price mpg foreign
                      est store e1
                      regress headroom mpg foreign rep78
                      est store e2
                      
                      * get the results
                      etable, est(e1 e2)
                      * peek at the equations
                      etable, replay showeq novarlabel
                      * recode the equations
                      etable, replay eqrecode(price = xb headroom = xb)
                      * other style changes
                      etable, replay noshoweq varlabel
                      
                      * start fresh and recode equations
                      etable, est(e1 e2) eqrecode(price = xb headroom = xb)
                      Here is the output from the etable commands:

                      Code:
                      . * get the results
                      . etable, est(e1 e2)
                      
                      ------------------------------------------
                                                price   headroom
                      ------------------------------------------
                      Mileage (mpg)            -294.196         
                                               (55.692)         
                      Car origin               1767.292         
                                              (700.158)         
                      Intercept               11905.415         
                                             (1158.634)         
                      Mileage (mpg)                       -0.049
                                                         (0.018)
                      Car origin                          -0.495
                                                         (0.265)
                      Repair record 1978                   0.126
                                                         (0.121)
                      Intercept                            3.763
                                                         (0.475)
                      Number of observations         74       69
                      ------------------------------------------
                      
                      . * peek at the equations
                      . etable, replay showeq novarlabel
                      
                      ------------------------------------------
                                                price   headroom
                      ------------------------------------------
                      price                                     
                        mpg                    -294.196         
                                               (55.692)         
                        foreign                1767.292         
                                              (700.158)         
                        _cons                 11905.415         
                                             (1158.634)         
                      headroom                                  
                        mpg                               -0.049
                                                         (0.018)
                        foreign                           -0.495
                                                         (0.265)
                        rep78                              0.126
                                                         (0.121)
                        _cons                              3.763
                                                         (0.475)
                      Number of observations         74       69
                      ------------------------------------------
                      
                      . * recode the equations
                      . etable, replay eqrecode(price = xb headroom = xb)
                      
                      ------------------------------------------
                                                price   headroom
                      ------------------------------------------
                      xb                                        
                        mpg                    -294.196   -0.049
                                               (55.692)  (0.018)
                        foreign                1767.292   -0.495
                                              (700.158)  (0.265)
                        rep78                              0.126
                                                         (0.121)
                        _cons                 11905.415    3.763
                                             (1158.634)  (0.475)
                      Number of observations         74       69
                      ------------------------------------------
                      
                      . * other style changes
                      . etable, replay noshoweq varlabel
                      
                      ------------------------------------------
                                                price   headroom
                      ------------------------------------------
                      Mileage (mpg)            -294.196   -0.049
                                               (55.692)  (0.018)
                      Car origin               1767.292   -0.495
                                              (700.158)  (0.265)
                      Repair record 1978                   0.126
                                                         (0.121)
                      Intercept               11905.415    3.763
                                             (1158.634)  (0.475)
                      Number of observations         74       69
                      ------------------------------------------
                      
                      . 
                      . * start fresh and recode equations
                      . etable, est(e1 e2) eqrecode(price = xb headroom = xb)
                      
                      ------------------------------------------
                                                price   headroom
                      ------------------------------------------
                      Mileage (mpg)            -294.196   -0.049
                                               (55.692)  (0.018)
                      Car origin               1767.292   -0.495
                                              (700.158)  (0.265)
                      Repair record 1978                   0.126
                                                         (0.121)
                      Intercept               11905.415    3.763
                                             (1158.634)  (0.475)
                      Number of observations         74       69
                      ------------------------------------------

                      Comment


                      • #12
                        Thanks Jeff. This is really helpful.

                        Comment


                        • #13
                          Hi there! Extremely helpful thread, thanks for helping the community out so effectively. Now that I have been to horizontally-align the two models' results by using #11's code, how can I include the log pseudo likelihood indicator and change the column's heading?

                          Thanks in advance,
                          Antonio

                          Comment

                          Working...
                          X