clear
A=xlsread('cigarette.xls');
W1=xlsread('Spat-Sym-US.xls');
T=30; % numberof time periods
N=46; % numberof regions
% row-normalizeW
W=normw(W1); %function of LeSage
y=A(:,[3]); % columnnumber 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);
[nobsK]=size(x);
%----------------------------------------------------------------------------------------
% No fixedeffects + spatially lagged dependent variable
info.lflag=0; %required for exact results
info.model=0;
info.fe=0; % Donot print intercept and fixed effects; use info.fe=1 to turn on
% New routinesto calculate effects estimates
results=sar_panel_FE(y,[xconstantx],W,T,info);
vnames=strvcat('logcit','intercept','logp','logy');
% Print outcoefficient estimates
prt_sp(results,vnames,1);
% Print outeffects estimates
spat_model=0;
direct_indirect_effects_estimates(results,W,spat_model);
panel_effects_sar(results,vnames,W);(一直都是这个代码有问题)
引用了不存在的字段 'hessi'。
出错 panel_effects_sar (line 49)
sigmat = results.hessi - diag(diag(results.hessi)) + diag(diag(abs(results.hessi)));
但是文件夹里有一个名为hessian.m的函数了,我一开始以为函数不一致,我把函数名和变量改成hessi还是有问题!真心不知道问题出在哪里?
另外:panel_effects_sar(results,vnames,W);函数代码出错的地方:
% cheat here to fix the numerical hessian
% Use MCMC to get good results results.xwith
sigmat = results.hessi - diag(diag(results.hessi)) + diag(diag(abs(results.hessi)));
sigmatt = sigmat(1:end-1,1:end-1);
[R,posdef] = chol(sigmatt);


雷达卡





京公网安备 11010802022788号







