查看原文
其他

stata输出结果之estadd

小计量 计量经济学 2022-12-31


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

编辑 :小计量

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

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







命令


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官网数据——美国妇女工资数据。

您可能也对以下帖子感兴趣

文章有问题?点此查看未经处理的缓存