楼主: arlionn
94496 925

[stata资源分享] [讨论]STATA 专题讨论   [推广有奖]

101
arlionn 在职认证  发表于 2005-10-29 10:32:00 |只看作者 |坛友微信交流群

[下载]GLS和序列相关的STATA实现——金禾论坛笔记

https://bbs.pinggu.org/thread-24961-1-1.html&page=1

使用道具

102
pudder 发表于 2005-10-31 02:53:00 |只看作者 |坛友微信交流群
请问那应该如何解决这个问题?

使用道具

103
arlionn 在职认证  发表于 2005-10-31 19:03:00 |只看作者 |坛友微信交流群

我不清楚你设定那三个变量的用意,如果只是想控制他们的影响效果,那么采用两个虚拟变量就可以解决了。

使用道具

104
pudder 发表于 2005-11-1 03:15:00 |只看作者 |坛友微信交流群

谢谢arlionn的答复。前面的问题我已经搞清楚了。还有如下几个问题向您以及大家讨教:

在fe中,如何选取估计方法?within estimator 还是 first-difference estimator ?我用一套数据同时使用这两种方法,但是最后得出的两组系数相差比较大。此时,应该如何取舍?

使用道具

105
arlionn 在职认证  发表于 2005-11-1 09:14:00 |只看作者 |坛友微信交流群

within 和 FD 都可以去除个体效应,但是后者会引入序列相关的问题,所以在做 FD处理后要采用 GLS 进行估计,得到的结果与 within 相同。所以你直接采用within即可。

不过,FD也有它的用处,因为我们可以前向差分(forward differencing),这种方法在处理动态面板数据时用的比较多。

使用道具

106
pudder 发表于 2005-11-1 19:17:00 |只看作者 |坛友微信交流群

. xtreg lny lnh lnk lnl, fe i (province)

Fixed-effects (within) regression Number of obs = 532 Group variable (i): province Number of groups = 28

R-sq: within = 0.9492 Obs per group: min = 19 between = 0.9739 avg = 19.0 overall = 0.9655 max = 19

F(3,501) = 3121.38 corr(u_i, Xb) = -0.4768 Prob > F = 0.0000

------------------------------------------------------------------------------ lny | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- lnh | .363275 .0427629 8.50 0.000 .2792583 .4472916 lnk | .6805351 .0119278 57.05 0.000 .6571004 .7039697 lnl | .5857636 .0683678 8.57 0.000 .4514408 .7200865 _cons | -.5523593 .4679209 -1.18 0.238 -1.471688 .3669698 -------------+---------------------------------------------------------------- sigma_u | .16018491 sigma_e | .11455977 rho | .66160712 (fraction of variance due to u_i) ------------------------------------------------------------------------------ F test that all u_i=0: F(27, 501) = 12.84 Prob > F = 0.0000

. sort province year

. for var lny lnh lnk lnl: qui by province: g DX=X[_n]-X[_n-1]

-> qui by province: g Dlny=lny[_n]-lny[_n-1]

-> qui by province: g Dlnh=lnh[_n]-lnh[_n-1]

-> qui by province: g Dlnk=lnk[_n]-lnk[_n-1]

-> qui by province: g Dlnl=lnl[_n]-lnl[_n-1]

. reg Dlny Dlnh Dlnk Dlnl

Source | SS df MS Number of obs = 504 -------------+------------------------------ F( 3, 500) = 96.02 Model | .524001283 3 .174667094 Prob > F = 0.0000 Residual | .909536002 500 .001819072 R-squared = 0.3655 -------------+------------------------------ Adj R-squared = 0.3617 Total | 1.43353729 503 .002849975 Root MSE = .04265

------------------------------------------------------------------------------ Dlny | Coef. Std. Err. t P>|t| [95% Conf. Interval] -------------+---------------------------------------------------------------- Dlnh | .145337 .0344233 4.22 0.000 .0777048 .2129692 Dlnk | .2364523 .0139977 16.89 0.000 .2089508 .2639538 Dlnl | -.1021516 .0620731 -1.65 0.100 -.2241079 .0198047 _cons | .0615844 .0026323 23.40 0.000 .0564127 .0667561 ------------------------------------------------------------------------------

. xtgls Dlny Dlnh Dlnk Dlnl

Cross-sectional time-series FGLS regression

Coefficients: generalized least squares Panels: homoskedastic Correlation: no autocorrelation

Estimated covariances = 1 Number of obs = 504 Estimated autocorrelations = 0 Number of groups = 28 Estimated coefficients = 4 Time periods = 18 Wald chi2(3) = 290.36 Log likelihood = 876.839 Prob > chi2 = 0.0000

------------------------------------------------------------------------------ Dlny | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- Dlnh | .145337 .0342865 4.24 0.000 .0781368 .2125373 Dlnk | .2364523 .013942 16.96 0.000 .2091265 .2637782 Dlnl | -.1021516 .0618263 -1.65 0.098 -.223329 .0190257 _cons | .0615844 .0026218 23.49 0.000 .0564457 .0667231 ------------------------------------------------------------------------------

[此贴子已经被作者于2005-11-1 19:34:14编辑过]

使用道具

107
pudder 发表于 2005-11-1 19:48:00 |只看作者 |坛友微信交流群

Arilionn以及其他同学请看以上结果(蓝色是命令,黑色是结果):

1. 很明显,用within与fd得出的结果相差比较大。尤其是lnl的符号在within中是正的,置信度在1%;但在fd中Dlnl的符号是负的,置信度在10%。

2. 即使对fd采用GLS,得出的结果也没有变化。并没有出现arlionn所说的结果会与within相同。

请问这是什么原因?谢谢!

使用道具

108
arlionn 在职认证  发表于 2005-11-2 00:30:00 |只看作者 |坛友微信交流群

虽然你在差分后使用了xtgls命令,但事实上你并没有过作任何针对异方差的处理,因为你没有设定panel(het)选项。

差分后模型的方差为 Var(e*)=sigma^2QQ',其中Q=(I 直乘 B),B为差分矩阵。

我建议你不要采用xtgls命令,直接用矩阵进行运算,得到的结果一定是相同的。因为,我是在看Arellano(2003)那本书时,从头到尾推到过一遍的,这个结论是不会有错的。

使用道具

109
pudder 发表于 2005-11-2 05:55:00 |只看作者 |坛友微信交流群

感谢arllionn的答复!

继续求教:

1。请问应该如何“直接用矩阵进行运算”?能否简要说明一下?

2。我尝试着用xtgls命令,设定了异方差,但是结果并没有太大差别。您能否大概说下应该怎么做?如下:

. xtgls Dlny Dlnh Dlnk Dlnl, p(h)

Cross-sectional time-series FGLS regression

Coefficients: generalized least squares Panels: heteroskedastic Correlation: no autocorrelation

Estimated covariances = 28 Number of obs = 504 Estimated autocorrelations = 0 Number of groups = 28 Estimated coefficients = 4 Time periods = 18 Wald chi2(3) = 417.28 Log likelihood = 919.7783 Prob > chi2 = 0.0000

------------------------------------------------------------------------------ Dlny | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- Dlnh | .145723 .0296073 4.92 0.000 .0876938 .2037522 Dlnk | .2468983 .0121668 20.29 0.000 .2230518 .2707448 Dlnl | -.0896344 .058913 -1.52 0.128 -.2051017 .025833 _cons | .0618981 .0023371 26.49 0.000 .0573175 .0664787 ------------------------------------------------------------------------------

. xtgls Dlny Dlnh Dlnk Dlnl, i(province) t(year) force igls nmk panels(het) Iteration 1: tolerance = .00410899 Iteration 2: tolerance = .00111581 Iteration 3: tolerance = .00029633 Iteration 4: tolerance = .00007967 Iteration 5: tolerance = .00002169 Iteration 6: tolerance = 5.952e-06 Iteration 7: tolerance = 1.642e-06 Iteration 8: tolerance = 4.541e-07 Iteration 9: tolerance = 1.258e-07 Iteration 10: tolerance = 3.489e-08

Cross-sectional time-series FGLS regression

Coefficients: generalized least squares Panels: heteroskedastic Correlation: no autocorrelation

Estimated covariances = 28 Number of obs = 504 Estimated autocorrelations = 0 Number of groups = 28 Estimated coefficients = 4 Time periods = 18 Wald chi2(3) = 433.16 Log likelihood = 920.1394 Prob > chi2 = 0.0000

------------------------------------------------------------------------------ Dlny | Coef. Std. Err. z P>|z| [95% Conf. Interval] -------------+---------------------------------------------------------------- Dlnh | .147157 .0294457 5.00 0.000 .0894446 .2048695 Dlnk | .2513356 .0121531 20.68 0.000 .2275159 .2751552 Dlnl | -.0835063 .0590802 -1.41 0.158 -.1993013 .0322887 _cons | .061871 .002338 26.46 0.000 .0572886 .0664535 ------------------------------------------------------------------------------

多谢!!!

使用道具

110
arlionn 在职认证  发表于 2005-11-2 21:50:00 |只看作者 |坛友微信交流群

这样吧,你把电子邮件留下,或发封信给我,我这里有证明的过程,可以发给你看看。看完后矩阵的操作也就明白了,这段时间太忙没时间搞这个,不然的话可以动手做一下,就可以避免纸上谈兵的嫌疑了,呵呵。

arlionn@163.com

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注jltj
拉您入交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-5-12 00:19