Announcement

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

  • Spanning multiple columns using esttab

    ******** I would like to generate Table 1 using esttab.

    TABLE 1
    Table1.png

    ******** I know that I can make manual adjustments using latex, but I would like to know the automatic coding by Stata.

    ​​​​​​​TABLE 2
    Table 2

    ******** Data is provided in the following link: (It has no malware or viruses.)
    https://www.dropbox.com/s/b1ppgj2w5vxzyec/card.dta?dl=0

    ******** Table 2 is what I made so far using outreg2, and its Stata code for Table 2 is below:
    Code:
    use "card.dta", clear
    keep if cut65==1
    est clear
    eststo clear
    local covariates "male black hispanic white i.educ_r1 i.year"
    local x "dage65 age65 age65sq age65dage65 age65sqdage65"
    
    * column (1), Fuzzy RD, Mean data, Control No
    preserve
    collapse (mean) insured `x', by(age_qtr)
    eststo mean: reg insured `x'
    outreg2 using Table2, tex(frag) replace lab keep(dage65) ///
    noobs nor2 nocon ///
    bdec(3) bfmt(f) sdec(3) sfmt(f) ///
    ctitle(Mean) ///
    addtext(Clustring, No, Controls, No) ///
    addnote("Other control variables included but not reported.", ///
    "Column 1, 2, and 3 are the first-stage of Fuzzy RD.")
    esttab meanclu mean
    restore
    
    * column (2), Fuzzy RD, Micro data, Control No
    eststo micro1: reg insured `x', vce(cluster age65)
    outreg2 using Table2, tex(frag) append lab keep(dage65) ///
    noobs nor2 nocon ///
    bdec(3) bfmt(f) sdec(3) sfmt(f) ///
    ctitle(Micro) ///
    addtext(Clustring, Yes, Controls, No)
    
    * column (3), Fuzzy RD, Micro data, Control Yes
    eststo micro2: reg insured `x' `covariates', vce(cluster age65)
    outreg2 using Table2, tex(frag) append lab keep(dage65) ///
    noobs nor2 nocon ///
    bdec(3) bfmt(f) sdec(3) sfmt(f) ///
    ctitle(Micro) ///
    addtext(Clustring, Yes, Controls, Yes)
    
    * column (4), OLS
    eststo ols: reg insured dage65 `covariates', vce(cluster age65)
    outreg2 using Table2, tex(frag) append lab keep(dage65) ///
    noobs nor2 nocon ///
    bdec(3) bfmt(f) sdec(3) sfmt(f) ///
    ctitle(Micro) ///
    addtext(Clustring, Yes, Controls, Yes)
    ******** Question (1)
    It seems that outreg2 does not have an option to span multiple columns like Table1. Is it true?

    ​​​​​​​TABLE 3
    Table3

    ******** Table 3 is what I made so far using esttab, and its Stata code for Table 3 is below:
    Code:
    esttab mean micro1 micro2 ols using "Table3.tex", ///
    se(%10.3f) b(%10.3f) nomtitles fragment noobs label replace keep(dage65) ///
    mgroups("First Stage of Fuzzy" "OLS", pattern(1 0 0 1) ///
    prefix(\multicolumn{@span}{c}{) suffix(}) ///
    span erepeat(\cmidrule(lr){@span}))
    ******** Question (2)
    Table 3 has only one row (Fuzzy RD, OLS), but I would like to have two rows (Fuzzy RD, OLS ; Mean data, Micro data) like Table 1.
    How can I do that? I have tried everything I can imagine, but did not work.

    ******** Question (3)
    Table 3 does not automatically produce the footnotes below. I tried to find the esttab options, but it seems there is no such option. How can I fix this?
    Robust standard errors in parentheses
    *** p<0.01, ** p<0.05, * p<0.1


    ******** Question (4)
    I tried to put the footnotes manually, but it did not work. Nothing of addnotes( ) are reported. How can I fix this?

    Code:
    esttab mean micro1 micro2 ols using "Table3.tex", ///
    se(%10.3f) b(%10.3f) nomtitles fragment noobs label replace keep(dage65) ///
    mgroups("First Stage of Fuzzy" "OLS", pattern(1 0 0 1) ///
    prefix(\multicolumn{@span}{c}{) suffix(}) ///
    span erepeat(\cmidrule(lr){@span})) ///
    addnotes("Control variables used but not reported.", ///
    "Robust standard errors in parentheses", ///
    " *** p$<$0.01, ** p$<$0.05, * p$<$0.1" )
    ******** Question (5)
    Meanwhile, I tried to put the additional rows ( notes( ) ) manually as below, but it did not work. How can I fix this?

    Code:
    esttab mean micro1 micro2 ols using "Table3.tex", ///
    se(%10.3f) b(%10.3f) nomtitles fragment noobs label replace keep(dage65) ///
    mgroups("First Stage of Fuzzy" "OLS", pattern(1 0 0 1) ///
    prefix(\multicolumn{@span}{c}{) suffix(}) ///
    span erepeat(\cmidrule(lr){@span})) ///
    note(Data Mean Micro Micro Micro)
    Dropbox is a free service that lets you bring your photos, docs, and videos anywhere and share them easily. Never email yourself a file again!
    Last edited by Jay Jeong; 17 Dec 2019, 18:04.

  • #2
    I wanted to edit my posting but it does not allow the edition.
    Let me write here instead.

    I found the answer for the question 3 and 4.
    I still could not find the answer for the question 1 and 2.
    Question 2 is the most important issue for me.

    Best
    Jay

    Comment


    • #3
      Dear Jay,

      I have exactly the same questions... have you found answers to your questions?

      Comment


      • #4
        I guess this thread might be helpful, https://www.statalist.org/forums/for...umns-in-esttab.

        Comment

        Working...
        X