stata 求输出相关系数矩阵命令_一文读懂结果输出命令大全(上)

stata 求输出相关系数矩阵命令_一文读懂结果输出命令大全(上)目录描述统计量helptabstat//Stata官方命令描述统计量组间均值差异检验helpttesthelpttable2helpestout相关分析命令helppwcorrhelppwcorr_a回归相关分析命令helpesttabhelpoutreg2helplogoutstata命令汇总helpsum2docx//输出基…

大家好,又见面了,我是你们的朋友全栈君。

目录

  • 描述统计量

  • 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,最小值

sd,标准差

variance,方差

semean,即sd/√n

skewness,偏度

kurtosis,峰度

p1,第一分位数

p5,第五分位数

p10,第十分位数

p50,中位数

median,中位数

range,max-min

示例:

sysuse auto tabstat price weight mpg rep78tabstat price weight mpg rep78, by(foreign) stat(mean sd min max)对变量price, weight, mpg, and rep78 按照foreign分类展示其描述统计量mean sd min max

结果为:

cf0bcde3e806005abe59fe3f8d05fbd5.png

2、ttest

样本检验

示例:

sysuse auto ttest mpg==20 (one-sample t test)webuse fuel3 (setup) ttest mpg, by(treated) (two-sample t test using groups)webuse fuel (setup)ttest mpg1==mpg2 (two-sample t test using variables)

3、ttable2

示例:

sysuse auto,clearttable2 price wei len mpg, by(foreign)ttable2 price wei len mpg, by(foreign) f(%6.2f)tab rep78ttable2 price wei len mpg if rep78==3|rep78==4, by(rep78)**输出保存到Word文档等Save in Excel or Wordlogout, save(Tab2_corr) excel replace: ttable2 price wei len mpg, by(foreign)

结果为:

1ae5c370712b11a5d86b6a81db36a48d.png

2af35ee3f573b38ee7074b43ef56ec2e.png

cb873c340c4c1c5614893b41ca3a3d71.png

cabbfeb0b87577cbbb440aeb8842c054.png

9bf524d67fbbc545dfe3f258793f0f97.png

c41c5e51fe5f59f527fd0b899ac66e5d.png

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:

sysuse auto pwcorr price headroom mpg displacement ,sig star(0.01)

结果为:

97c10f63f8762847e2ffdacd61b7fc0f.png

使用pwcorr可以对指定的显著性水平进行标注。 缺点是只能对指定的显著水平标注一个 *,即无法同时标注1% 5% 10%。
2
pwcorr_a
pwcorr_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_a price weight mpg displ, star1(0.01) star5(0.05) star10(0.1)

结果为:

703726a0d9b0d270ec28c29c5d471115.png

3
输出相关系数矩阵到Word文档中
代码为:

sysuse auto, clearlogout, save(数量经济学) word replace: ///        pwcorr_a price wei len mpg    //标注star(0.05)

结果为:

a60beee212ce3884f3ad455807833322.png

4
输出相关系数矩阵到Excel文档中
代码为:

sysuse auto, clearlogout, save(数量经济学) excel replace: ///        pwcorr_a price wei len mpg    //标注star(0.05)

结果为:

a27e3cf53bf7781def2c8f490c4a520e.png

5、esttab

新的esttab命令是estout的升级版本。它的语法相比较于estout而言,默认情况下,它会生成很好地结果,并输出在Stata的结果窗口中。 

esttab不仅仅是estout的简化版本。另一方面,esttab提供完整的estout功能,因为所有的estout选项都是允许在esttab中。 另一方面,esttab也扩展了功能。例如,esttab支持与WORD、Excel、Latex、Html结果

一、Basic syntax and usage

Syntax

esttab [namelist] [using filename] [, options]

与estout(或官方Stata的估计表)一样,基本程序是首先存储多个模型,然后将esttab应用于这些存储的估计集以组成回归表。但是,esttab和estout之间的主要区别在于,如果在没有选项的情况下应用,esttab会生成一个完全格式化的表。 

dc7f5dfde4dab9af013aa31bcdc2e4d4.png

二、添加统计量

The default in esttab is to display raw point estimates along with t statistics and to print the number of observations in the table footer. Furthermore, the output displays 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, type

esttab, se ar2 nostar

结果为:

70800f83cbc08daa9f7d32302b51f767.png

t统计量也可以用p值(p),置信区间(ci)或 估计中包含的任何参数统计信息(请参阅aux()选项)。更多信息请参考esttab的option选项。

esttab, beta not

55b398f23d4a0d577105a51d9f0b59b2.png

三、添加数据来源以及表头等信息

Furthermore, the plain option produces a minimally formatted table with all display formats set 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 causes variable labels to be used, and mtitles(), which specifies that model titles be printed in the header above the model columns. For example,

esttab, se ar2 nostar brackets label title(This is a regression table) > nonumbers mtitles(“Model A” “Model B”) addnote(“Source: auto.dta”)

3617059a56ed4aef42d7754d05880bc4.png

四、数据结果小数点位数保存格式

esttab, b(%9.0g) p(4) r2(4) nostar wide

c5b18fc9268ddcac33accff46efc4051.png

五、结果输出

use “E:\stata\data\盈余管理新版.dta”, clear

reg dacc rid tm

est store da

reg dacc rid tm size

est store qin

reg dacc rid tm size debt14 eps

est store daqinxueshu

esttab da qin daqinxueshu using daqinxueshu14.rtf, ///

 mtitles(“model 1” “model 2” “model 3” ) ///

title(“This is the Second regression table”) ///

append star( * 0.10 ** 0.05 *** 0.01 ) staraux r2 nogaps 

b3912026106b98a495c9b28dcc8c61e7.png

6、outreg2

命令outreg2可以帮助你在学术论文中看到的展示类型。注意到这一点很重要,它不是一个Stata命令,它是一个用户编写的过程,您需要通过输入来安装它(只有第一次)。

ssc install outreg2

Example1:

stata code:

cd E:\stata\results

use “E:\stata\data\盈余管理新版.dta”, clear

reg dacc rid tm size debt14 eps, robust 

outreg2 using 计量经济学服务中心.doc, replace ctitle(Model 1) 

结果输出为:

22aea715870a5dfb5e3b80637b81cede.png

You can add other model (using variable x2) by using the option append

Example2:

stata code:

use “E:\stata\data\盈余管理新版.dta”, clear

reg dacc rid tm size debt14 , robust

outreg2 using 计量经济学服务中心.doc, append ctitle(Model 1 Model 2) 

结果输出为:

5d73dd8f59ba0bbd00ec06da2a83e064.png

Showing variable labels

The command outreg2 gives you the type of presentation you see in academic papers. It is important to notice that outreg2 is not a Stata command, it is a user-written procedure, and you need to install it by typing (only the first time)

Example3:

stata code:

use “E:\stata\data\盈余管理新版.dta”, clear

reg dacc rid tm size debt14 , robust

outreg2 using 计量经济学服务中心.doc, replace ctitle(Model 1) label 

结果输出为:

de7d52363451477e670a9ae6c3ca441b.png

Fixed effects regression

Example4:

stata code:

use “E:\stata\data\FDI.dta”, clear

xtreg lngdp lnfdi lnie lnex lnim  lnci lngp,fe robust   //固定效应估计

outreg2 using 计量经济学服务中心.doc, replace ctitle(Fixed Effects) addtext(Country FE, YES) 

结果输出为:

c986b3cebbaabb8cbf0cc042dc418be3.png

Comparing different linear models

Fixed effects with time fixed effects

Example5:

stata code:

use “E:\stata\data\FDI.dta”, clear

xtreg lngdp lnfdi lnie lnex lnim  lnci lngp,re

est store re

xtreg lngdp lnfdi lnie lnex lnim  lnci lngp,fe

est store fe

hausman fe re

est 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 

结果输出为:

5c54baf45e400f88e3dbbc82dd69ba17.png

Summary statistics

Using outreg2 for summary statistics: all variables in dataset

Example6:

stata code:

cd E:\stata\results

sysuse auto, clear 

outreg2 using 计量经济学服务中心.doc, replace sum(log)

74b73d7eb7d595bd6fe89b4f2d7c5080.png

Using outreg2 for summary statistics: selected variables

stata code:

cd E:\stata\results

sysuse auto, clear 

outreg2 using 计量经济学服务中心.doc, replace sum(log) keep(price mpg turn) 

625d1137c085b3025657f1de9847dbca.png

Using outreg2 for summary statistics: selected variables in dataset and selected statistics

stata code:

sysuse auto, clear 

outreg2 using 计量经济学服务中心.doc, replace sum(log) keep(price mpg turn) eqkeep(N mean) 

b0a012e0135e33e05f3d7b7aa916e249.png

Using outreg2 for summary statistics: selected variables in dataset and detail statistics

stata code:

sysuse auto, clear 

set more off

outreg2 using 计量经济学服务中心.doc,  replace sum(detail) keep(price mpg turn) 

fe0a1d30654951676bd53e4b7e257317.png

7、logout

本文为大家介绍命令如下:

ssc install logout  

e99a868b98572097c498c206f8a8b83c.png

方法1安装外部命令,另外一种方法为:findit logout

d73c9bbf315c3d0a8cfd34bd705d50c2.png

bc339ee7d969f3f318151b0646b3eafc.png

描述性分析-

描述性统计通常对收集来的数据进行直接的频率、频数等描述,描述性统计分析一般对样本的最小值、最大值、平均值、标准偏差等进行分析,这些数据有助于了解样本数据特征,能够清晰的看到各个统计量的分布情况。

程序如下:

sysuse auto.dta,clear

logout, save(logout-basic1) word excel replace: sum price mpg rep78 headroom

输出结果如下:

9546458d1b66db9a042c9807499b98d2.png

43035a2716cbc1accbd7ea44929d8b61.png

相关分析-

相关关系中的重要方法——相关分析,可以研究变量之间关联程度和密切程度,而变量之间的关联程度可以用相关系数表示。

logout, save(correlate) word excel replace: pwcorr price mpg rep78 headroom, sig

1f2c5976b33d50085a4d34254a36a046.png

52ab79cd9b60dbfb6b74cce338aeba62.png

logout,save(corr2) word excel replace: pwcorr  price mpg rep78 headroom

c7272a67406ec2eae70c3a13259adaaf.png

回归分析结果

use "E:\stata\data\盈余管理新版.dta", clearreg dacc rid tmest store dareg dacc rid tm sizeest store qinreg dacc rid tm size debt14 epsest store daqinxueshulogout, save(计量经济学服务中心) word excel dec(3) replace:   ///          esttab da qin daqinxueshu, mtitle(模型   daqinxueshu deng) ///          b(%6.3f) se(%6.2f)                  /// //系数、标准误         star(* 0.1 ** 0.05 *** 0.01)        /// //显著水平的标注      scalar(r2 r2_a N F) compress nogap  

结果为:

a84a43849a908bf1185830d83c1b5586.png

b85f6f222b0444f9f42e53fd4122d4ef.png

·

·

·

五年,计量经济学服务中心,专业的计量服务平台

l 计量经济学服务中心 l

计量经济学服务中心,一个专注计量经济学的专业计量服务平台。中心专注于计量经济学及Eviews、Stata、SPSS、Matlab、Geoda、Python、ArcGIS、R等相关方法及软件操作,旨在为大家分享经管人文社科等领域的相关知识,希望能帮助大家更好的学习计量。转载请后台留言联系。

软件操作:Geoda | Matlab  | ArcGIS  | Python经典书单 | Eviews9.0简介  | Stata 16

  | SPSS常见数据分析方法比较汇总 | 

一文读懂:内生性专题(上) | 内生性专题(中) | 面板数据 | 数据管理  | 门限回归 |格兰杰因果检验 | 空间计量命令

面板数据:短面板 | 长面板  | 面板向量自回归 | 实证方法 | 方法汇总  | 主要命令 | 面板泊松模型 | 面板随机前沿模型 | 面板离散选择模型  | 面板工具变量法 | 面板负二项模型| 面板Tobit模型

横截面计量:回归分析 | 武功秘籍  |异方差自相关与多重共线性

时间序列:思维导图   | 知识汇总 | 平稳性 | 时间序列学习手册

空间计量:前世今生  | 不可不知  | 空间计量经济学分析  | 空间计量经济学:从横截面数据到空间面板

政策评估:合成控制法 | 倾向得分匹配法 | 断点回归(RD) | 双重差分

长按2秒识别二维码关注我们

欢迎把我们推荐给你的家人和朋友哟

b6d7bf83aceada8c25e234e6aa894fb0.png

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/148203.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • CMD命令提示符窗口中的快捷键、小技巧和常用命令

    CMD命令提示符窗口中的快捷键、小技巧和常用命令快捷键:F1:按F1一次,命令提示符向后切换到已经执行过的命令字符。如果已经是最后的一条的命令,则不进行任何切换操作。例子:之前输入“dir”,按F1一次后自动输入d,按两次自动输入i,三次自动输入r。F2:按下此键后,会提示“输入可复制的字符数量”,此时直接按下上次输入命令中包含的字符(区分大小写)后命令提示符将自动输入到按键字符之前的上次输入的命令

    2022年4月5日
    87
  • 读还是不读:that is the question

    点击上方☝,轻松关注!及时获取有趣有料的技术文章一个人只拥有此生此世是不够的,他还应该拥有诗意的世界。——王小波读书日今天是2020年的世界读书日,时间过的就是那么的快,不感概都不行!想…

    2022年2月28日
    56
  • Java.Utils:获取电脑配置信息

    Java.Utils:获取电脑配置信息packagecom.boob.common.utils;importjava.io.*;/***@description:电脑配置信息*@author:boob*@since:2020/2/7*/publicclassHardwareUtils{publicHardwareUtils(){}/***获取…

    2022年7月14日
    17
  • 风控模型评估方法以及大数据风控模型概念

    风控模型评估方法以及大数据风控模型概念更新一下有效性指标中的区分能力指标:KS(Kolmogorov-Smirnov):KS用于模型风险区分能力进行评估,指标衡量的是好坏样本累计分部之间的差值。好坏样本累计差异越大,KS指标越大,那么模型的风险区分能力越强。KS的计算步骤如下:1.计算每个评分区间的好坏账户数。2.计算每个评分区间的累计好账户数占总好账户数比率(good%)和累计坏账户数占总坏账户数比率(bad%

    2022年6月3日
    40
  • MIPI协议知识

    MIPI协议知识转发路径:https://blog.csdn.net/weixin_41842559/article/details/109828013?spm=1001.2101.3001.6650.14&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7ERate-14.pc_relevant_paycolumn_v3&depth_1-utm_source=distribute.pc_

    2022年6月2日
    37
  • c语言程序设计答案 第五版 谭浩强

    c语言程序设计答案 第五版 谭浩强1 假如我国国民生产总值的年增长率为 7 计算 10 年后我国国民生产总值于现在相比增长多少百分比 计算公式为 p 1 r 2 r 为年增长率 n 为年数 p 为于现在相比比的倍数 include stdio h include math h pow 为调用数学函数需要加 math h 头文件 intmain intn floatp r math h stdio h

    2025年6月17日
    2

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号