首页 > 编程知识 正文

豪斯曼检验为负怎么选择模型

时间:2023-05-06 00:18:31 阅读:229751 作者:4709

各位大神,本人空间计量诚心的网络,最近看了迷路的抽屉老师的书,自己也进行了实证分析。有一些问题不太懂:

1、空间面板数据模型分为混合空间面板数据模型、空间固定效应空间面板数据模型、时间固定效应空间面板模型、空间和时间双固定效应的空间面板数据模型、随机效应的空间面板数据模型,而豪斯曼检验可以用来判断到底是选择固定效应模型还是随机效应模型。gddhj统计量到底是如何来构造呢?是否需要按照空间时间双固定效应模型vs.随机效应模型、空间固定效应模型vs.空间随机效应模型、时间固定效应模型vs.时间随机效应模型分别来构造?如果是空间随机时间固定效应模型,那么豪斯曼检验统计量是不是按照空间和时间双固定效应模型vs.随机效应模型来构造?

2.我在应用自己的数据,运行MATLAB中的demopanelscompare代码时,到最后一个模型“空间随机时间固定效应模型”,就会出现错误:

部分代码:

% Spatial random effects and time period fixed effects + spatially lagged dependent variable + spatially

% independent variables

[ywith,xwith,meanny,meannx,meanty,meantx]=demean(y,[x wx],N,T,2); % 2=time dummies

info.model=1;%不清楚此处为什么还是选择1,空间固定效应模型不才是1吗?

results=sar_panel_RE(ywith,xwith,W,T,info);

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);

% Wald test for spatial lag model

btemp=results.parm(1:2*K+2);

varcov=results.cov(1:2*K+2,1:2*K+2);

Rafg=zeros(K,2*K+2);

for k=1:K

Rafg(k,K+k)=1; % R(1,3)=0 and R(2,4)=0;

end

Wald_spatial_lag=(Rafg*btemp)'*inv(Rafg*varcov*Rafg')*Rafg*btemp

prob_spatial_lag= 1-chis_cdf (Wald_spatial_lag, K) % probability greater than 0.05 points to insignificance

% LR test spatial Durbin model against spatial lag model (requires

% estimation results of the spatial lag model to be available)

resultssar=sar_panel_RE(ywith,xwith(:,1:K),W,T,info);

LR_spatial_lag=-2*(resultssar.lik-results.lik)

prob_spatial_lag=1-chis_cdf (LR_spatial_lag,K) % probability greater than 0.05 points to insignificance

% Wald test for spatial error model

R=zeros(K,1);

for k=1:K

R(k)=btemp(2*K+1)*btemp(k)+btemp(K+k); % k changed in 1, 7/12/2010

%   R(1)=btemp(5)*btemp(1)+btemp(3);

%   R(2)=btemp(5)*btemp(2)+btemp(4);

end

Rafg=zeros(K,2*K+2);

for k=1:K

Rafg(k,k)    =btemp(2*K+1); % k changed in 1, 7/12/2010

Rafg(k,K+k)  =1;

Rafg(k,2*K+1)=btemp(k);

%   Rafg(1,1)=btemp(5);Rafg(1,3)=1;Rafg(1,5)=btemp(1);

%   Rafg(2,2)=btemp(5);Rafg(2,4)=1;Rafg(2,5)=btemp(2);

end

Wald_spatial_error=R'*inv(Rafg*varcov*Rafg')*R

prob_spatial_error= 1-chis_cdf (Wald_spatial_error,K) % probability greater than 0.05 points to insignificance

% LR test spatial Durbin model against spatial error model (requires

% estimation results of the spatial error model to be available

resultssem=sem_panel_RE(ywith,xwith(:,1:K),W,T,info);

LR_spatial_error=-2*(resultssem.lik-results.lik)

prob_spatial_error=1-chis_cdf (LR_spatial_error,K) % probability greater than 0.05 points to insignificance

%运行到这一行时,就会提示错误。

错误使用 gammainc

输入必须为实数完全双精度值或单精度值。

出错 gamm_cdf (line 25)

cdf = gammainc(x,a);

出错 chis_cdf (line 28)

F = gamm_cdf(x/2,a*0.5);

出错 demopanelscompareorigin (line 310)

prob_spatial_error=1-chis_cdf (LR_spatial_error,K) % probability greater than 0.05 points to insignificance

我往前找错,发现出错的原因是resultssem.lik数值为:1031.40668903056 + 47.1238898038469i;

不知道为什么会出现这样的问题?该代码中前面还运行了无固定效应、空间固定效应、时间固定效应和时空双固定效应,都没有报错。用相同的代码,运行书中的数据,也没有问题。难道是我的数据存在什么问题吗?

3.我在运行SDM模型的几种固定效应、时间效应时,发现时间固定效应的相关系数R2(0.47)明显高于空间固定效应(0.10)、时空固定效应(0.12),而最大似然值时间固定效应模型(679.8)却显著低于空间固定效应(1121.4)和时空固定效应(1142.4),同时,空间固定效应和时空固定效应的变量显著性也好于时间固定效应。为什么不同指标差别那么大?可能是什么原因造成的呢?

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。