Announcement

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

  • Esttab not displaying R2, other stats in exported table

    Hi,

    I am using Esttab in State 14.2 to export tables to Latex with my regression results in Stata. For the most part, that works well, but I have an issue: Using the Stats command, I am able to display N and N_clust, but not r2. I have also been unable to display the two Estadd-created strings dum and con (coded "Yes" or "No"), but after updating to the latest version of Estout, that was resolved, while the R2 issue, which is most important, was not. In place of the R2 values, I get zeroes. How can I solve this?

    This is the relevant code, somewhat shortened by removing controls:

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input double(girlshare StudentAge girl) float(newlyArr intGirlNew intGirlShare intNewShare intGirlNewShare) double SchoolID
    .5714285714285714 10.42 1 0 0 .5714286         0 0 1
    .6190476190476191 12.92 0 1 0        0  .6190476 0 1
    .6190476190476191 10.67 0 0 0        0         0 0 1
    .5714285714285714 10.92 1 0 0 .5714286         0 0 1
    .5714285714285714 10.92 1 0 0 .5714286         0 0 1
    .5714285714285714 10.42 1 0 0 .5714286         0 0 1
    .6190476190476191 10.67 0 0 0        0         0 0 1
    .5714285714285714 10.92 1 0 0 .5714286         0 0 1
    .5714285714285714 10.67 1 0 0 .5714286         0 0 1
    .5714285714285714 10.42 1 0 0 .5714286         0 0 1
    .6190476190476191 10.92 0 0 0        0         0 0 1
    .5714285714285714 10.67 1 0 0 .5714286         0 0 1
    .5714285714285714 11.08 1 0 0 .5714286         0 0 1
    .3684210526315789 10.75 0 0 0        0         0 0 1
    .3157894736842105 10.75 1 0 0 .3157895         0 0 1
    .3684210526315789 11.08 0 . .        0         . . 1
    .3684210526315789 11.08 0 0 0        0         0 0 1
    .3684210526315789 11.17 0 0 0        0         0 0 1
    .3157894736842105 10.92 1 0 0 .3157895         0 0 1
    .3684210526315789 11.58 0 . .        0         . . 1
    .3684210526315789 11.25 0 . .        0         . . 1
    .3684210526315789 10.67 0 0 0        0         0 0 1
    .3684210526315789 10.75 0 . .        0         . . 1
    .3157894736842105 11.92 1 . . .3157895         . . 1
    .3684210526315789 11.42 0 1 0        0 .36842105 0 1
    .6046511627906976 10.42 0 0 0        0         0 0 2
    .6046511627906976 10.42 0 0 0        0         0 0 2
    .6046511627906976 11.08 0 0 0        0         0 0 2
    .6046511627906976 11.08 0 0 0        0         0 0 2
    .5813953488372093 10.83 1 0 0 .5813953         0 0 2
    .5813953488372093 10.83 1 0 0 .5813953         0 0 2
    .5813953488372093 10.58 1 0 0 .5813953         0 0 2
    .5813953488372093 10.58 1 0 0 .5813953         0 0 2
    .5813953488372093 10.58 1 . . .5813953         . . 2
    .5813953488372093 10.25 1 0 0 .5813953         0 0 2
    .5813953488372093 10.25 1 0 0 .5813953         0 0 2
                   .6 10.33 1 0 0       .6         0 0 2
                   .6 10.25 1 0 0       .6         0 0 2
                  .65 10.92 0 0 0        0         0 0 2
                   .6 10.92 1 0 0       .6         0 0 2
                  .65 10.67 0 . .        0         . . 2
                   .6 10.42 1 0 0       .6         0 0 2
                  .65 10.25 0 0 0        0         0 0 2
                   .6 11.08 1 0 0       .6         0 0 2
                  .65 11.17 0 0 0        0         0 0 2
    end
    label values StudentAge ASDAGE
    label values girl girl
    label def girl 0 "Male", modify
    label def girl 1 "Female", modify
    label values newlyArr newlyArr
    label def newlyArr 0 "No", modify
    label def newlyArr 1 "Yes", modify
    label values SchoolID IDSCHOOL
    
    
    
    #delimit ;
    local controls2 "StudentAge girl newlyArr intGirlNew";
    #delimit cr
    
    reg mathscore girlshare intGirlShare intNewShare intGirlNewShare, cluster(SchoolID)
    eststo est1, refresh
    estadd local dum "No", replace
    estadd local con "No", replace
    
    reg mathscore girlshare intGirlShare intNewShare intGirlNewShare i.(SchoolID), cluster(SchoolID)
    eststo est2, refresh
    estadd local dum "Yes", replace
    estadd local con "No", replace
    
    reg mathscore girlshare intGirlShare intNewShare intGirlNewShare `controls2' i.(SchoolID), cluster(SchoolID)
    eststo est3, refresh
    estadd local dum "Yes", replace
    estadd local con "Yes", replace
    
    #d ;
    esttab est1 est2 est3 using Table2.tex, replace
    style(tex) keep(girlshare intGirlShare intNewShare intGirlNewShare)
    starlevels(* 0.10 ** 0.05 *** 0.01)
    cells(b(fmt(%8.3f) star) se(fmt(%8.3f) par))
    stats(dum con N N_clust r2, fmt(0 0 0 0 0)
    labels("School dummies" "Controls" "Number of observations" "Number of classroom clusters" "R2"))
    label
    title("Regression of share of girls in the classroom on math scores by group")
    numbers
    mlabels( ,none) collabels( ,none)
    addnotes("Robust standard errors, adjusted for clustering at the school level, are presented in parentheses." "*** Significant at the 1\% level; ** Significant at the 5\% level; * Significant at the 10\% level")
    legend
    ;
    #d cr
    Thank you in advance!
    Last edited by Artur Obminski; 29 Apr 2017, 12:02.

  • #2
    The proximate problem is that you have formatted r-squared as format style "0", which means to the nearest integer, which means, in every case, "0". You can just change fmt(0 0 0 0 0) to fmt(0 0 0 0 3) to get your r-squareds.

    I made some other changes below to be more esttab-ish. Notably "style", "cells", "stats", and "legend" are all estout options that should probably be avoided with esttab unless you have a specific reason to want them to override esttab's smarts. You can use "indicate" as a cleaner way of indicating controls. (It's easy for me to make mistakes with "keep".) Star notes are included already.

    Let me know if you have any questions about the below:

    Code:
    #delimit ;
    local controls2 "StudentAge girl newlyArr intGirlNew";
    #delimit cr
    
    reg mathscore girlshare intGirlShare intNewShare intGirlNewShare, cluster(SchoolID)
    eststo est1, refresh
    
    reg mathscore girlshare intGirlShare intNewShare intGirlNewShare i.(SchoolID), cluster(SchoolID)
    eststo est2, refresh
    
    reg mathscore girlshare intGirlShare intNewShare intGirlNewShare `controls2' i.(SchoolID), cluster(SchoolID)
    eststo est3, refresh
    
    #d ;
    esttab est1 est2 est3, replace
    tex
    indicate("School dummies = *SchoolID" "Controls = StudentAge girl newlyArr intGirlNew")
    starlevels(* 0.10 ** 0.05 *** 0.01)
    b(%8.3f) se(%8.3f)
    r2 scalars("N_clust Number of classroom clusters") sfmt(0) obslast
    label
    title("Regression of share of girls in the classroom on math scores by group")
    numbers
    mlabels( ,none) collabels( ,none)
    addnotes("Robust standard errors, adjusted for clustering at the school level, are presented in parentheses.")
    ;
    #d cr

    Comment


    • #3
      Thank you very much for your kind help, Nils!

      Comment

      Working...
      X