全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件
24581 6
2019-08-31

来源 :计量经济学微信公众号出品

编辑 :小计量



   Stata作为数据分析的一把利器,好用但是难学,毕竟作为一个可以编写命令的软件,你需要掌握很多很多的命令。今天小计量为大家分享一个estadd的命令,希望能够在数据分析的过程中帮助到你。



数据结果的输出能够节省你很多的时间,以前一般的操作方法时,回归结果出来进行复制自行根据期刊论文要求自己制表。如何生成控制年份、是否使用固定效应、是否在数据处理过程中加入聚类分析。


555.png


命令


clear

set more off

webuse nlswork,clear

des

xtset idcode year

tab year,gen(yd)

des yd*


*1 未控制年份OLS,对标准误进行聚类修正

reg ln_w age ttl_exp tenure not_smsa south ,vce(cluster idcode)

est store m1

*2 控制年份的OLS,对标准误进行聚类修正

reg ln_w age ttl_exp tenure not_smsa south yd* ,vce(cluster idcode)

est store m2

*控制年份的固定效应模型,对标准差进行聚类修正

xtreg ln_w age ttl_exp tenure not_smsa south yd* ,vce(cluster idcode) fe

est store m3


esttab m1 m2 m3,star(* 0.1 ** 0.05 *** 0.01) b(%6.3f) t(%6.3f) compress nogap ///

stats(N r2_a, fmt(%12.0f %9.3f)) varwidth(20) indicate("Year Fe=yd*") ///

title(Table1 wage) mtitle("OLS1" "OLS2" "FE")


help estadd

clear

set more off

webuse nlswork,clear

xtset idcode year

tab year,gen(yd)

*1 未控制年份OLS,对标准误进行聚类修正

reg ln_w age ttl_exp tenure not_smsa south ,vce(cluster idcode)

estadd local Cluster "Yes",replace

estadd local Fixed_Effect "No",replace

est store m1

*2 控制年份的OLS,对标准误进行聚类修正

reg ln_w age ttl_exp tenure not_smsa south yd* ,vce(cluster idcode)

estadd local Cluster "Yes",replace

estadd local Fixed_Effect "No",replace

est store m2

*控制年份的固定效应模型,对标准差进行聚类修正

xtreg ln_w age ttl_exp tenure not_smsa south yd* ,vce(cluster idcode) fe

estadd local Cluster "Yes",replace

estadd local Fixed_Effect "Yes",replace

est store m3


esttab m1 m2 m3 ,star(* 0.1 ** 0.05 *** 0.01) b(%6.3f) t(%6.3f) compress nogap ///

stats(Fixed_Effect Cluster N r2_a ) varwidth(20) ///

indicate("Year Fe=yd*") ///

title(Table2 wage) mtitle("OLS1" "OLS2" "Fe")


clear

set more off

webuse nlswork,clear

xtset idcode year

tab year,gen(yd)


*1 未控制年份OLS,对标准误进行聚类修正

reg ln_w age ttl_exp tenure not_smsa south ,vce(cluster idcode)

estadd local Cluster "Yes",replace

estadd local Fixed_Effect "No",replace

estadd local Year_Fe  "No",replace

est store m1

*2 控制年份的OLS,对标准误进行聚类修正

reg ln_w age ttl_exp tenure not_smsa south yd* ,vce(cluster idcode)

estadd local Cluster "Yes",replace

estadd local Fixed_Effect "No",replace

estadd local Year_Fe "Yes",replace

est store m2

*控制年份的固定效应模型,对标准差进行聚类修正

xtreg ln_w age ttl_exp tenure not_smsa south yd* ,vce(cluster idcode) fe

estadd local Cluster "Yes",replace

estadd local Fixed_Effect "Yes",replace

estadd local Year_Fe "Yes",replace

est store m3


esttab m1 m2 m3 ,star(* 0.1 ** 0.05 *** 0.01) b(%6.3f) t(%6.3f) compress nogap ///

stats(Year_Fe Fixed_Effect Cluster N r2_a) varwidth(20) ///

title(Table2 wage) mtitle("OLS1" "OLS2" "Fe")


注释


以上命令使用stata官网数据——美国妇女工资数据。


在公众号回复:数据结果输出,即可获得do文档。上文中的命令也可以直接复制在stata运行。







二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2019-9-1 09:45:44
学习了!
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2020-6-9 12:10:43
你好,为何我用了如上命令,会出现报错,显示invalid name,要不就是uncommand title is unrecognized
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2020-10-4 19:22:00
9957812794 发表于 2020-6-9 12:10
你好,为何我用了如上命令,会出现报错,显示invalid name,要不就是uncommand title is unrecognized
有的命令需要安装
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2023-10-23 17:52:13
说的不清楚,看了也没明白estadd的用处是啥
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群