⼀⽂读懂结果输出命令⼤全(上)
⽬录
•描述统计量
•
help tabstat //Stata 官⽅命令
•描述统计量组间均值差异检验
羊肚菌汤的做法
•
help ttest
•
怀孕着床需要几天help ttable2
•
help estout
•相关分析命令
•
help pwcorr
•
help pwcorr_a
•回归相关分析命令
•暴雨红色预警
help esttab
冬瓜焖鸭
朗诵伴奏音乐•
help outreg2
•
help logout
•stata命令汇总
•help sum2docx //输出基本统计量输出
•help t2docx //输出均值差异检验结果输出
•help corr2docx //输出 Pearson & Spearman 相关系数矩阵输出
•help reg2docx //输出回归结果输出
1、tabstat
日本轻音乐描述性统计通常对收集来的数据进⾏直接的频率、频数等描述,描述性统计分析⼀般对样本的最⼩值、最⼤值、平均值、标准偏差等进⾏分析,这些数据有助于了解样本数据特征,能够清晰的看到各个统计量的分布情况。
描述性分析常⽤的统计量:
mean,均值
max,最⼤值
min,最⼩值
min,最⼩值
sd,标准差
variance,⽅差
mean,即sd/√n
skewness,偏度
kurtosis,峰度
p1,第⼀分位数
p5,第五分位数
p10,第⼗分位数
p50,中位数
median,中位数
range,max-min
⽰例:
•
•
•
•
•
sysu auto tabstat price weight mpg rep78 tabstat price weight mpg rep78, by(foreign) stat(mean s
炸花生米d min max)对变量price, weight, mpg, and rep78 按照foreign分类展⽰其描述统计量mean sd min max2、ttest样本检验⽰例: sysuauto ttestmpg==20 (one-sample t test) webufuel3 (tup) ttestmpg, by(treated) (two-sample t test using groups) webufuel (tup) ttestmpg1==mpg2 (two-sample t test using variables) 3、ttable2⽰例: sysuauto,clear
ttable2price wei len mpg, by(foreign) ttable2price wei len mpg, by(foreign) f( %6.2f) tabrep78 ttable2price wei len mpg if rep78==3|rep78==4, by(rep78) **输出保存到 Word⽂档等Save in Excel or Word logout, save(Tab2_corr) excel replace: ttable2 price wei len mpg, by(foreign) 4、pwcorr VS pwcorr_a相关系数的命令⼀般有corr、pwcorr,但是pwcorr的⼀个缺点是只能⼀次输出⼀个置信⽔平下的显著性,因此本⽂将为⼤家介绍pwcorr_a的具体使⽤。1命令回顾correlate --Correlations of variables进⾏变量相关系数的命令,该命令主要分为corr以及pwcorr语法格式为: correlate[varlist][if][in] [weight][, correlate_options]pwcorr[varlist][if][in][weight][, pwcorr_options]案例1: sysuauto pwcorrprice headroom mpg displacement ,sig star(0.01) 使⽤pwcorr可以对指定的显著性⽔平进⾏标注。缺点是只能对指定的显著⽔平标注⼀个 *,即⽆法同时标注1% 5% 10%。2pwcorr_apwcorr_a 可以对1%,5%,10% 的显著⽔平进⾏标注 *** ,** 和 *语法格式为: pwcorr_a[varlist][if][in][weight][, pwcorr_options]主要选项含义为:star1(#) :1% significance level for displaying with three stars, newly added 新增的标注1%⽔平下三颗星star5(#) 5% significance level for displaying with two stars,
newly added 新增的标注5%⽔平下两颗星star10(#) 10% significance level for displaying with one star, newly added 新增的标注10%⽔平下⼀颗星案例应⽤介绍 pwcorr_apriceweightmpgdispl, star1(0 .01) star5(0 .05) star10(0 .1) 3输出相关系数矩阵到Word⽂档中代码为: sysu auto, clear logout, save(数量经济学) word replace: ///pwcorr_a price wei len mpg //标注star(0.05)4输出相关系数矩阵到Excel⽂档中代码为: sysu auto, clear logout, save(数量经济学) excel replace: ///pwcorr_a price wei len mpg //标注star(0.05)结果为:5、esttab新的esttab命令是estout的升级版本。它的语法相⽐较于estout⽽⾔,默认情况下,它会⽣成很好地结果,并输出在Stata的结果窗⼝中。esttab不仅仅是estout 的简化版本。另⼀⽅⾯,esttab提供完整的estout功能,因为所有的estout选项都是允许在esttab中。另⼀⽅⾯,esttab 也扩展了功能。例如,esttab⽀持与WORD、Excel、Latex、Html结果⼀、Basic syntax and usageSyntaxesttab [namelist] [using filename] [, options]与estout(或官⽅Stata的估计表)⼀样,基本程序是⾸先存储多个模型,然后将esttab应⽤于这些存储的估计集以组成回归表。但是,esttab和estout之间的主要区别在于,如果在没有选项的情况下应⽤,esttab会⽣成⼀个完全格式化的表。⼆、添加统计量The default in esttab is to display raw point estimates along with t statistics and to print the number of obrvations in the table footer. Furthermore, the output displays asterisks
with t statistics and to print the number of obrvations in the table footer. Furthermore, the output di
splays asterisks denoting the statistical significance of coefficients. All this can be changed. To replace the t statistics with standard errors, add the adjusted R-squared, and omit the significance asterisks; for example, typeesttab, ar2 nostart统计量也可以⽤p值(p),置信区间(ci)或估计中包含的任何参数统计信息(请参阅aux选项)。更多信息请参考esttab的option选项。esttab, beta not三、添加数据来源以及表头等信息Furthermore, the plain option produces a minimally formatted table with all display formats t to Stata’s %9.0g quasistandard, and compress reduces horizontal spacing to fit more models on screen without line breaking. Other options are, for example, label, which caus variable labels to be ud, and mtitles, which specifies that model titles be printed in the header above the model columns. For example,esttab, ar2 nostar brackets label title(This is a regression table) > nonumbers mtitles("Model A" "Model B") addnote("Source: auto.dta")四、数据结果⼩数点位数保存格式esttab, b(%9.0g) p(4) r2(4) nostar wide 五、结果输出6、outreg2命令outreg2可以帮助你在学术论⽂中看到的展⽰类型。注意到这⼀点很重要,它不是⼀个Stata命令,它是⼀个⽤户编写的过程,您需要通过输⼊来安装它(只有第⼀次)。ssc install outreg2Example1:stata code:cd
E:stataresultsu "E:statadata盈余管理新版.dta", clearreg dacc rid tm size debt14 eps, robust outreg2 using 计量经济学服务中⼼.doc, replace ctitle(Model 1) 结果输出为:You can add other mod
el (using variable x2) by using the option appendExample2:stata code:u "E:statadata盈余管理新版.dta", clearreg dacc rid tm size debt14 , robustoutreg2 using 计量经济学服务中⼼.doc, append ctitle(Model 1 Model 2) 结果输出为:Showing variable labelsThe command outreg2 gives you the type of prentation you e in academic papers. It is important to notice that outreg2 is not a Stata command, it is a ur-written procedure, and you need to install it by typing (only the first time)Example3:stata code:u "E:statadata盈余管理新版.dta", clearreg dacc rid tm size debt14 , robustoutreg2 using 计量经济学服务中⼼.doc, replace ctitle(Model 1) label 结果输出为:Fixed effects regressionExample4:stata code:u
"E:statadataFDI.dta", clearxtreg lngdp lnfdi lnie lnex lnim lnci lngp,fe robust //固定效应估计outreg2 using 计量经济学服务中⼼.doc, replace ctitle(Fixed Effects) addtext(Country FE, YES) 结果输出为:Comparing different linear modelsFixed effects with time fixed effectsExample5:stata code:u "E:statadataFDI.dta", clear xtreg lngdp lnfdi lnie lnex lnim lnci lngp,reest store rextreg lngdp lnfdi lnie lnex lnim lnci lngp,feest store fehausman fe reest table re fe, b(%6.3f) star(0.1 0.05 0.01) outreg2 [fe re] using daqinxueshu.doc,stats(coef,tstat) addstat(Ajusted R2,`e(r2_a)') replace 结果输出为:Summary statisticsUsing outreg2 for summary statistics: all variables in datatExample6:stata code:cd E:stataresults sysu auto, clear outreg2 using 计量经济学服务中⼼.doc, replace sum(log)
Using outreg2 for summary statistics: lected variablesstata code:cd E:stataresults sysu auto, clear outreg2 using 计量经济学服务中⼼.doc, replace sum(log) keep(price mpg turn) Using outreg2 for summary statistics: lected variables in datat and lected statisticsstata code:sysu auto, clear outreg2 using 计量经济学服务中⼼.doc, replace sum(log)
家用空调原理keep(price mpg turn) eqkeep(N mean) Using outreg2 for summary statistics: lected variables in datat and detail statisticsstata code:sysu auto, clear t more offoutreg2 using 计量经济学服务中⼼.doc, replace sum(detail)
keep(price mpg turn) 7、logout本⽂为⼤家介绍命令如下:ssc install logout ⽅法1安装外部命令,另外⼀种⽅法为:findit logout描述性分析-描述性统计通常对收集来的数据进⾏直接的频率、频数等描述,描述性统计分析⼀般对样本的最⼩值、最⼤值、平均值、标准偏差等进⾏分析,这些数据有助于了解样本数据特征,能够清晰的看到各个统计量的分布情况。程序如下:sysu auto.dta,clearlogout, save(logout-basic1) word excel replace: sum price mpg rep78 headroom输出结果如下:相关分析-相关关系中的重要⽅法——相关分析,可以研究变量之间关联程度和密切程度,⽽变量之间的关联程度可以⽤相关系数表⽰。logout, save(correlate) word excel replace: pwcorr price mpg rep78 headroom, sig logout,save(corr2) word excel replace: pwcorr price mpg rep78 headroom回归分析结果 u"E:statadata 盈余管理新版.dta", clear regdacc rid tm eststore da regdacc rid tm size eststore q
in regdacc rid tm size debt14 eps eststore daqinxueshu logout, save(计量经济学服务中⼼) word excel dec(3) replace: /// esttabda qin daqinxueshu, mtitle(模型 daqinxueshu deng) /// b( %6.3f) ( %6.2f) /// //系数、标准误 star(* 0.1 ** 0.05 *** 0.01) /// //显著⽔平的标注scalar(r2 r2_a N F) compress nogap