以空间滞后模型的个体效应为例,程序如下。
具体遇到的问题有:1、LR检验显示错误 2、LM检验有的不显著 3、有些变量的系数与预期相反
T=4;
N=25;
W=normw(W1);
y=A(:,[3]);
x=A(:,[4:20]);
info.lflag=0;
info.model=1;
info.fe=0;
results=sem_panel_FE(y,x,W,T,info);
vnames=strvcat('教育投资','对子女的期望','调整后家庭纯收入','受教育年限','个人收入','子女性别','城乡分类','家庭中学历最高性别','户口类型','国有/集体企业','民办企业','其他类型企业','职业其他','事业单位','私营企业/个体工商','职业为自己/自家干活','外商港澳台投资','ZF部门党政机关');
prt_spnew(results,vnames,1);
blagre=[results.beta(2:end);results.rho]; % exclude constant
covblagre=results.cov(2:end,2:end);
%LM检验和稳健的LM检验
% Print out effects estimates
LMsarsem_panel(results,W,y,x);
blagfe=[results.beta;results.rho];
covblagfe=results.cov;
% LR-test for joint significance spatial fixed effects
logliklagfe=results.lik;
info.model=1;
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);
% Hausman test FE versus RE of model + spatially lagged dependent variable
covblagfe= covblagfe(1:17,1:17)
blagfe=blagfe(1:17,:)
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);
%运行结果
Pooled model with spatial error autocorrelation and spatial fixed effects
Dependent Variable = 教育投资
R-squared = 0.7305
corr-squared = 0.4389
sigma^2 = 0.0096
log-likelihood = 100.10764
Nobs,Nvar,#FE = 100, 17, 42
# iterations = 14
min and max rho = -0.9900, 0.9900
total time in secs = 1.2800
time for optimiz = 0.5700
time for lndet = 0.0570
time for t-stats = 0.0660
No lndet approximation used
***************************************************************
Variable Coefficient Asymptot t-stat z-probability
对子女的期望 0.228279 0.738370 0.460289
调整后家庭纯收入 1.517292 4.004764 0.000062
受教育年限 0.164816 0.954345 0.339909
个人收入 0.195996 0.879214 0.379285
子女性别 0.128975 0.908650 0.363535
城乡分类 0.079042 0.773469 0.439245
家庭中学历最高性别 -0.084279 -0.751456 0.452378
户口类型 -0.129711 -0.944824 0.344749
国有/集体企业 -0.746339 -2.012652 0.044151
民办企业 -0.630928 -0.844520 0.398379
其他类型企业 -0.651729 -1.576001 0.115026
职业其他 -0.398841 -0.674792 0.499808
事业单位 -0.075951 -0.185438 0.852886
私营企业/个体工商 -0.382527 -1.330488 0.183358
职业为自己/自家干活 -0.511331 -1.568177 0.116840
外商港澳台投资 0.506747 1.008832 0.313055
ZF部门党政机关 -0.164558 -0.318135 0.750382
spat.aut. 0.440971 4.335554 0.000015
LM test no spatial lag, probability = 23.8529, 0.000
robust LM test no spatial lag, probability = 4.1537, 0.042
LM test no spatial error, probability = 20.8152, 0.000
robust LM test no spatial error, probability = 1.1159, 0.291
LR-test joint significance spatial fixed effects, degrees of freedom and probability = NaN, 25, NaN