土土阿力 发表于 2022-11-30 17:23 
您好,我是初学者,看到帖子中对两阶段最小二乘法的导出技巧感到收获颇丰。不过在使用xtivreg2命令的过程 ...
我之前遇到过这个问题并且困扰了我很久,个人觉得这个命令并不能试用所有的回归。下面我来分享一下我借鉴来的命令,希望对你有所帮助。
ivregress2 2sls y x2 x3 x4 i.industry (x1=z1 z2 z3), first
estimates restore first
outreg2 using twostage.doc,cttop(first stage) bdec(4) replace
estimates restore second
outreg2 using twostage.doc,cttop(second stage) bdec(4)
注释:y代表被解释变量 x1为内伤解释变量 x2-x4等为控制变量, i.industry为生成行业虚拟变量,z1-z3为虚拟变量