% dimensions of the problem
A=xlsread('C:\Users\toshiba\Desktop\空间操作\chap3\cigarette.xls');
W1=xlsread('C:\Users\toshiba\Desktop\空间操作\chap3\spat-Sym-US.xls');
T=29; % 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+1
t1=(t-1)*N+1;t2=t*N;
wx(t1:t2,:)=W*x(t1:t2,:);
Wy(t1:t2,1)=W*y(t1:t2,1);
end
[nobs K]=size(x);
xconstant=ones(nobs,1);
info.lflag=0;
info.tl=1;
info.stl=1;
info.ted=1;
info.dyn=1;
info.model=3;
info.fe=0;
info.bc=0;
results=sar_panel_FE(y(N+1:end),[y(1:end-N) Wy(1:end-N) x(N+1:end,:) wx(N+1:end,:)],W,T,info);
vnames=strvcat('logcit','timelag logcit','spacetimelag logcit','logp','logy','W*logp','W*logy');
results1=sar_jihai_time(y(1:nobs),[x(N+1:nobs,:) wx(N+1:nobs,:)],W,info);