[关闭]
@liuyuxi 2021-07-18T12:11:25.000000Z 字数 4382 阅读 41

stata结果输出

stata


基本上,描述性统计的输出跟在sum xxxxxxx, detail之后;回归结果输出跟在reg xxxxxxx之后。

outreg2

  1. reg ******
  2. outreg2 using xxx.doc,word replace title(outreg2_Table: regression result) ctitle(OLS-1) keep(x1 x2 x3) addtext(City FE,YES,Year FE,YES,City timetrend,YES)
  3. reg ******
  4. outreg2 using xxx.doc,word replace append ctitle(OLS-2) keep(x1 x2 x3) addtext(City FE,YES,Year FE,YES,City timetrend,YES)
  5. ..........

最简单版本:

  1. reg ******
  2. outreg2 using "xxx.doc", replace
  3. reg ******
  4. outreg2 using "xxx.doc", append

esttab

  1. *引自饶品贵等《高铁开通与供应商分布决策》,《中国工业经济》2019年。
  2. areg Dis HSR Cash Invt Lev Size ROA Rec Age PGDP SOE i.year,absorb(company_id) robust
  3. est store m_1
  4. areg Disw HSR Cash Invt Lev Size ROA Rec Age PGDP SOE i.year,absorb(company_id) robust
  5. est store m_2
  6. esttab m_1 m_2 using baseline.rtf, replace ///
  7. b(%9.4f) star(* 0.1 ** 0.05 *** 0.01) t(%9.4f) ///
  8. scalar(F N r2_a) nogaps ///
  9. mtitle()
  10. *连享会“四个输出命令对比”一文中的code
  11. esttab m1 m2 m3 using Myfile.rtf, ///
  12. replace star( * 0.10 ** 0.05 *** 0.01 ) nogaps compress ///
  13. order(married) drop(occupation) b(%20.3f) se(%7.2f) ///
  14. r2(%9.3f) ar2 aic bic obslast scalars(F) ///
  15. indicate("race=race_num*") mtitles("OLS-1" "OLS-2" "OLS-3") ///
  16. title(esttab_Table: regression result)

(3)asdoc,outreg2中的addtext()选项在esttab中可用estadd()代替。

  1. reghdfe fdi c.D if treatdate ==2017|treatdate ==2015|treatdate ==2013 , absorb(id year) vce(r)
  2. estadd local Cluster Yes,replace
  3. estadd local Year_FE Yes,replace
  4. estadd local Fixed_Effect Yes,replace
  5. estadd local Control No,replace
  6. est sto m1
  7. ...........
  8. reghdfe fdi c.D if treatdate ==2019|treatdate ==2018|treatdate ==2017|treatdate ==2015|treatdate ==2013 , absorb(id year) vce(r)
  9. estadd local Cluster Yes,replace
  10. estadd local Year_FE Yes,replace
  11. estadd local Fixed_Effect Yes,replace
  12. estadd local Control No,replace
  13. est sto m3
  14. ...........
  15. esttab m1 m2 m3 m4 using result030906.rtf, star(* 0.1 ** 0.05 *** 0.01) b(%6.3f) t(%6.3f) compress nogap ///
  16. stats(Year_FE Fixed_Effect Cluster Control N r2_a aic bic , fmt(%3s %3s %3s %12.0f %9.3f)) ///
  17. varwidth(20) title('Regression Result') mtitles("treat13to17" "treat13to18" "treat13to19" "treat13to20")

sum2docxreg2docx

特色:可以把四张表同时输出到同一张表上,参见“连享会”文章。
- 描述性统计

  1. *连享会《用…2docx来进行四大表输出》的code
  2. sum2docx price-foreign using ///
  3. 1.docx, append obs ///
  4. mean(%9.2f) sd min(%9.0g)///
  5. median(%9.0g) max(%9.0g) ///
  6. title("表 1: 描述性统计")
  1. *连享会“四个输出命令对比”一文中的code
  2. reg2docx m1 m2 m3 using Myfile.docx, replace indicate("race=race_num*") ///
  3. b(%9.2f) se(%7.2f) scalars(r2(%9.3f) r2_a(%9.2f) N) ///
  4. drop(occupation) order(married) ///
  5. title(reg2docx_Table: regression result) ///
  6. mtitles("OLS-1" "OLS-2" "OLS-3")

asdoc

  1. asdoc sum
  2. 选择变量
  3. asdoc sum price mpg rep78save(summary.doc) title(###)
  4. 选择统计量
  5. asdoc sum, stat(N mean sd tstat p1 p99) fs(7) dec(2)
  6. 分组输出
  7. asdoc sum, stat(N mean sd tstat p1 p99) by(foreign)
  8. -或
  9. bysort foreign: asdoc sum, stat(N mean sd tstat p1 p99)
  10. 加文字描述
  11. asdoc, text(A car is a wheeled motor vehicle used for transportation) append fs(10)
  1. asdoc reg price mpg rep78, nest replace ///对第一个回归
  2. asdoc reg price mpg rep78 headroom, nest append ///针对以后的回归
  3. 需要在一张表上显示多个回归结果就依次进行 nest append
  4. 横向放置回归表格,需要使用 asdoc 中的 wide 选项。
  5. asdoc reg price mpg rep78, replace wide
  6. 想把被解释变量为 trunk 的回归结果追加于上表,输入如下命令:
  7. asdoc reg trunk mpg rep78, wide
  8. 回归命令后加 t(below) 表示在系数的下方显示对应的 t 值,t(side)表示在旁边显示t值。

文献中值得借鉴的绘图code

  1. //Preliminary observation
  2. /*2014-2017 air quality comparision*/
  3. qui:estpost tabstat aaqi aso2 apm10 apm25 aco ano2 ao3,by(year) col(stat) nototal
  4. esttab using table2-1-1.rtf, cell(mean) unstack label noobs nogap nonumber title("table2-1")
  5. qui:estpost tabstat maqi mso2 mpm10 mpm25 mco mno2 mo3,by(year) col(stat) nototal
  6. esttab using table2-1-2.rtf, cell(mean) unstack label noobs nogap nonumber title("table2-2")
  1. bys year dd: egen complex=mean(county_soph)
  2. bys year dd: drop if _n!=_N
  3. twoway (connect complex year if dd==1,lp(solid) lc(black) mc(black)) ///
  4. (connect complex year if dd==0,lp(dash) lc(black) mc(black)), ///
  5. ytitle("技术复杂度") xtitle("年份") legend(label(1 "实验组") label(2 "对照组"))
  1. logout, save(表1) word dec(4) replace: tabstat lngdp lnpgdp fdi exp popden industry non_agri sav welfare minor fin govspend near agro_t match ///
  2. lnis1 lnis2 lnloan lninv student citylive rurallive lnincome, stat( mean sd min max n) c(s) f(%9.4f)
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注