目录
简单介绍
1、内生性:
2、为什么要解决内生性问题?
3、内生性问题产生的原因
4、例子
代码(简洁版):
代码(详细分析版):
结果
简单介绍
1、内生性:
x与误差项有相关关系
2、为什么要解决内生性问题?
内生性会破坏参数估计的“一致性”。
参数估计的“一致性”就是指:
当样本量很大时,用样本估计出的参数会无限趋近于总体的真实参数。
简单理解就是:因为Y同时受到x和扰乱项的影响,若 x对误差项有影响,则x对y的影响说不清了。
3、内生性问题产生的原因
随机扰动项和解释变量存在相关主要源自
遗漏变量偏误(omitted variable bias)
测量偏误(measurement error)
互为因果(simultaneity)
自选择偏误(self-selection bias)
样本选择偏误(sample selection bias )
(本文重点讲样本选择)
简单区分一下自选择偏误和样本选择偏误:
样本选择中,个体差异在于是否有机会进入到观测样本,那些没有进入样本的个体,其y是观测不到的;
而在自选择偏误中,个体的差异在于是否得到处理,并且这种差异是个体自选择形成的,而不论是否得到处理,其y都是可观测的。
4、例子
研究妇女工资和其受教育程度和工作经验的关系:
因变量y:妇女工资水平
自变量x:受教育程度和工作经验
已知200个妇女,其中只有100个妇女有工作,即样本只能是这100个妇女
(因为没工作的妇女我们没有办法调查到或者没工作也就没资格谈收入水平)
结果我们只能用着100个有工作的妇女的数据去做回归分析,得到了受教育程度和工作经验是显著正向影响工资水平的,但显然这个结论是不可靠的,因为样本的非随机性不能反映出总体的真实情况。
解决办法:Heckman两阶段法
代码(简洁版):
findit esttab
use "D:\大二\回归分析\内生性\womenwk",clear
reg lw education age children if work==1
est sto k1
heckman lw education age children,select(work=education age children married) mle nolog
est sto k2
heckman lw education age children,select(work=education age children married) twostep
est sto k3
local d "using D:\大二\回归分析\内生性\结果1.rtf"
local a "k1 k2 k3"
esttab `a' `d', b(%6.4f) se(%6.4f) nogap compress
star(* 0.1 ** 0.05 *** 0.01)
ar2 scalar(N) replace
代码(详细分析版):
//y:lw
//x:education, age, children
//下载安装包esttab
findit esttab
//已知:数据储存在womanwk里,womanwk储存在“D:\大二\回归分析\内生性”里
//当你想用stata处理这些数据时,用下面这行代码实现
use "D:\大二\回归分析\内生性\womenwk",clear*传统的简单回归
reg lw education age children,r //如果只想对有工作的妇女的信息进行回归,则用下面这一行代码取代上面那行
//reg lw education age childrenif work==1est sto k1 //保存为k1表
*用两步法
heckman lw education age children,select(work=education age children married) mle nolog
est sto k2*用一步法twostep
heckman lw education age children,select(work=education age children married) twostep
est sto k3//保存结果
local d "using D:\大二\回归分析\内生性\结果.rtf"
local a "k1 k2 k3"
esttab `a' `d', b(%6.4f) se(%6.4f) nogap compress
star(* 0.1 ** 0.05 *** 0.01)
ar2 scalar(N) replace
结果
(1)回归 | (2)两步法 | (3)一步法 | |
lw | lw | lw | |
main | |||
education | 0.0372*** | 0.0397*** | 0.0427*** |
(0.0023) | (0.0025) | (0.0031) | |
age | 0.0062*** | 0.0076*** | 0.0093*** |
(0.0009) | (0.0010) | (0.0014) | |
children | -0.0312*** | -0.0180** | -0.0020 |
(0.0047) | (0.0065) | (0.0115) | |
_cons | 2.4531*** | 2.3055*** | 2.1248*** |
(0.0427) | (0.0653) | (0.1250) | |
work | |||
education | 0.0565*** | 0.0584*** | |
(0.0110) | (0.0110) | ||
age | 0.0350*** | 0.0347*** | |
(0.0042) | (0.0042) | ||
children | 0.4538*** | 0.4473*** | |
(0.0288) | (0.0287) | ||
married | 0.4548*** | 0.4309*** | |
(0.0736) | (0.0742) | ||
_cons | -2.4781*** | -2.4674*** | |
(0.1928) | (0.1926) | ||
/ | |||
athrho | 0.3378** | ||
(0.1152) | |||
lnsigma | -1.3755*** | ||
(0.0247) | |||
/mills | |||
lambda | 0.1823** | ||
(0.0638) | |||
N | 1343 | 2000 | 2000 |
Standard errors in parentheses
* p < 0.05, ** p < 0.01, *** p < 0.001