t因变量,g,f,c是自变量,_26存放了弟26个观测值,为需要预测的值 reg t g f c if _n!=26 点预测
predict taxpredict if _n==26
均值的区间预测
predictnl py=predict(xb),ci(lb ub) l(95)
因变量的区间预测
adjust g=117251.9 f=24649.95 c=99.9,stdf ci level(95)
Hausman检验是检验内生性的最常用的方法。它是通过比较一致估计量与有效估计量的Wald统计量。 命令格式为:
.hausman name-constistent [name-efficent] [,options]
其中,name-cosistent指一致估计的结果, name-efficent 指有效估计的结果。注意,一致、有效估计量的先后顺序不能改变。 Option选项:
constant 计算检验统计量将常数也包括在内,默认值为排除常数 allegs 利用所有方程进行检验,默认只对第一个方程进行检验 skipeqs(eqlist) eqlist只能以方程名称而不能以方程序号表示 equation(matchlist) 比较设定的方程。 force 即使假设条件不满足仍进行检验
df(#) 默认值为一致估计与有效估计的协方差矩阵的差的估计 sigmamore 协方差矩阵采用有效估计量的协方差矩阵 sigmaless 协方差矩阵采用一致估计量的协方差矩阵 tconsistent(string) 一致估计量的标题 tefficient(string) 有效估计量的标题
工具变量估计 命令格式:
.ivregress esitimator depvar [varlist1] [varlist2=varlist_iv] [if] [in] [weight][,options]
其中,estimator包括2sls,gmm,liml三种。varlist1为模型中的外生变量,varlist2为模型中的内生变量,varlist_iv为模型中的工具变量。 Nonconstant 不包括常数项 Hascons 用户自己设定常数项 CMM 选项:
wmatrix(wmtype) robust,cluster clustvar,hac kernel, unadjusted center 权数矩阵采用中心矩 igmm 采用迭代GMM估计
eps(#) 参数收敛标准。默认值为eps(le-6)
weps(#) 权数矩阵的收敛标准。默认值为w eps(le-6)
Vce(vcetype) unajusted,robust,cluster clustvar,bootstrap,jackknife,hac kernel
level(#)置信区间
First 输出第一阶段的估计结果 Small 小样本下的自由度调整
.estat firststage [,all forcenonrobust]
该命令给出第一阶段的估计结果以及各种统计量,包括排除外生变量的相关性检验。All选项给出所有的拟合优度统计量。如果模型存在多个内生变量,则stata给出R2、偏R2、调整的R2 、F统计量;如果模型存在多个内生变量,则stata给出Shea偏R2和调整的偏R2。
forcenonrobust给出最小特征值统计量及其临界值,即使采用稳健估计(这一检验的假设条件是误差项为独立正态分布)。
estat overid[,lag(#) forceweights forcenonrobust]
该命令给出了过度识别约束检验。如果使用2sls估计估计,则Stata给Sargan’s(1958)和Basman’s(1960)卡方统计量,这也是Wooldridge’(1995)稳健得分检验。如果采用liml估计方法,则stata给出Anderson and Rubin’s(1950) 卡方统计量以及Basmann F统计量;如果采用GMM估计,则stata给出hansen’s(1982)J统计量。Lags(#)用于计算得分检验的HAC(异方差自相
关一致)统计量的过程中进行去噪时设定滞后阶数。如果设定lag(0),则表示不进行去噪处理。默认选择为lag(1)。这一选择仅使用于2sls估计方法和设定vce(hac)选项情况。
Forceweight 表示即使采用aweights,pweights或iweights也进行检验。Stata仅对于fweights的情况进行检验,其他权数所得到临界值可能不准确。 Forcenonrobust 指在2sls或LIML估计中即使采用稳健标准差也进行Sargan and Basmann检验(这一检验的假设的假设条件是误差项为独立正态分布)。 例子:
log(wage)=a+b*educ+c*exper+d*expersq+u
怀疑模型教育(educ)具有内生性问题,利用父母接受教育的年数(fatheduc,motheduc)作educ的工具变量估计上述模型。 (1)利用2SLS估计模型
.ivregress 2sls lwage exper expersq (educ=fatheduc motheduc),first 第一阶段回归结果为:
educhat=9.1+0.19fatheduc+0.16motheduc+0.05exper
(21.34) (5.62) (4.39) (1.12) - 0.001expersq (-0.84) 第二阶段的估计结果为:
lwagehat=0.05+0.06educ+0.04exper-0.001expersq
(0.12) (1.95) (5.29) (-2.24) (2)检验educ的内生性
.quietly ivreg iwage exper expersq {educ=fatheduc motheduc} .est store IV_reg
.quietly regress lwage exper expersq educ .est store LS_reg .hausman IV_reg LS_reg
可以得到hausman估计量=2.7,P值=0.44。接受原假设,即educ是外生的。 (3)进行过度识别的约束检验 .estat overid
可得Sargan统计量=0.38,P值=0.54接受原假设。 面板数据估计
首先对面板数据进行声明: 前面是截面单元,后面是时间标识: tsset company year tsset industry year
产生新的变量:gen newvar=human*lnrd 产生滞后变量Gen fiscal(2)=L2.fiscal 产生差分变量Gen fiscal(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 GLS Random-effects estimator pa GEE population-averaged estimator
mle Maximum-likelihood Random-effects estimator
主要估计方法:
xtreg: Fixed-, between- and random-effects, and population-averaged linear models xtregar:Fixed- and random-effects linear models with an AR(1) disturbance xtpcse :OLS or Prais-Winsten models with panel-corrected standard errors xtrchh :Hildreth-Houck random coefficients models
xtivreg :Instrumental variables and two-stage least squares for panel-data models
xtabond:Arellano-Bond linear, dynamic panel data estimator xttobit :Random-effects tobit models
xtlogit : Fixed-effects, random-effects, population-averaged logit models
xtprobit :Random-effects and population-averaged probit models
相关推荐: