matlab 空间计量,使用Matlab进行空间计量分析时遇到的错误

以下错误应该怎么解决?恳请热心的高手指点一下啊!万分感谢!!

Matlab的运行结果为:

??? Undefined command/function 'normw'.

Error in ==> multip5 at 23

W=normw(W1); % function of LeSage

所使用的m文件的具体命令为:

clear all;

load multip&W.mat;

load W1.mat;

% Spatial weights matrix constructed by Elhorst

%

% written by: J.Paul Elhorst summer 2008

% University of Groningen

% Department of Economics

% 9700AV Groningen

% the Netherlands

%

% 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=20; % number of time periods

N=30; % number of regions

% row-normalize W

W=normw(W1); % function of LeSage

y=multip(:,[1]); % column number in the data matrix that corresponds to the dependent variable

x=multip(:,[3,4,5,7,8,9,10,11,12,13]); % 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('upg2','lK','lz','lrwork2','lpercapi','ltech','lperh','lrfdi','lopen','lurban','lgover');

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('upg2','intercept','lK','lz','lrwork2','lpercapi','ltech','lperh','lrfdi','lopen','lurban','lgover');

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('upg2','lK','lz','lrwork2','lpercapi','ltech','lperh','lrfdi','lopen','lurban','lgover');

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('upg2','intercept','lK','lz','lrwork2','lpercapi','ltech','lperh','lrfdi','lopen','lurban','lgover');

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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值