一.面板数据简介
面板数据是非常常见的数据类型,尤其是在经济、金融的研究中,面板数据、时间序列数据的相关模型,得到了极大地发展和广泛的应用。
面板数据,简言之是时间序列和截面数据的混合。严格地讲是指对一组个体(如居民、国家、公司等)连续观察多期得到的资料。所以很多时候我们也称其为“追踪资料”。近年来,由于面板数据资料获得变得相对容易,使得其应用范围也不断扩大。采用面板数据模型进行分析的主要目的在于两个方向:一是控制不可观测的个体异质性,包含两个方面:一是由于民族习惯、风俗文化而形成的、不随着时间移动而改变的个体效应。二是在特定年份而出现的时间效应;二是描述和分析动态调整过程,处理误差成分。使模型包含的信息量更大,降低了变量间共线性的可能性,增加了自由度和估计的有效性。
面板数据,即Panel Data,是截面数据与时间序列综合起来的一种数据资源。在分析时,多用PanelData模型,故也被称为面板数据模型。它可以用于分析各样本在时间序列上组成的数据的特征,它能够综合利用样本信息,通过模型中的参数,既可以分析个体之间的差异情况,又可以描述个体的动态变化特征。
面板数据基本上可以认为是同一个截面的观测样本在不同时间节点的重复测量和记录;或者同样也可以认为是若干个结构、记录时间、记录选项相同的时间序列数据的复合结构。因此,在针对面板数据进行分析时候,通常可以使用截面数据的一些方法,同样也可以使用时间序列的一些方法。方法之间的共通性在这一“混合”类型的数据中体现的还是十分明显的。
二.面板数据命令汇总
以下都是常用面板命令,不作详细解释。
xtset Declare a dataset to be panel data
xtdescribe Describe pattern of xt data
xtsumSummarize xt data
xttabTabulate xt data
xtdataFaster specification searches with xt data
xtlineLine plots with xt data
xtregFixed-, between- and random-effects, and population-averaged linear models
xtregarFixed- and random-effects linear models with an AR(1) disturbance
xtmixed Multilevel mixed-effects linear regression
xtglsPanel-data models using GLS
xtpcseOLS or Prais-Winsten models with panel-corrected standard errors
xthtaylorHausman-Taylor estimator for error-components models
xtfrontierStochastic frontier models for panel data
xtrcRandom coefficients models
xtivregInstrumental variables and two-stage least squares for panel-data models
xtunitrootPanel-data unit-root tests
xtabondArellano-Bond linear dynamic panel-data estimator xtdpdsys Arellano-Bond/Blundell-Bond estimation
xtdpd Linear dynamic panel-data estimation
xttobitRandom-effects tobit models
xtintregRandom-effects interval-data regression models
xtlogit Fixed-effects, random-effects, & population-averaged logit models
xtprobitRandom-effects and population-averaged probit models
xtcloglogRandom-effects and population-averaged cloglog models
xtpoissonFixed-effects, random-effects, & population-averaged Poisson models
xtnbregFixed-effects, random-effects, & population-averaged negative binomial models
xtmelogit Multilevel mixed-effects logistic regression
xtmepoissonMultilevel mixed-effects Poisson regression
xtgee Population-averaged panel-data models using GEE
三.面板数据随机效应与固定效应检验
模型设定过程中最为关键同时也是最难的一步,在这方面功力的提高还需要大量的实践经验和对理论的深入理解。
1)检验个体效应的显著性。我们做固定效应模型时,F检验表明固定效应模型由于混合OLS模型。下面我们说明如何检验随机效应是否显著,命令为:xttest0。若P 值为0.0000,表明随机效应非常显著。
2)Hausman检验。具体步骤为:
step1:估计固定效应模型,存储估计结果;
step2:估计随机效应模型,存储估计结果;
step3:进行Hausman检验;
命令为:
xtreg GDP FDI EX IM, fe /*step1*/
eststore fe
xtreg GDP FDI EX IM, re /*step2*/
eststore re
hausman fe re/*step3*/
eststore 的作用在于把估计结果存储到名称为fe,re的临时性文件中。然后我们就可以根据Hausman检验的值进行模型的选择了。注意 Hausman检验需要将fe放在re前面。
四.动态面板数据模型
对于面板数据,如果观测到被解释变量随时间而改变,则开启了动态面板对参数估计的可能性。动态面板模型设定了一个个体的被解释变量部分取决于前一期的值。当被解释变量的滞后一期或者多期出现在解释变量中。
对于短面板数据来说,需要研究短面板的固定效应模型估计,使用一阶差分消除固定效应。通过解释变量的适当滞后期作为工具变量对一阶差分模型中的参数进行IV估计可以得到一致估计量。但是Stata有一些固定的命令,可以直接进行动态面板估计。如:xtabond、xtdpdsys、xtdpd。以上这些命令使得模型更加容易估计,同时也提供了相关的一些检验。
关于xtabond命令的stata动态面板数据
另外,Stata有个命令xtabond2,作者是:David Roodman,
http://www.cgdev.org/content/expert/detail/2719/
写过abarnewey2ivvifcollapse2等。
xtabond2的详细说明:
How to Do xtabond2:An Introduction to “Difference” and “System” GMM in Stata
http://www.cgdev.org/files/11619_file_HowtoDoxtabond8_with_foreword.pdf
还有专门介绍的PPT:
repec.org/nasug2006/How2Do_xtabond2.ppt
五.静态面板数据操作简介
首先对面板数据进行声明:
前面是截面单元,后面是时间标识:
tsset company year
tsset industry year
产生新的变量:gennewvar=human*lnrd
产生滞后变量Genfiscal(2)=L2.fiscal
产生差分变量Genfiscal(D)=D.fiscal
描述性统计
xtdes :对Panel Data截面个数、时间跨度的整体描述
Xtsum:分组内、组间和样本整体计算各个变量的基本统计量
xttab 采用列表的方式显示某个变量的分布
Stata中用于估计面板模型的主要命令:xtreg
xtreg depvar [varlist] [if exp] , model_type [level(#) ]
Model type 模型
be Between-effects estimator
fe Fixed-effects estimator
re GLSRandom-effects estimator
pa GEEpopulation-averaged estimator
mle Maximum-likelihood Random-effectsestimator
xtreg命令的应用
声明面板数据类型:xtset
描述性统计:xtsum gdp investsci admin
1.固定效应模型估计:
xtreg gdp invest culture sci health admin techno,fe
固定效应模型中个体效应和随机干扰项的方差估计值(分别为sigma u 和sigma e),二者之间的相关关系(rho)
最后一行给出了检验固定效应是否显著的F 统计量和相应的P 值
2.随机效应模型估计:
xtreg gdp invest culture sci health admin techno,re
检验随机效应模型是否优于混合OLS 模型:
在进行随机效应回归之后,使用xttest0
检验得到的P 值为0.0000,表明随机效应模型优于混合OLS 模型
3. 最大似然估计Ml:
xtreg gdp invest culture sci health admin techno,mle
Hausman检验
Hausman检验究竟选择固定效应模型还是随机效应模型:
第一步:估计固定效应模型,存储结果
xtreg gdp invest culture sci health admin techno,fe
est store fe
第二步:估计随机效应模型,存储结果
xtreg gdp invest culture sci health admin techno,re
est store re
第三步:进行hausman检验
hausman fe
Hausman检验量为:
H=(b-B)´[Var(b)-Var(B)]-1(b-B)~x2(k)
Hausman统计量服从自由度为k的χ2分布。当H大于一定显著水平的临界值时,我们就认为模型中存在固定效应,从而选用固定效应模型,否则选用随机效应模型
如果hausman检验值为负,说明的模型设定有问题,导致Hausman 检验的基本假设得不到满足,遗漏变量的问题,或者某些变量是非平稳等等
可以改用hausman检验的其他形式:
hausman fe, sigmaless
对于固定效应模型的异方差检验和序列相关检验:
Xtserial gdp invest culture sci health admin techno
异方差检验:
xtreg gdp invest culture sci health admin techno,fe
xttest3 (Modified Wald statistic for groupwise heteroskedasticity in fixedeffect model)
随机效应模型的序列相关检验:
xtreg gdp invest culture sci health admin techno,re
Xttest1
Xttest1用于检验随机效应(单尾和双尾) 、一阶序列相关以及两者的联合显著
检验结果表明存在随机效应和序列相关,而且对随机效应和序列相关的联合检验也非常显著
可以使用广义线性模型xtgls对异方差和序列相关进行修正:
xtgls gdp invest culture sci health admin techno, panels(hetero),修正异方差
xtgls gdp invest culture sci health admin techno, panels(correlated),修正依横截面而变化的异方差
xtgls gdp invest culture sci health admin techno, panels(hetero) corr(ar1),修正异方差和一阶序列相关ar(1)返回搜狐,查看更多