clear all;
A=xlsread('C:\Users\Administrator\Desktop\matlab建模数据\shuju.xls');
W1=xlsread('C:\Users\Administrator\Desktop\matlab建模数据\权重矩阵.xls');
T=13; 
N=30; 
W=normw(W1);
y=A(:,[3]);
x=A(:,[4:9]);
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=1;
info.fe=0;
results=sar_panel_FE(y,x,W,T,info);
vnames=strvcat('E','pgdp','pd','rd','ip','er','fdi');
prt_spnew(results,vnames,1);
blagfe=[results.beta;results.rho]; 
covblagfe=results.cov; 
clear info.model;
results=sar_panel_RE(y,[xconstant x],W,T,info);
vnames=strvcat('E','intercept','pgdp','pd','rd','ip','er','fdi');
prt(results,vnames,1);
blagre=[results.beta(2:end);results.rho]; 
covblagre=results.cov(2:end,2:end); 
hausman=(blagfe-blagre)'*inv(covblagre-covblagfe)*(blagfe-blagre);
dof=length(blagfe);
probability=1-chis_prb(abs(hausman),dof);
fprintf(1,'hausman test—statistic,degrees of freedom and probability=%9.4f,%6d,%9.4f\n',hausman,dof,probability);