全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Stata专版
5260 0
2024-10-21

stata回归结果导出命令esttab

首先,打开我们今天要用到的数据集,我们使用系统自带的吧

命令sysuseauto.dta

这里依次给大家介绍在实证分析中一定能够用到esttab的几个常用输出命令,

安装命令ssc install estout,replaceEsttabestout的简化版本,因此先安装外部命令一、基础语法esttab [namelist] [using filename] [, options][示例1] 导入示例数据集sysuse auto.dta。被解释变量为汽车价格price,解释变量包括weightmpgforeignregprice weighteststore m1regprice weight mpgeststore m2regprice weight mpg foreigneststore m3esttab m1 m2 m3,replace二、添加统计量esttab默认在估计系数下方括号中输出t统计量且保留两位小数。更改、添加统计量需要在[,options]选项进行重新设置。[示例2] 添加p值和调整regprice weighteststore m1regprice weight mpgeststore m2regprice weight mpg foreigneststore m3esttab m1 m2 m3,replace p ar2// ar2表示调整p值可以更换成其他统计量,如标准误se、置信区间ci 三、设置数据格式3.1 小数点后保留位数以上结果输出表格中,我们看到小数点后保留位数是不一致的,可以进行以下设置:[示例3]regprice weighteststore m1regprice weight mpgeststore m2regprice weight mpg foreigneststore m3esttab m1 m2 m3,replace b(%6.4f)p(%6.4f) ar2(4)//b(%6.4f)设置估计系数保留四位小数,整数部分可以达到六位。3.2 表格格式除了添加各类统计量以及显著性水平以外,我们还可以在[,options]中设置表格格式。[示例4]regprice weighteststore m1regprice weight mpgeststore m2regprice weight mpg foreigneststore m3esttab m1 m2 m3,replace b(%6.4f) p(%6.4f) ar2(4)  ///star(* 0.1 ** 0.05 *** 0.01) ///compress nogap ///mtitles("model1" "model2" "model3") ///title("Table1")//nogap表示删除表格间距;mtitles()定义表格中每一列的模型名称;title( )添加表格标题 四、导出结果[示例5]regprice weightregprice weighteststore m1regprice weight mpgeststore m2regprice weight mpg foreigneststore m3esttab m1 m2 m3 using reg1.rtf, ///replace b(%6.4f) p(%6.4f) ar2(4) star(* 0.1 ** 0.05 *** 0.01)  ///compress nogap  ///mtitles("model1" "model2" "model3") title("Table1")//输出文件名为reg1rtf格式文件。rtf可以更改为csvword等其他文件类型。esttabm1 m2 m3 using reg1.rtf, replace b(%6.4f) p(%6.4f) ar2(4) star(* 0.1 ** 0.05*** 0.01)  compress nogap  mtitles("model1" "model2""model3") title("Table1")括号下面默认是t,上述代码是p 如果想括号下面是se标准误,esttabm1 m2 m3 using reg1.rtf, replace b(%6.4f) se(%6.4f) se ar2(4) star(* 0.1 **0.05 *** 0.01)  compress nogap  mtitles("model1" "model2""model3") title("Table1")

二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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