admin 管理员组

文章数量: 1086019


2024年4月15日发(作者:妹妹送情郎原唱)

Stata结果输出常用命令整理

*1.描述性统计输出结果

asdoc sum `varlist', save() replace stat(N mean sd min p50 max) dec(3)

title(asdoc_Table: Descriptive statistics)

sum2docx `varlist' using ,replace stats(N mean(%9.2f) sd(%9.3f)

min(%9.2f) median(%9.2f) max(%9.2f)) title(sum2docx_Table: Descriptive statistics)

outreg2 using Myfile, sum(detail) replace word eqkeep(N mean sd min p50 max)

fmt(f) keep(`varlist') sortvar(wage age grade) title(outreg2_Table: Descriptive

statistics)

estpost summarize `varlist', detail

esttab using , cells("count mean(fmt(2)) sd(fmt(2)) min(fmt(2))

p50(fmt(2)) max(fmt(2))") noobs compress replace title(esttab_Table: Descriptive

statistics)

*2分组 T 均值检验输出

local common_exp "save() by(south) stat(obs mean p)"

asdoc ttest wage, `common_exp' replace title(asdoc_Table: T_test by group)

asdoc ttest age, `common_exp' rowappend

asdoc ttest race, `common_exp' rowappend

asdoc ttest married, `common_exp' rowappend

asdoc ttest grade, `common_exp' rowappend

asdoc ttest collgrad, `common_exp' rowappend

asdoc ttest union, `common_exp' rowappend

t2docx `varlist' using ,replace not by(south) title(t2docx_Table: T_test by

group)

logout, save(Myfile) word replace: ttable2 `varlist', by(south)

estpost ttest `varlist', by(south)

esttab using , cells("N_1 mu_1(fmt(3)) N_2 mu_2(fmt(3)) b(star fmt(3))")

starlevels(* 0.10 ** 0.05 *** 0.01) noobs compress replace title(esttab_Table: T_test

by group)

*3.相关系数矩阵输出

asdoc cor `varlist', save() replace nonum dec(3) title(asdoc_Table:

correlation coefficient matrix)

corr2docx `varlist' using , replace spearman(ignore) pearson(pw) star

title(corr2docx_Table: correlation coefficient matrix)

logout, save(Myfile) word replace : pwcorr_a `varlist', star1(0.01) star5(0.05)

star10(0.1)

estpost correlate `varlist', matrix

esttab using , unstack not noobs compress nogaps replace star(* 0.1 ** 0.05

*** 0.01) b(%8.3f) p(%8.3f) title(esttab_Table: correlation coefficient matrix)

*4.回归结果输出

asdoc reg wage age married occupation, save() nest replace cnames(OLS-1)

rep(se) add(race, no)

asdoc reg wage age married collgrad occupation, save() nest append

cnames(OLS-2) add(race, no)

asdoc reg wage age married collgrad occupation race_num*, save() nest

append add(race, yes) cnames(OLS-3) dec(3) drop(occupation race_num*) stat(r2_a,

F, rmse, rss) title(asdoc_Table: regression result)

reg wage age married occupation

est store m1

reg wage age married collgrad occupation

est store m2

reg wage age married collgrad occupation race_num*

est store m3

reg2docx m1 m2 m3 using , replace indicate("race=race_num*")

b(%9.2f) se(%7.2f) scalars(r2(%9.3f) r2_a(%9.2f) N) drop(occupation)

order(married) title(reg2docx_Table: regression result) mtitles("OLS-1" "OLS-2"

"OLS-3")

reg wage age married occupation

outreg2 using Myfile, word replace title(outreg2_Table: regression result)

ctitle(OLS-1) `subexp' addtext(race, no)

reg wage age married collgrad occupation

outreg2 using Myfile, word append ctitle(OLS-2) `subexp' addtext(race, no)

reg wage age married collgrad occupation race_num*

outreg2 using Myfile, word append ctitle(OLS-3) `subexp' addtext(race, yes)

reg wage age married occupation

est store m1

reg wage age married collgrad occupation

est store m2

reg wage age married collgrad occupation race_num*

est store m3

*可利用addest自行增加统计量

addest, name("chi2") value(`chi2')

addest, textn("Industry") texts("Yes")

estadd scalar Hausman= r(chi2),replace

estadd scalar Hausman_Test = r(p),replace

esttab m1 m2 m3 using , replace star( * 0.10 ** 0.05 *** 0.01 ) nogaps

compress order(married) drop(occupation) b(%20.3f) se(%7.2f) r2(%9.3f) ar2 aic

bic obslast scalars(F) indicate("race=race_num*") mtitles("OLS-1" "OLS-2" "OLS-3")

title(esttab_Table: regression result)


本文标签: 输出 结果 统计 情郎 妹妹