Skip to content

Instantly share code, notes, and snippets.

@ichengzi
Last active August 22, 2023 06:33
Show Gist options
  • Save ichengzi/0eea2af7bbd227f0bd481b8ae8167e79 to your computer and use it in GitHub Desktop.
Save ichengzi/0eea2af7bbd227f0bd481b8ae8167e79 to your computer and use it in GitHub Desktop.
stata分析

一、简单操作

下载外部命令:ssc install outreg2 logout pwcorr_a

二、描述性统计

outreg2 using xxx.doc, replace sum(log) title(Decriptive statistics)
outreg2 using xxx.doc, replace sum(log) keep(**v** **v** **v**) title(Decriptive statistics)
outreg2 using xxx.doc, replace sum(log) keep(**v** **v** **v**) eqkeep(N mean min max) title(Decriptive statistics)
bysort x:outreg2 using xxx.doc, replace sum(log) title(Decriptive statistics)

三、相关性分析

logout, save (xxx)word replace: pwcorr 
logout, save(xxx) word replace: pwcorr_a 

四、多元回归

outreg2 using xxx.doc,replace tstat bdec(3) tdec(2) ctitle(y)
outreg2 using xxx.doc,replace tstat bdec(3) tdec(2) e(r2_a,F) addstat(F test,e(p))
outreg2 using xxx.doc,append tstat bdec(3) tdec(2) e(r2_a,F) addstat(F test,e(p))
固定效应xtreg y x1 x2 x3,fe r
outreg2 using xxx.doc,replace tstat bdec(3) tdec(2) ctitle(y) e(r2_a,F) addstat(F test,e(p)) addtext(Company FE, YES )
xtreg y x1 x2 x3 i.year,fe r
outreg2 using xxx.doc,replace tstat bdec(3) tdec(2) ctitle(y) e(r2_a,F) addstat(F test,e(p)) addtext(Company FE, YES,Year FE, YES)

基础命令Describe 
List 
Sum(obs统计数量mean平均值std.dev标准差, min最小值, max最大值)

pwcorr_a price weight mpg displ, star1(0.01) star5(0.05) star10(0.1) 显著性解释变量是原因,被解释变量是结果。

@ichengzi
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment