Stata:面板交互固定效应模型
简介
面板交互固定效应模型指的是通过设置个体固定效应与时间效应的交互项,通过控制这些随时间和个体变化的不可观测因素(遗漏变量问题),来减少模型估计的内生性问题,提高模型估计的拟合优度。
白聚山(Bai2009)在线性面板数据中引入了个体差异和时间差异的交互效应,来反映共同因素对不同个体的效应差异。详见Bai, Jushan. Panel data models with interactive fixed effects. (2009) Econometrica.
面板交互固定效应估计方法
面板交互固定效应模型的估计命令为regife。regife符合Bai(2009)的一个具有交互固定效应的模型。如果希望拟合具有多维/高维固定效果的模型,请使用reghdfe。它还可以保存估计的交互固定效果。该程序需要安装reghdfe和hdfe(在SSC上都可用)。
首先需要下载该外部命令,使用如下命令进行下载
help regife
regife 现在可以从 ssc下载,但是需要reghdfe
ssc install reghdfe
ssc install regife
在Github上安装最新版本
net install regife, from("https://raw.githubusercontent.com/matthieugomez/regife/master/")
对于Stata 12或更早版本,下载存储库的zip文件,并在Stata中运行以下命令
net install regife, from("SomeFolderRegife")
引用方法为:
Matthieu Gomez, 2015. REGIFE: Stata module to estimate linear models with interactive fixed effect. Statistical Software Components s457874, Boston College Department of Economics. https://ideas.repec.org/c/boc/bocode/s458042.html
相关语法格式为
regife depvar [indepvars] [if] [in] [weight] , ife(idvar timevar, ndmis) [options]
选项含义为
ife (idvar timevar, ndims)指定id变量、时间变量和固定效应的时间维度。要保存估计的交互固定效果,写入ife(ife_idvar = idvar ife_timevar= timevar, ndims).
absorb(absvar[...]) 表示将被吸收的固定效应,即加入个体或者时间固定效应
vce(vcetype[, opt]) vcetype是unadjusted/ols (default), robust, bootrap or cluster clustervars.。蒙特卡罗证据表明,bootstrap在有限样本中具有较好的性能
案例应用
1、下面我们下载nlswork数据来研究工作年限对员工收入的影响。
webuse nlswork
keep if id <= 100
2、然后进行一维交互固定效应模型估计
* Factor model in id, year of dimension 1
regife ln_w tenure, ife(id year, 1)
3、加入个体效应Model including id fixed effect, and a factor model in id, year of dimension 2
regife ln_w tenure, a(id) ife(id year, 1)
4、个体效应基础上继续加入时间效应Model including id fixed effect, year fixed effect, and a factor model in id, year of dimension 1
regife ln_w tenure, a(id year) ife(id year, 1)
5、保存结果Save interactive fixed effects
regife ln_w tenure, ife(ife_id = id ife_year = year, 1)
6、Save fixed effects and interactive fixed effects
regife ln_w tenure, a(fe_id = id fe_year = year) ife(ife_id = id ife_year = year, 1)
7、产生残差项Generate residuals
regife ln_w tenure, ife(id year, 1) residuals(newvar)
8、Bootstrap 方法计算标准误
regife ln_w tenure, ife(id year, 1) vce(bootstrap)
References
- Bai, Jushan. Panel data models with interactive fixed effects. (2009) Econometrica
- Ilin, Alexander, and Tapani Raiko. Practical approaches to principal component analysis in the presence of missing values. (2010) The Journal of Machine Learning Research 11
- Koren, Yehuda. Factorization meets the neighborhood: a multifaceted collaborative filtering model. (2008) Proceedings of the 14th ACM SIGKDD international conference on Knowledge discovery and data mining.
- Raiko, Tapani, Alexander Ilin, and Juha Karhunen. Principal component analysis for sparse high-dimensional data. (2008) Neural Information Processing.
- Srebro, Nathan, and Tommi Jaakkola. Weighted low-rank approximations (2010) The Journal of Machine Learning Research 11
- Nocedal, Jorge and Stephen Wright An Inexact Levenberg-Marquardt method for Large Sparse Nonlinear Least Squares (1985) The Journal of the Australian Mathematical Society