clear all
load shujuN.txt
W=xlsread('dis.xls')
T=11;
N=31;
y=shujuN(:,3); % column number in the data matrix that corresponds to the dependent variable
x=shujuN(:,[4:9]); % 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);
info.lflag=0;
info.model=0;
info.fe=0; 
results=sar_panel_FE(y,[x wx],W,T,info); 
vnames=strvcat('logRJA','logurba','logOPE','logflxe','logthir','logGOV','logdes','W*logurba','W*logope','W*logflxe','W*logthir','W*logGOV','W*logdes');
% 输出各系数估计结果
prt_sp(results,vnames,1);
% Print out effects estimates
spat_model=1;
direct_indirect_effects_estimates(results,W,spat_model);
panel_effects_sdm(results,vnames,W);
运行结果如下:
Pooled model with spatially lagged dependent variable, no fixed effects 
Dependent Variable =        logRJA    
R-squared          = -855.0220   
corr-squared       =    0.2441   
sigma^2            =  357.6381 
Nobs,Nvar,#FE      =    341,    13,    12  
log-likelihood     =       -677.17559 
# of iterations    =      1   
min and max rho    =   -1.0000,   1.0000 
total time in secs =    0.2020 
time for optimiz   =    0.0770 
time for lndet     =    0.0490 
time for t-stats   =    0.0120 
No lndet approximation used 
***************************************************************
Variable        Coefficient  Asymptot t-stat    z-probability 
logurba          -16.372524        -2.255067         0.024129 
logOPE             5.076206         2.114543         0.034469 
logflxe           33.634253         3.321232         0.000896 
logthir           15.169495         1.700436         0.089049 
logGOV           -24.754716        -3.023258         0.002501 
logdes            -1.612903        -0.956194         0.338974 
W*logurba         -0.021281        -3.553094         0.000381 
W*logope           0.001536         2.789553         0.005278 
W*logflxe          0.016997         3.528191         0.000418 
W*logthir         -0.014292        -3.440759         0.000580 
W*logGOV          -0.002942        -3.023322         0.002500 
W*logdes          -0.001680        -3.161128         0.001572 
W*dep.var.         0.013023         3.564002         0.000365 
    direct    t-stat   indirect    t-stat   total    t-stat 
ans =
   -1.6207   -1.3827    3.2733    2.7290    1.6526   24.4776
    0.8105    1.9502   -0.9350   -2.1798   -0.1244   -3.4283
    4.9635    4.6287   -6.3067   -5.8307   -1.3431  -22.8693
    3.6527    2.2807   -2.5685   -1.5947    1.0842   11.7515
   -4.2900   -3.9984    4.5413    4.1696    0.2513    5.1325
   -0.1776   -0.5427    0.3085    0.9403    0.1308    5.5777
Error using betainc
X must be in the interval [0,1].
Error in tdis_prb (line 35)
tmp = 1.0 - 0.5*betainc(x2,0.5*n,0.5);
Error in panel_effects_sdm (line 143)
    indirect_out(i,:) = [cmean cmean./smean tdis_prb(cmean./smean,nobs) lbounds ubounds];