楼主: tulipsliu
31063 92

[问答] 基于MATLAB的spatial panel model 程序阅读与学习。   [推广有奖]

经济学论述自由撰稿人!

已卖:2752份资源

学科带头人

45%

还不是VIP/贵宾

-

威望
0
论坛币
386045 个
通用积分
527.0498
学术水平
127 点
热心指数
140 点
信用等级
103 点
经验
46986 点
帖子
1773
精华
0
在线时间
2509 小时
注册时间
2007-11-5
最后登录
2024-8-16

初级热心勋章

楼主
tulipsliu 在职认证  发表于 2012-10-24 23:17:27 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
发此文的目的是通过研读程序,更深入的了解Elhost在写这个程序时的思想,通过认真研读程序,深入掌握空间面板程序建模的问题。
  1. % Demonstration file for Elhorst Panel Data code
  2. %
  3. % Dataset downloaded from www.wiley.co.uk/baltagi/
  4. % Spatial weights matrix constructed by Elhorst
  5. %
  6. % written by: J.Paul Elhorst summer 2010
  7. % University of Groningen
  8. % Department of Economics
  9. % 9700AV Groningen
  10. % the Netherlands
  11. % j.p.elhorst@rug.nl
  12. %
  13. % REFERENCE:
  14. % Elhorst JP (2010) Matlab Software for Spatial Panels. Under review.
  15. %
  16. % Elhorst JP (2010) Spatial Panel Data Models. In Fischer MM, Getis A (Eds.)
  17. % Handbook of Applied Spatial Analysis, Ch. C.2. Springer: Berlin Heidelberg New York.
  18. %
  19. % New:

  20. % 1) Direct/Indirect effect esimates of the explanatory variables
  21. % LeSage JP, Pace RK (2009) Introduction to Spatial Econometrics. Boca Raton, Taylor & Francis Group.
  22. % routine direct_indirect_effects_estimates(results,W,spat_model) is written by J.P. Elhorst
  23. % routines panel_effects_sar(results,vnames,W) and panel_effects_sar(results,vnames,W)
  24. % are written and made available by D. Lacombe
  25. % User may use both routines (note: results are slightly different from each other since they are based on draws from a distrobution
  26. % or choose one particular routine. If N is large, user should choose
  27. % Lacombe's routines, since this one is much more efficient computationally

  28. % 2) Bias correction of coefficient estimates
  29. % Lee Lf, Yu J. (2010) Estimation of spatial autoregressive models with
  30. % fixed effects, Journal of Econometrics 154: 165-185.

  31. % 3) Selection framework to determine which spatial panel data model best
  32. % describes the data.

  33. % dimensions of the problem
  34. load cigarette_mat;
  35. load US_W;
  36. T=30; % number of time periods
  37. N=46; % number of regions
  38. % row-normalize W
  39. W=normw(W1); % function of LeSage
  40. y=A(:,[3]); % column number in the data matrix that corresponds to the dependent variable
  41. x=A(:,[4,6]); % column numbers in the data matrix that correspond to the independent variables
  42. for t=1:T
  43.     t1=(t-1)*N+1;t2=t*N;
  44.     wx(t1:t2,:)=W*x(t1:t2,:);
  45. end
  46. xconstant=ones(N*T,1);
  47. [nobs K]=size(x);
  48. % ----------------------------------------------------------------------------------------
  49. % No fixed effects + spatially lagged dependent variable
  50. info.lflag=0; % required for exact results
  51. info.model=0;
  52. info.fe=0; % Do not print intercept and fixed effects; use info.fe=1 to turn on
  53. % New routines to calculate effects estimates
  54. results=sar_panel_FE(y,[xconstant x],W,T,info);
  55. vnames=char('logcit','intercept','logp','logy');
  56. % Print out coefficient estimates
  57. prt_sp(results,vnames,1);
  58. % Print out effects estimates
  59. spat_model=0;
  60. direct_indirect_effects_estimates(results,W,spat_model);
  61. panel_effects_sar(results,vnames,W);
  62. % ----------------------------------------------------------------------------------------
  63. % No fixed effects + spatially lagged dependent variable + spatially
  64. % independent variables
  65. info.lflag=0; % required for exact results
  66. info.model=0;
  67. info.fe=0; % Do not print intercept and fixed effects; use info.fe=1 to turn on
  68. % New routines to calculate effects estimates
  69. results=sar_panel_FE(y,[xconstant x wx],W,T,info);
  70. vnames=char('logcit','intercept','logp','logy','W*logp','W*logy');
  71. % Print out coefficient estimates
  72. prt_sp(results,vnames,1);
  73. % Print out effects estimates
  74. spat_model=1;
  75. direct_indirect_effects_estimates(results,W,spat_model);
  76. panel_effects_sdm(results,vnames,W);
  77. % ----------------------------------------------------------------------------------------
  78. % Spatial fixed effects + spatially lagged dependent variable
  79. info.lflag=0; % required for exact results
  80. info.model=1;
  81. info.fe=0; % Do not print intercept and fixed effects; use info.fe=1 to turn on
  82. % New routines to calculate effects estimates
  83. results=sar_panel_FE(y,x,W,T,info);
  84. vnames=char('logcit','logp','logy');
  85. % Print out coefficient estimates
  86. prt_sp(results,vnames,1);
  87. % Print out effects estimates
  88. spat_model=0;
  89. direct_indirect_effects_estimates(results,W,spat_model);
  90. panel_effects_sar(results,vnames,W);
  91. % ----------------------------------------------------------------------------------------
  92. % Spatial fixed effects + spatially lagged dependent variable + spatially
  93. % independent variables
  94. info.lflag=0; % required for exact results
  95. info.model=1;
  96. info.fe=0; % Do not print intercept and fixed effects; use info.fe=1 to turn on
  97. % New routines to calculate effects estimates
  98. results=sar_panel_FE(y,[x wx],W,T,info);
  99. vnames=char('logcit','logp','logy','W*logp','W*logy');
  100. % Print out coefficient estimates
  101. prt_sp(results,vnames,1);
  102. % Print out effects estimates
  103. spat_model=1;
  104. direct_indirect_effects_estimates(results,W,spat_model);
  105. panel_effects_sdm(results,vnames,W);
  106. % ----------------------------------------------------------------------------------------
  107. % Time period fixed effects + spatially lagged dependent variable
  108. info.lflag=0; % required for exact results
  109. info.model=2;
  110. info.fe=0; % Do not print intercept and fixed effects; use info.fe=1 to turn on
  111. % New routines to calculate effects estimates
  112. results=sar_panel_FE(y,x,W,T,info);
  113. vnames=char('logcit','logp','logy');
  114. % Print out coefficient estimates
  115. prt_sp(results,vnames,1);
  116. % Print out effects estimates
  117. spat_model=0;
  118. direct_indirect_effects_estimates(results,W,spat_model);
  119. panel_effects_sar(results,vnames,W);
  120. % ----------------------------------------------------------------------------------------
  121. % Time period fixed effects + spatially lagged dependent variable + spatially
  122. % independent variables
  123. info.lflag=0; % required for exact results
  124. info.model=2;
  125. info.fe=0; % Do not print intercept and fixed effects; use info.fe=1 to turn on
  126. % New routines to calculate effects estimates
  127. results=sar_panel_FE(y,[x wx],W,T,info);
  128. vnames=char('logcit','logp','logy','W*logp','W*logy');
  129. % Print out coefficient estimates
  130. prt_sp(results,vnames,1);
  131. % Print out effects estimates
  132. spat_model=1;
  133. direct_indirect_effects_estimates(results,W,spat_model);
  134. panel_effects_sdm(results,vnames,W);
  135. % ----------------------------------------------------------------------------------------
  136. % Spatial and time period fixed effects + spatially lagged dependent variable
  137. info.lflag=0; % required for exact results
  138. info.model=3;
  139. info.fe=0; % Do not print intercept and fixed effects; use info.fe=1 to turn on
  140. % New routines to calculate effects estimates
  141. results=sar_panel_FE(y,x,W,T,info);
  142. vnames=char('logcit','logp','logy');
  143. % Print out coefficient estimates
  144. prt_sp(results,vnames,1);
  145. % Print out effects estimates
  146. spat_model=0;
  147. direct_indirect_effects_estimates(results,W,spat_model);
  148. panel_effects_sar(results,vnames,W);
复制代码

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:Spatial MATLAB atlab Panel matla 程序 学习

已有 1 人评分学术水平 热心指数 信用等级 收起 理由
日新少年 + 2 + 2 + 2 精彩帖子

总评分: 学术水平 + 2  热心指数 + 2  信用等级 + 2   查看全部评分

本帖被以下文库推荐

劳动经济学

沙发
tulipsliu 在职认证  发表于 2012-10-24 23:18:16
  1. % ----------------------------------------------------------------------------------------
  2. % Spatial and time period fixed effects + spatially lagged dependent variable + spatially
  3. % independent variables
  4. % No bias correction
  5. info.bc=0;
  6. info.lflag=0; % required for exact results
  7. info.model=3;
  8. info.fe=0; % Do not print intercept and fixed effects; use info.fe=1 to turn on
  9. % New routines to calculate effects estimates
  10. results=sar_panel_FE(y,[x wx],W,T,info);
  11. vnames=char('logcit','logp','logy','W*logp','W*logy');
  12. % Print out coefficient estimates
  13. prt_sp(results,vnames,1);
  14. % Print out effects estimates
  15. spat_model=1;
  16. direct_indirect_effects_estimates(results,W,spat_model);
  17. panel_effects_sdm(results,vnames,W);
  18. % Wald test for spatial Durbin model against spatial lag model
  19. btemp=results.parm;
  20. varcov=results.cov;
  21. Rafg=zeros(K,2*K+2);
  22. for k=1:K
  23. Rafg(k,K+k)=1; % R(1,3)=0 and R(2,4)=0;
  24. end
  25. Wald_spatial_lag=(Rafg*btemp)'*inv(Rafg*varcov*Rafg')*Rafg*btemp
  26. prob_spatial_lag=1-chis_cdf (Wald_spatial_lag, K) % probability greater than 0.05 points to insignificance
  27. % LR test spatial Durbin model against spatial lag model (requires
  28. % estimation results of the spatial lag model to be available)
  29. resultssar=sar_panel_FE(y,x,W,T,info);
  30. LR_spatial_lag=-2*(resultssar.lik-results.lik)
  31. prob_spatial_lag=1-chis_cdf (LR_spatial_lag,K) % probability greater than 0.05 points to insignificance
  32. % Wald test spatial Durbin model against spatial error model
  33. R=zeros(K,1);
  34. for k=1:K
  35. R(k)=btemp(2*K+1)*btemp(k)+btemp(K+k); % k changed in 1, 7/12/2010
  36. % R(1)=btemp(5)*btemp(1)+btemp(3);
  37. % R(2)=btemp(5)*btemp(2)+btemp(4);
  38. end
  39. Rafg=zeros(K,2*K+2);
  40. for k=1:K
  41. Rafg(k,k) =btemp(2*K+1); % k changed in 1, 7/12/2010
  42. Rafg(k,K+k) =1;
  43. Rafg(k,2*K+1)=btemp(k);
  44. % Rafg(1,1)=btemp(5);Rafg(1,3)=1;Rafg(1,5)=btemp(1);
  45. % Rafg(2,2)=btemp(5);Rafg(2,4)=1;Rafg(2,5)=btemp(2);
  46. end
  47. Wald_spatial_error=R'*inv(Rafg*varcov*Rafg')*R
  48. prob_spatial_error=1-chis_cdf (Wald_spatial_error,K) % probability greater than 0.05 points to insignificance
  49. % LR test spatial Durbin model against spatial error model (requires
  50. % estimation results of the spatial error model to be available
  51. resultssem=sem_panel_FE(y,x,W,T,info);
  52. LR_spatial_error=-2*(resultssem.lik-results.lik)
  53. prob_spatial_error=1-chis_cdf (LR_spatial_error,K) % probability greater than 0.05 points to insignificance
  54. % ----------------------------------------------------------------------------------------
  55. % Spatial and time period fixed effects + spatially lagged dependent variable + spatially
  56. % independent variables
  57. info.lflag=0; % required for exact results
  58. info.model=3;
  59. info.fe=0; % Do not print intercept and fixed effects; use info.fe=1 to turn on
  60. info.bc=1;
  61. % New routines to calculate effects estimates
  62. results=sar_panel_FE(y,[x wx],W,T,info);
  63. vnames=char('logcit','logp','logy','W*logp','W*logy');
  64. % Print out coefficient estimates
  65. prt_sp(results,vnames,1);
  66. % Print out effects estimates
  67. spat_model=1;
  68. direct_indirect_effects_estimates(results,W,spat_model);
  69. panel_effects_sdm(results,vnames,W);
  70. % Wald test for spatial lag model
  71. btemp=results.parm;
  72. varcov=results.cov;
  73. Rafg=zeros(K,2*K+2);
  74. for k=1:K
  75. Rafg(k,K+k)=1; % R(1,3)=0 and R(2,4)=0;
  76. end
  77. Wald_spatial_lag=(Rafg*btemp)'*inv(Rafg*varcov*Rafg')*Rafg*btemp
  78. prob_spatial_lag= 1-chis_cdf (Wald_spatial_lag, K) % probability greater than 0.05 points to insignificance
  79. % LR test spatial Durbin model against spatial lag model (requires
  80. % estimation results of the spatial lag model to be available)
  81. resultssar=sar_panel_FE(y,x,W,T,info);
  82. LR_spatial_lag=-2*(resultssar.lik-results.lik)
  83. prob_spatial_lag=1-chis_cdf (LR_spatial_lag,K) % probability greater than 0.05 points to insignificance
  84. % Wald test for spatial error model
  85. R=zeros(K,1);
  86. for k=1:K
  87. R(k)=btemp(2*K+1)*btemp(k)+btemp(K+k); % k changed in 1, 7/12/2010
  88. % R(1)=btemp(5)*btemp(1)+btemp(3);
  89. % R(2)=btemp(5)*btemp(2)+btemp(4);
  90. end
  91. Rafg=zeros(K,2*K+2);
  92. for k=1:K
  93. Rafg(k,k) =btemp(2*K+1); % k changed in 1, 7/12/2010
  94. Rafg(k,K+k) =1;
  95. Rafg(k,2*K+1)=btemp(k);
  96. % Rafg(1,1)=btemp(5);Rafg(1,3)=1;Rafg(1,5)=btemp(1);
  97. % Rafg(2,2)=btemp(5);Rafg(2,4)=1;Rafg(2,5)=btemp(2);
  98. end
  99. Wald_spatial_error=R'*inv(Rafg*varcov*Rafg')*R
  100. prob_spatial_error= 1-chis_cdf (Wald_spatial_error,K) % probability greater than 0.05 points to insignificance
  101. % LR test spatial Durbin model against spatial error model (requires
  102. % estimation results of the spatial error model to be available
  103. resultssem=sem_panel_FE(y,x,W,T,info);
  104. LR_spatial_error=-2*(resultssem.lik-results.lik)
  105. prob_spatial_error=1-chis_cdf (LR_spatial_error,K) % probability greater than 0.05 points to insignificance
  106. % needed for Hausman test later on
  107. logliklag=results.lik;
  108. blagfe=results.parm(1:end-1);
  109. covblagfe=results.cov(1:end-1,1:end-1);
  110. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% random effects estimator by ML %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  111. %
  112. % Spatial random effects and time period fixed effects + spatially lagged dependent variable + spatially
  113. % independent variables
  114. [ywith,xwith,meanny,meannx,meanty,meantx]=demean(y,[x wx],N,T,2); % 2=time dummies
  115. info.model=1;
  116. results=sar_panel_RE(ywith,xwith,W,T,info);
  117. prt_sp(results,vnames,1);
  118. % Print out effects estimates
  119. spat_model=1;
  120. direct_indirect_effects_estimates(results,W,spat_model);
  121. panel_effects_sdm(results,vnames,W);
  122. % Wald test for spatial lag model
  123. btemp=results.parm(1:2*K+2);
  124. varcov=results.cov(1:2*K+2,1:2*K+2);
  125. Rafg=zeros(K,2*K+2);
  126. for k=1:K
  127. Rafg(k,K+k)=1; % R(1,3)=0 and R(2,4)=0;
  128. end
  129. Wald_spatial_lag=(Rafg*btemp)'*inv(Rafg*varcov*Rafg')*Rafg*btemp
  130. prob_spatial_lag= 1-chis_cdf (Wald_spatial_lag, K) % probability greater than 0.05 points to insignificance
  131. % Wald test for spatial error model
  132. R=zeros(K,1);
  133. for k=1:K
  134. R(k)=btemp(2*K+1)*btemp(k)+btemp(K+k); % k changed in 1, 7/12/2010
  135. % R(1)=btemp(5)*btemp(1)+btemp(3);
  136. % R(2)=btemp(5)*btemp(2)+btemp(4);
  137. end
  138. Rafg=zeros(K,2*K+2);
  139. for k=1:K
  140. Rafg(k,k) =btemp(2*K+1); % k changed in 1, 7/12/2010
  141. Rafg(k,K+k) =1;
  142. Rafg(k,2*K+1)=btemp(k);
  143. % Rafg(1,1)=btemp(5);Rafg(1,3)=1;Rafg(1,5)=btemp(1);
  144. % Rafg(2,2)=btemp(5);Rafg(2,4)=1;Rafg(2,5)=btemp(2);
  145. end
  146. Wald_spatial_error=R'*inv(Rafg*varcov*Rafg')*R
  147. prob_spatial_error= 1-chis_cdf (Wald_spatial_error,K) % probability greater than 0.05 points to insignificance
  148. % needed for Hausman test later on
  149. logliklagre=results.lik;
  150. blagre=results.parm(1:end-2);
  151. covblagre=results.cov(1:end-2,1:end-2);
  152. % ----------------------------------------------------------------------------------------
  153. % Hausman test FE versus RE
  154. hausman=(blagfe-blagre)'*inv(covblagre-covblagfe)*(blagfe-blagre);
  155. dof=length(blagfe);
  156. probability=1-chis_prb(abs(hausman),dof);
  157. % Note: probability < 0.025 implies rejection of random effects model in favor of fixed effects model
  158. % Use 0.025, since it is a one-sided test
  159. fprintf(1,'Hausman test-statistic, degrees of freedom and probability = %9.4f,%6d,%9.4f \n',abs(hausman),dof,probability);
复制代码
劳动经济学

藤椅
tulipsliu 在职认证  发表于 2012-10-24 23:28:55
MATLAB R2012b 已经不支持读取 wk1的文件。还好当初已经将数据保存为matlab的数据格式 .mat。
数据的读入是如下两句:
load cigarette_mat;
load US_W;
劳动经济学

板凳
tulipsliu 在职认证  发表于 2012-10-24 23:29:50
T=30; % number of time periods
N=46; % number of regions
% row-normalize W
W=normw(W1); % function of LeSage
y=A(:,[3]); % column number in the data matrix that corresponds to the dependent variable
x=A(:,[4,6]); % column numbers in the data matrix that correspond to the independent variables
for t=1:T
    t1=(t-1)*N+1;t2=t*N;
    wx(t1:t2,:)=W*x(t1:t2,:);
end
xconstant=ones(N*T,1);
[nobs K]=size(x);

这部分是空间面板数据的初始处理;为面板模型数据格式做好准备。
劳动经济学

报纸
tulipsliu 在职认证  发表于 2012-10-24 23:37:46
第53~65行的代码;是定义了一个具体的空间面板模型,并通过小效应数估计出(直接效应与间接效应),我这里所说的效应也许翻译得不对,记得一些论文上说的是“空间溢出效应”。具体看相关论文与手册。
---------------------
% No fixed effects + spatially lagged dependent variable
info.lflag=0; % required for exact results
info.model=0;
info.fe=0; % Do not print intercept and fixed effects; use info.fe=1 to turn on
% New routines to calculate effects estimates
results=sar_panel_FE(y,[xconstant x],W,T,info);
vnames=char('logcit','intercept','logp','logy');
% Print out coefficient estimates
prt_sp(results,vnames,1);
% Print out effects estimates
spat_model=0;
direct_indirect_effects_estimates(results,W,spat_model);
panel_effects_sar(results,vnames,W);

info是一个数据结构,其中的 info.fe,是info结构里,对 fe 赋值,0与1,在计算机程序里,如在C++里,应该是 boolean 类型,或者其他的如 FOXPRO里,会负值为 0对于 false,1对于 true的逻辑函数。
这里,info.fe=0,就是逻辑否,关闭特定的功能。

results=sar_panel_FE(y,[xconstant x],W,T,info);
具体的估计函数是 sar_panel_FE,是一个 “空间自回归的面板模型”函数。y为因变量,[xconstant x],xconstant 应当是我们所说的常数项 C ( Constant),x 是各列因变量数据。W 是空间权重矩阵,T是时间时期数,info是一个数据结构,刚才对于模型的各种设定在 info 里给予具体的“设定”, specify

direct_indirect_effects_estimates(results,W,spat_model);
这句解释了空间的直接效应与空间的间接效应。其实从大师们的论文里可以看到,还有所谓的“空间溢出效应”。
劳动经济学

地板
gdfoshanluofeng 发表于 2012-10-24 23:38:33
lz能否做个文件,一句一句解释下啊。然后告诉大家如何在matlab上实现程序。我保证该帖必火啊。现在很多人不知道怎么做空间面板。能否将该程序文件发一份给我?非常感谢!598636005@qq.com
努力学习

7
tulipsliu 在职认证  发表于 2012-10-25 12:01:27
gdfoshanluofeng 发表于 2012-10-24 23:38
lz能否做个文件,一句一句解释下啊。然后告诉大家如何在matlab上实现程序。我保证该帖必火啊。现在很多人不 ...
我是业余爱好,工作不稳定,也没心思做这个。其实因为这个爱好,已经严重影响其他方面的正常生活。
暂时不会有一句一句解释这个程序的可能。

只是偶尔心血来潮,随便发两句短文。

至于整个程序,我已经共享在论坛里了,我发帖了的;
是 Elhost 的空间面板,你搜索下我的帖子;

该怎么用,自己探索和与人交流了。
我得做其他事。这个对我来说是一个游戏,有空的时候才玩玩,该忙其他重要的事的时候,会放弃这个的。
劳动经济学

8
gdfoshanluofeng 发表于 2012-10-25 13:04:54
哦。原来如此!真是可惜了!
努力学习

9
tulipsliu 在职认证  发表于 2012-11-10 22:50:17
  • % Wald test for spatial lag model
  • btemp=results.parm;
  • varcov=results.cov;
  • Rafg=zeros(K,2*K+2);
  • for k=1:K
  • Rafg(k,K+k)=1; % R(1,3)=0 and R(2,4)=0;
  • end
  • Wald_spatial_lag=(Rafg*btemp)'*inv(Rafg*varcov*Rafg')*Rafg*btemp
  • prob_spatial_lag= 1-chis_cdf (Wald_spatial_lag, K) % probability greater than 0.05 points to insignificance
这里是精彩的Wald 检验,通过矩阵运算算出检验统计量。




  • % LR test spatial Durbin model against spatial lag model (requires
  • % estimation results of the spatial lag model to be available)
  • resultssar=sar_panel_FE(y,x,W,T,info);
  • LR_spatial_lag=-2*(resultssar.lik-results.lik)
  • prob_spatial_lag=1-chis_cdf (LR_spatial_lag,K) % probability greater than 0.05 points to insignificance
  • % Wald test for spatial error model
  • R=zeros(K,1);
  • for k=1:K
  • R(k)=btemp(2*K+1)*btemp(k)+btemp(K+k); % k changed in 1, 7/12/2010
  • % R(1)=btemp(5)*btemp(1)+btemp(3);
  • % R(2)=btemp(5)*btemp(2)+btemp(4);
  • end
  • Rafg=zeros(K,2*K+2);
  • for k=1:K
  • Rafg(k,k) =btemp(2*K+1); % k changed in 1, 7/12/2010
  • Rafg(k,K+k) =1;
  • Rafg(k,2*K+1)=btemp(k);
  • % Rafg(1,1)=btemp(5);Rafg(1,3)=1;Rafg(1,5)=btemp(1);
  • % Rafg(2,2)=btemp(5);Rafg(2,4)=1;Rafg(2,5)=btemp(2);
  • end
  • Wald_spatial_error=R'*inv(Rafg*varcov*Rafg')*R
  • prob_spatial_error= 1-chis_cdf (Wald_spatial_error,K) % probability greater than 0.05 points to insignificance








  • % LR test spatial Durbin model against spatial error model (requires
  • % estimation results of the spatial error model to be available
  • resultssem=sem_panel_FE(y,x,W,T,info);
  • LR_spatial_error=-2*(resultssem.lik-results.lik)
  • prob_spatial_error=1-chis_cdf (LR_spatial_error,K) % probability greater than 0.05 points to insignificance
精彩的LR统计检验量计算,chis_cdf是来自lesage计量经济学工具箱里的函数。   且该模型是对 Spatial Durbin model 与 error model 的对比检验。值得期待。


  • % needed for Hausman test later on
  • logliklag=results.lik;
  • blagfe=results.parm(1:end-1);
  • covblagfe=results.cov(1:end-1,1:end-1);

劳动经济学

10
rokre2tt 发表于 2012-12-12 13:16:48
tulipsliu 发表于 2012-10-25 12:01
我是业余爱好,工作不稳定,也没心思做这个。其实因为这个爱好,已经严重影响其他方面的正常生活。
暂时 ...
lz你好,为什么我用你发的那个Elhorst的程序包运行里面的demo程序时会报错呢?比如有这些Error: File: demoLMsarsem_panel.m Line: 60 Column: 29
Expression or statement is incorrect--possibly unbalanced (, {, or [.

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

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-27 12:58