function LMsarsem_panel(results,W,y,x)
% PURPOSE: Computes (robust) LM tests for spatial lag and spatial error
% model of a panel data model
% -------------------------------------------------------------------------
% Usage: LM=LMsarsem_panel(results,W)
% where: results = a structure returned by a spatial panel regression
% W = spatial weights matrix (standardized)
% y = dependent variable vector
% x = independent variables matrix
% -------------------------------------------------------------------------
% RETURNS: print of lm tests and probabilities
% -------------------------------------------------------------------------
% Note: probabilitities smaller than 0.05 point to signifance of spatial
% lag or spatial error
% -------------------------------------------------------------------------
% Written by: J.Paul Elhorst summer 2008
% University of Groningen
% Department of Economics
% 9700AV Groningen
% the Netherlands
% [email protected]
%
% REFERENCE:
% Elhorst JP (2009) Spatial Panel Data Models. In Fischer MM, Getis A (Eds.)
% Handbook of Applied Spatial Analysis, Ch. C.2. Springer: Berlin Heidelberg New York.
%
tr=trace((W'+W)*W);
[N junk]=size(W);
[nobs junk]=size(x);
T=nobs/N;
beta=results.beta;
res=results.resid;
sige=res'*res/nobs;
WXB2=0;EWE=0;EWY=0;
for t=1:T
t1=(t-1)*N+1;t2=t*N;
WXB=W*x(t1:t2,:)*beta;
M=eye(N)-x(t1:t2,:)*inv(x(t1:t2,:)'*x(t1:t2,:))*x(t1:t2,:)';
WXB2=WXB2+WXB'*M*WXB;
EWE=EWE+res(t1:t2,1)'*W*res(t1:t2,1);
EWY=EWY+res(t1:t2,1)'*W*y(t1:t2,1);
end
Ttr=T*tr;
J=(WXB2+Ttr*sige)/sige;
LMerror=(EWE/sige)^2/Ttr;
LMlag=(EWY/sige)^2/J;
robustLMerror=((EWE-(Ttr/J)*EWY)/sige)^2/(Ttr*(1-Ttr/J));
robustLMlag=((EWY-EWE)/sige)^2/(J-Ttr);
fprintf(1,'LM test no spatial lag, probability = %9.4f,%9.3f \n',LMlag,1-chis_prb(LMlag,1));
fprintf(1,'robust LM test no spatial lag, probability = %9.4f,%9.3f \n',robustLMlag,1-chis_prb(robustLMlag,1));
fprintf(1,'LM test no spatial error, probability = %9.4f,%9.3f \n',LMerror,1-chis_prb(LMerror,1));
fprintf(1,'robust LM test no spatial error, probability = %9.4f,%9.3f \n',robustLMerror,1-chis_prb(robustLMerror,1));
LMsarsem_panel.rar_lmsarsem_panel_最大似然法_空间面板
版权申诉
199 浏览量
2022-09-20
20:18:49
上传
评论
收藏 1022B RAR 举报
小贝德罗
- 粉丝: 70
- 资源: 1万+
最新资源
- 基于opencv+yolov8实现目标追踪及驻留时长统计源码.zip
- 水稻病害基于Yolov8算法优化目标检测识别与AI辅助决策python源码+模型+使用说明.zip
- 海尔618算价表_七海5.20_16.00xlsx(1)(2).xlsx
- WebCrawler.scr
- 【计算机专业毕业设计】大学生就业信息管理系统设计源码.zip
- YOLO 数据集:8种路面缺陷病害检测【包含划分好的数据集、类别class文件、数据可视化脚本】
- JAVA实现Modbus RTU或Modbus TCPIP案例.zip
- 基于YOLOv8的FPS TPS AI自动锁定源码+使用步骤说明.zip
- JAVA实现Modbus RTU或Modbus TCPIP案例.zip
- 基于yolov8+streamlit的火灾检测部署源码+模型.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈