[loveliness],另外有需要代码和jplv7的可以联系我,我可以发给你们。数据demo:
代码demo:
A=wk1read('I:\Graduated\data\分析报告\数据输出\数据更新\Tan_HH_MB.xls',1,0);
W1=wk1read('I:\Graduated\data\分析报告\数据输出\数据更新\Tan_HH_W.xls');
T=19; % number of time periods
N=63; % number of regions
% row-normalize W
W=normw(W1); % function of LeSage
y=A(:,[32]); % column number in the data matrix that corresponds to the dependent variable
x=A(:,[34:42]); % column numbers in the data matrix that correspond to the independent variables
xconstant=ones(N*T,1);
[nobs K]=size(x);
% ----------------------------------------------------------------------------------------
% ols estimation
results=ols(y,[xconstant x]);
vnames=strvcat('lnPM','lgpop','lgbpa','lglgdp','lglgdpq2','lgsec','lgrd','lgeff','lgene','lgcar','lgfdi','lgpm');
prt_reg(results,vnames,1);
sige=results.sige*((nobs-K)/nobs);
loglikols=-nobs/2*log(2*pi*sige)-1/(2*sige)*results.resid'*results.resid
LMsarsem_panel(results,W,y,[xconstant x]); % (Robust) LM tests %LMsarsem_panel为下边函数
function LMsarsem_panel(results,W,y,x)
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));
结果:
希望诸君能帮我解答一下,在线等。


雷达卡



京公网安备 11010802022788号







