运行elhorst代码时出现结果:Pooled model with spatially lagged dependent variable and spatial fixed effects
Dependent Variable = logcit
R-squared = 0.8330
corr-squared = 0.8588
sigma^2 = 0.0799
Nobs,Nvar,#FE = 42, 8, 10
log-likelihood = NaN
# of iterations = 1
min and max rho = -1.0000, 1.0000
total time in secs = 6.8350
time for optimiz = 1.1700
time for lndet = 2.6050
time for t-stats = 0.1870
No lndet approximation used
***************************************************************
Variable Coefficient Asymptot t-stat z-probability
logm -1.574680 -4.062095 0.000049
logp -1.257264 -1.288147 0.197695
logr 2.881825 2.314324 0.020650
logr2 0.030691 0.031202 0.975108
logs -1.033890 -2.542877 0.010994
logk -4.320598 -2.633721 0.008445
logw -0.056595 -0.377752 0.705615
W*dep.var. -0.236068 -2.872343 0.004074
LR-test joint significance spatial fixed effects, degrees of freedom and probability = NaN, 3, NaN
Wrong # of variable names in prt_sp -- check vnames argument
will use generic variable names
Pooled model with spatially lagged dependent variable and spatial random effects
R-squared = 0.8323
corr-squared = 0.8589
sigma^2 = 0.0802
Nobs,Nvar = 42, 9
log-likelihood = NaN
# of iterations = 2
min and max rho = -1.0000, 1.0000
total time in secs = 0.5460
time for optimiz = 0.5150
time for lndet = 0.0150
No lndet approximation used
***************************************************************
Variable Coefficient Asymptot t-stat z-probability
variable 1 30.836063 1.557228 0.119416
variable 2 -1.561838 -4.028274 0.000056
variable 3 -1.267030 -1.297605 0.194423
variable 4 2.827473 2.294879 0.021740
variable 5 0.072121 0.073514 0.941397
variable 6 -1.022704 -2.531868 0.011346
variable 7 -4.278777 -2.625291 0.008657
variable 8 -0.056930 -0.379387 0.704401
W*dep.var. -0.236068 -2.897152 0.003766
teta 0.996894 2.356657 0.018440
LR-test significance spatial random effects, degrees of freedom and probability = NaN, 1, NaN
Hausman test-statistic, degrees of freedom and probability = 0.2320, 8, 1.0000
Pooled model with spatial error autocorrelation and spatial fixed effects
Dependent Variable = logcit
R-squared = 0.7702
corr-squared = 0.7745
sigma^2 = 0.0161
log-likelihood = 15.613561
Nobs,Nvar,#FE = 42, 7, 10
# iterations = 16
min and max rho = -0.9900, 0.9900
total time in secs = 0.3590
time for optimiz = 0.2810
time for t-stats = 0.0310
No lndet approximation used
***************************************************************
Variable Coefficient Asymptot t-stat z-probability
logm -0.426951 -1.508374 0.131459
logp -0.460146 -0.913078 0.361201
logr 0.372846 0.805292 0.420651
logr2 0.635262 1.544534 0.122459
logs -0.007702 -0.039654 0.968369
logk -0.451945 -0.482995 0.629099
logw 0.102662 1.500221 0.133557
spat.aut. 0.748983 14.623228 0.000000
LR-test joint significance spatial fixed effects, degrees of freedom and probability = NaN, 3, NaN
Wrong # of variable names in prt_sp -- check vnames argument
will use generic variable names
Pooled model with spatial error autocorrelation and spatial random effects
R-squared = 0.9666
corr-squared = 0.7737
sigma^2 = 0.0160
Nobs,Nvar = 42, 8
log-likelihood = 15.383889
# of iterations = 8
min and max rho = -1.0000, 1.0000
total time in secs = 0.8420
time for optimiz = 0.7490
time for eigs = 0.0620
time for t-stats = 0.0150
***************************************************************
Variable Coefficient Asymptot t-stat z-probability
variable 1 -7.209513 -0.723618 0.469300
variable 2 -0.432158 -1.535145 0.124748
variable 3 -0.455101 -0.906348 0.364751
variable 4 0.378647 0.826546 0.408494
variable 5 0.625425 1.530895 0.125795
variable 6 -0.013158 -0.068090 0.945714
variable 7 -0.411996 -0.441376 0.658941
variable 8 0.105018 1.544999 0.122347
spat.aut. 0.755900 20.374834 0.000000
teta 0.000000 0.000005 0.999996
LR-test significance spatial random effects, degrees of freedom and probability = NaN, 1, NaN
Hausman test-statistic, degrees of freedom and probability = 0.0337, 8, 1.0000
代码是:
clear all;
A=xlsread('D:\A.xlsx')
W1=xlsread('D:\W1.xlsx')
% Dataset downloaded from www.wiley.co.uk/baltagi/
% Spatial weights matrix constructed by Elhorst
%
% written by: J.Paul Elhorst summer 2008
% University of Groningen
% Department of Economics
% 9700AV Groningen
% the Netherlands
% j.p.elhorst@rug.nl
%
% REFERENCE:
% Elhorst JP (2009) Spatial Panel Data Models. In Fischer MM, Getis A (Eds.)
% Handbook of Applied Spatial Analysis, Ch. C.2. Springer: Berlin Heidelberg New York.
%
% dimensions of the problem
T=14; % number of time periods
N=3; % number of regions
% row-normalize W
W=normw(W1); % function of LeSage
y=A(:,[1]); % column number in the data matrix that corresponds to the dependent variable
x=A(:,[2,3,4,5,6,7,8]); % column numbers in the data matrix that correspond to the independent variables
xconstant=ones(N*T,1);
[nobs K]=size(x);
% ----------------------------------------------------------------------------------------
% spatial fixed effects + spatially lagged dependent variable
info.lflag=0; % required for exact results
info.model=1;
info.fe=0; % no print intercept and spatial fixed effects
results=sar_panel_FE(y,x,W,T,info);
vnames=strvcat('logcit','logm','logp','logr','logr2','logs','logk','logw');
prt(results,vnames,1);
blagfe=[results.beta;results.rho];
covblagfe=results.cov;
% LR-test for joint significance spatial fixed effects
logliklagfe=results.lik;
info.model=0;
results=sar_panel_FE(y,x,W,T,info);
logliklag=results.lik;
LR=-2*(logliklag-logliklagfe);
dof=N;
probability=1-chis_prb(LR,dof);
% Note: probability > 0.05 implies rejection of spatial fixed effects
fprintf(1,'LR-test joint significance spatial fixed effects, degrees of freedom and probability = %9.4f,%6d,%9.4f \n',LR,dof,probability);
% ----------------------------------------------------------------------------------------
% spatial random effects + spatially lagged dependent variable
clear info.model;
info.model=1;
results=sar_panel_RE(y,[xconstant x],W,T,info);
vnames=strvcat('logcit','logm','logp','logr','logr2','logs','logk','logw');
prt(results,vnames,1);
blagre=[results.beta(2:end);results.rho]; % exclude constant
covblagre=results.cov(2:end,2:end); % exclude constant
% LR-test for significance spatial random effects (note logliklag is already available)
logliklagre=results.lik;
LR=-2*(logliklag-logliklagre);
dof=1;
probability=1-chis_prb(LR,dof);
% Note: probability > 0.05 implies rejection of spatial fixed effects
fprintf(1,'LR-test significance spatial random effects, degrees of freedom and probability = %9.4f,%6d,%9.4f \n',LR,dof,probability);
% ----------------------------------------------------------------------------------------
% Hausman test FE versus RE of model + spatially lagged dependent variable
hausman=(blagfe-blagre)'*inv(covblagre-covblagfe)*(blagfe-blagre);
dof=length(blagfe);
probability=1-chis_prb(abs(hausman),dof);
% Note: probability > 0.05 implies rejection of random effects model in favor of fixed effects model
fprintf(1,'Hausman test-statistic, degrees of freedom and probability = %9.4f,%6d,%9.4f \n',hausman,dof,probability);
% ----------------------------------------------------------------------------------------
% spatial fixed effects + spatial autocorrelation
clear info.model;
info.lflag=0; % required for exact results
info.fe=0; % no print intercept and spatial fixed effects
info.model=1;
results=sem_panel_FE(y,x,W,T,info);
vnames=strvcat('logcit','logm','logp','logr','logr2','logs','logk','logw');
prt_spnew(results,vnames,1);
berrorfe=[results.beta;results.rho];
covberrorfe=results.cov;
% LR-test for joint significance spatial fixed effects
loglikerrorfe=results.lik;
info.model=0;
results=sar_panel_FE(y,x,W,T,info);
loglikerror=results.lik;
LR=-2*(loglikerror-loglikerrorfe);
dof=N;
probability=1-chis_prb(LR,dof);
% Note: probability > 0.05 implies rejection of spatial fixed effects
fprintf(1,'LR-test joint significance spatial fixed effects, degrees of freedom and probability = %9.4f,%6d,%9.4f \n',LR,dof,probability);
% ----------------------------------------------------------------------------------------
% spatial random effects + spatial autocorrelation
clear info.model;
results=sem_panel_RE(y,[xconstant x],W,T);
vnames=strvcat('logcit','logm','logp','logr','logr2','logs','logk','logw');
prt_spnew(results,vnames,1);
berrorre=[results.beta(2:end);results.rho]; % exclude constant
covberrorre=results.cov(2:end,2:end); % exclude constant
% LR-test for significance spatial random effects (note loglikerror is already available)
loglikerrorre=results.lik;
LR=-2*(loglikerror-loglikerrorre);
dof=1;
probability=1-chis_prb(LR,dof);
% Note: probability > 0.05 implies rejection of spatial fixed effects
fprintf(1,'LR-test significance spatial random effects, degrees of freedom and probability = %9.4f,%6d,%9.4f \n',LR,dof,probability);
% ----------------------------------------------------------------------------------------
% Hausman test FE versus RE of model + spatial autocorrelation
hausman=(berrorfe-berrorre)'*inv(covberrorre-covberrorfe)*(berrorfe-berrorre);
dof=length(berrorfe);
probability=1-chis_prb(abs(hausman),dof);
% Note: probability > 0.05 implies rejection of random effects model in favor of fixed effects model
fprintf(1,'Hausman test-statistic, degrees of freedom and probability = %9.4f,%6d,%9.4f \n',hausman,dof,probability);
求问大神,为什么LR检验的值都出现NAN?