Announcement

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

  • Trouble adding statistic to esttab latex table

    Hello all. I am trying to add additional statistics to a latex table using the user-written command esttab. In the code that follows, the diffse stat shows up as blank in the results table and I am unsure why. I've also tried with the "scalar" option with no luck. Note that the macro `se' is not blank.

    Code:
    eststo m1:reg complete1 trainee_tt trainee_dl i.ind_bin , vce(cluster CoopSN)
    lincom trainee_tt-trainee_dl
    local diff: display %8.3f r(estimate)
    local se: display %8.3f r(se)
    if r(p) < 0.10 {
    local diff = "`diff'*"
    }
    if r(p) < 0.05 {
    local diff = "`diff'**"
    }
    if r(p) < 0.01 {
    local diff = "`diff'***"
    }
    estadd local diffb `diff'
    estadd local diffse `se'
    
    esttab using "$d9/Tables/tex/cahw/complete_dlvstt.tex", ///
    prehead(" \begin{tabular}{l*{1}{c}}\toprule \noalign{\smallskip}") ///
    fragment b(%8.3f) se(%8.3f) stats(diffb diffse, layout(@ (@)) labels("Difference" "")) noobs compress nonumb star(* 0.10 ** 0.05 *** 0.01) keep(trainee_tt trainee_dl) ///
    coefl(trainee_tt "ITT, traditional" trainee_dl "ITT, distance") replace ///
    mtitle("\shortstack{Completed training}")
    The diffb stat, with stars, and its label show up fine. It also makes no difference whether I add a label for diffse.
    Last edited by Conner Mullally; 06 Aug 2021, 12:36.

  • #2
    Here is a reproducible examples:
    clear all

    Code:
    input float(year y x)
    1999 2  1
    2000 3  2
    2001 2  1
    2002 3  3
    2003 3  2
    2004 2 43
    2005 1  1
    end
    
    tsset year
    
    eststo: reg y x L.x
    lincom x+L.x
    
    
    return list
    
    estadd r(estimate)
    estadd r(se)
    
    eststo: reg y x L.x L2.x
    lincom x+L.x+L2.x
    estadd r(estimate)
    estadd r(se)
    
    esttab, stats(F estimate se, layout(@ @ (@)) labels("F-stat" "Difference" " ")) varwidth(25) keep(x L.x L2.x) star(* 0.10 ** 0.05 *** 0.01) p  label

    Comment


    • #3
      estout is from SSC (FAQ Advice #12). I cannot reproduce your result.

      Code:
      . esttab, stats(F estimate se, layout(@ @ (@)) labels("F-stat" "Difference" " ")) varwidth(25) keep(x L.x L2.x) star(* 0.10 ** 0.05 ***
      >  0.01) p  label
      
      ---------------------------------------------------------
                                         (1)             (2)   
                                           y               y   
      ---------------------------------------------------------
      x                              -0.0173         -0.0331   
                                     (0.297)         (0.599)   
      
      L.x                            -0.0428*        -0.0479   
                                     (0.053)         (0.327)   
      
      L2.x                                             0.429   
                                                     (0.735)   
      ---------------------------------------------------------
      F-stat                           5.010           1.258   
      Difference                     -0.0601           0.348   
                                    (0.0215)         (0.916)   
      ---------------------------------------------------------
      p-values in parentheses
      * p<0.10, ** p<0.05, *** p<0.01
      Update estout and see if it solves it.

      Code:
      ssc install estout, replace

      Comment


      • #4
        First, I'm running Stata 16.1. Also, I may have posted the wrong example. Try this:
        clear all
        Code:
        clear all
        input float(year y x)
        1999 2  1
        2000 3  2
        2001 2  1
        2002 3  3
        2003 3  2
        2004 2 43
        2005 1  1
        end
        
        tsset year
        
        eststo: reg y x L.x
        lincom x+L.x
        
        
        return list
        
        estadd r(estimate)
        estadd r(se)
        
        eststo: reg y x L.x L2.x
        lincom x+L.x+L2.x
        estadd r(estimate)
        estadd r(se)
        
        esttab, stats(F estimate se, layout(@ @ (@)) labels("F-stat" "Difference" " ")) varwidth(25) keep(x L.x L2.x) star(* 0.10 ** 0.05 *** 0.01) p  label
        When I run this, here is my output:

        Code:
        
        ---------------------------------------------------------
                                           (1)             (2)  
                                             y               y  
        ---------------------------------------------------------
        x                              -0.0173         -0.0331  
                                       (0.297)         (0.599)  
        
        L.x                            -0.0428*        -0.0479  
                                       (0.053)         (0.327)  
        
        L2.x                                             0.429  
                                                       (0.735)  
        ---------------------------------------------------------
        F-stat                           5.010           1.258  
        Difference                     -0.0601           0.348  
                                                                
        ---------------------------------------------------------
        p-values in parentheses
        * p<0.10, ** p<0.05, *** p<0.01
        Last edited by Conner Mullally; 07 Aug 2021, 06:24.

        Comment


        • #5
          I have version 16.1 as well and I cannot replicate your issue. Did you follow my advice in #3 to update estout?

          Code:
          . esttab, stats(F estimate se, layout(@ @ (@)) labels("F-stat" "Difference" " ")) varwidth(25) keep(x L.x L2.x) star(* 0.10 ** 0.05 ***
          >  0.01) p  label
          
          ---------------------------------------------------------
                                             (1)             (2)   
                                               y               y   
          ---------------------------------------------------------
          x                              -0.0173         -0.0331   
                                         (0.297)         (0.599)   
          
          L.x                            -0.0428*        -0.0479   
                                         (0.053)         (0.327)   
          
          L2.x                                             0.429   
                                                         (0.735)   
          ---------------------------------------------------------
          F-stat                           5.010           1.258   
          Difference                     -0.0601           0.348   
                                        (0.0215)         (0.916)   
          ---------------------------------------------------------
          p-values in parentheses
          * p<0.10, ** p<0.05, *** p<0.01

          Comment


          • #6
            I missed that, it worked (tears of joy). Thanks!

            Comment

            Working...
            X