- sysuse auto,clear
- ivregress2 2sls mpg weight (length=displacement),first
- est restore first
- outreg2 using xxx.doc,cttop(first) tstat bdec(3) tdec(2) replace
- ivregress2 2sls mpg weight (length=displacement),first
- outreg2 using xxx.doc,cttop(second) tstat bdec(3) tdec(2)
上述方案不够简洁,有点让人难以理解,也不好记,所以我给大家提供一条简洁的命令,只要按outreg2的命令写法一步完成。
- ivregress2 2sls mpg weight (length=displacement),first
- outreg2 [first second] using xxx.doc, tstat bdec(3) tdec(2) replace
对于ivreg2,稍微有点区别,只要在回归中加入savefp(first)选项即可。
- sysuse auto,clear
- ivreg2 mpg weight (length=displacement),first savefp(first)
- eststo second
- outreg2 [firstlength second] using xxx1.doc, tstat bdec(3) tdec(2) replace
最终呈现到Word中结果如下:
对于xtivreg2,可能稍微有点复杂,跟本文开头的方案类似。
- use http://fmwww.bc.edu/ec-p/data/macro/abdata.dta,clear
- xtset id year
- xtivreg2 ys k (n=l2.n l3.n), fe first savefp(first)
- eststo second
- est restore firstn
- outreg2 using xxx1.doc,cttop(first) tstat bdec(3) tdec(2) replace
- est restore second
- outreg2 using xxx1.doc,cttop(second) tstat bdec(3) tdec(2)
最终效果如下:
对于ivreghdfe,类似于ivreg2,这里同时给出outreg2以及esttab的解决方案:
- ***ivreghdfe----outreg2******
- sysuse auto, clear
- eststo:ivreghdfe price (weight=length), a(foreign) first savefirst savefp(f)
- est restore fweight
- outreg2 using xxx.doc,cttop(first) replace
- est restore est1
- outreg2 using xxx.doc,cttop(second)
- ***ivreghdfe----esttab同时加入F统计量******
- sysuse auto, clear
- eststo: ivreghdfe price (weight=length), a(foreign) first savefirst savefprefix(f)
- estadd scalar F = `e(widstat)' : fweight //将第二阶段得到的弱工具变量检验统计量加到第一阶段模型中
- esttab fweight est1 using xxx.doc, scalar(F) replace
esttab得到表格如下图所示,对于ivreghdfe似乎esttab更方便。