stata关于⾯板数据
stata关于⾯板数据
标签:
杂谈⾸先对⾯板数据进⾏声明:
前⾯是截⾯单元,后⾯是时间标识:tsset company yeartsset industry year
产⽣新的变量:gen newvar=human*lnrd产⽣滞后变量Gen fiscal(2)=L2.fiscal产⽣差分变量Gen fiscal(D)=D.fiscal描述性统计:
xtdes :对Panel Data截⾯个数、时间跨度的整体描述Xtsum:分组内、组间和样本整体计算各个变量的基本统计量xttab 采⽤列表的⽅式显⽰某个变量的分布
Stata中⽤于估计⾯板模型的主要命令:xtregxtreg depvar [varlist] [if exp] , model_type [level(#) ]Model type 模型
be Between-effects estimatorfe Fixed-effects estimatorre GLS Random-effects estimatorpa GEE population-averaged estimator
mle Maximum-likelihood Random-effects estimator主要估计⽅法:
xtreg: Fixed-, between- and random-effects, and population-averaged linear modelsxtregar:Fixed- and random-effects linear models with an AR(1) disturbancextpcse :OLS or Prais-Winsten models with panel-corrected standard errorsxtrchh :Hildreth-Houck random coefficients models
xtivreg :Instrumental variables and two-stage least squares for panel-data modelsxtabond:Arellano-Bond linear, dynamic panel data estimatorxttobit :Random-effects tobit models
xtlogit : Fixed-effects, random-effects, population-averaged logit modelsxtprobit :Random-effects and population-averaged probit modelsxtfrontier :Stochastic frontier models for panel-dataxtrc gdp invest culture edu sci health social admin,beta
xtreg命令的应⽤:
声明⾯板数据类型:tsset sheng t描述性统计:xtsum gdp invest sci admin1.固定效应模型估计:
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,feest store fe
第⼆步:估计随机效应模型,存储结果
xtreg gdp invest culture sci health admin techno,reest 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 fixed effect model)随机效应模型的序列相关检验:
xtreg gdp invest culture sci health admin techno,reXttest1
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)