matlab做空间面板出现问题——NAN,怎么解决-经管之家官网!

人大经济论坛-经管之家 收藏本站
您当前的位置> 软件培训>>

Matlab软件培训

>>

matlab做空间面板出现问题——NAN,怎么解决

matlab做空间面板出现问题——NAN,怎么解决

发布:weiqun890 | 分类:Matlab软件培训

关于本站

人大经济论坛-经管之家:分享大学、考研、论文、会计、留学、数据、经济学、金融学、管理学、统计学、博弈论、统计年鉴、行业分析包括等相关资源。
经管之家是国内活跃的在线教育咨询平台!

获取电子版《CDA一级教材》

完整电子版已上线CDA网校,累计已有10万+在读~ 教材严格按考试大纲编写,适合CDA考生备考,也适合业务及数据分析岗位的从业者提升自我。

完整电子版已上线CDA网校,累计已有10万+在读~ 教材严格按考试大纲编写,适合CDA考生备考,也适合业务及数据分析岗位的从业者提升自我。

我在用matlab做空间面板时,遇到几个问题,具体的操作如下:权重矩阵(W1)和变量矩阵(A)在附件里LM检验的命令为:T=9;%numberoftimeperiodsN=55;%numberofregions%row-normalizeWW=normw(W1);%functionofLeSagey=A( ...
免费学术公开课,扫码加入


我在用matlab做空间面板时,遇到几个问题,具体的操作如下:
权重矩阵(W1)和变量矩阵(A)在附件里
LM检验的命令为:
T=9; % number of time periods
N=55; % 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:11]); % column numbers in the data matrix that correspond to the independent variables
xconstant=ones(N*T,1);
[nobs K]=size(x);
% ---------------------------------------------------------------------------------------
% ols estimation
results=ols(y,[xconstant x]);
vnames=strvcat('crste','PGDP','MIDU','EDU','PIN','PEX','PJIJIAN','CHENGZHEN','SZGX','TREAT','EFFECT');
prt_reg(results,vnames,1);
sige=results.sige*((nobs-K)/nobs);
loglikols=-nobs/2*log(2*pi*sige)-1/(2*sige)*results.resid'*results.resid
LMsarsem_panel(results,W,y,[xconstant x]); % (Robust) LM tests
% ----------------------------------------------------------------------------------------
% spatial fixed effects + (robust) LM tests for spatial lag and spatial error model
% fixed effects, within estimator
% demeaning of the y and x variables
model=1;
[ywith,xwith,meanny,meannx,meanty,meantx]=demean(y,x,N,T,model);
results=ols(ywith,xwith);
vnames=strvcat('crste','PGDP','MIDU','EDU','PIN','PEX','PJIJIAN','CHENGZHEN','SZGX','TREAT','EFFECT'); % should be changed if x is changed
prt_reg(results,vnames);
FE=meanny-meannx*results.beta; % including the constant term
yme = y - mean(y);
ee=ones(T,1);
error=y-kron(ee,FE)-x*results.beta;
rsqr1 = error'*error;
rsqr2 = yme'*yme;
FE_rsqr2 = 1.0 - rsqr1/rsqr2 % r-squared including fixed effects
sige=results.sige*((nobs-K)/nobs);
loglikfe=-nobs/2*log(2*pi*sige)-1/(2*sige)*results.resid'*results.resid
LMsarsem_panel(results,W,ywith,xwith); % (Robust) LM tests
% ----------------------------------------------------------------------------------------
% spatial and time period fixed effects + (robust) LM tests for spatial lag and spatial error model
% fixed effects, within estimator
% demeaning of the y and x variables
model=3;
[ywith,xwith,meanny,meannx,meanty,meantx]=demean(y,x,N,T,model);
results=ols(ywith,xwith);
vnames=strvcat('crste','PGDP','MIDU','EDU','PIN','PEX','PJIJIAN','CHENGZHEN','SZGX','TREAT','EFFECT'); % should be changed if x is changed
prt_reg(results,vnames);
LMsarsem_panel(results,W,ywith,xwith); % (Robust) LM tests
结果为:
Wrong # of variable names in prt_reg -- check vnames argument
will use generic variable names
Ordinary Least-squares Estimates
R-squared = 0.5555
Rbar-squared = 0.5463
sigma^2 = 0.0200
Durbin-Watson= 1.7191
Nobs, Nvars = 495, 11
***************************************************************
Variable Coefficient t-statistic t-probability
variable 1 0.671015 4.589867 0.000006
variable 2 0.074995 2.970968 0.003116
variable 3 0.109128 7.962159 0.000000
variable 4 0.673918 1.384733 0.166772
variable 5 -0.092080 -4.879901 0.000001
variable 6 -0.204196 -10.168544 0.000000
variable 7 0.013275 1.112598 0.266433
variable 8 0.076925 0.949029 0.343079
variable 9 0.038177 1.291779 0.197050
variable 10 0.155732 3.955480 0.000088
variable 11 -0.010064 -0.271933 0.785789
loglikols =
270.9526
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate.
RCOND =4.047746e-35.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate.
RCOND =6.423347e-36.
Warning: Matrix is singular to working precision.
Warning: Matrix is singular to working precision.
Warning: Matrix is close to singular or badly scaled. Results may be inaccurate.
RCOND =9.370064e-36.
LM test no spatial lag, probability = NaN, NaN
robust LM test no spatial lag, probability = NaN, NaN
LM test no spatial error, probability = 80.5333, 0.0000
robust LM test no spatial error, probability = NaN, NaN
Warning: Matrix is singular to working precision.
Ordinary Least-squares Estimates
Dependent Variable = crste
R-squared = NaN
Rbar-squared = NaN
sigma^2 = NaN
Durbin-Watson= NaN
Nobs, Nvars = 495, 10
***************************************************************
Error using betainc
X must be in the interval [0,1].
Error in tdis_prb (line 35)
tmp = 1.0 - 0.5*betainc(x2,0.5*n,0.5);
Error in prt_reg (line 364)
tout = tdis_prb(results.tstat,nobs-nvar); % find t-stat probabilities
Error in SHS_LMtest (line 26)
prt_reg(results,vnames);
本人是初学,还请哪位大虾指点一下,不胜感激!
「经管之家」APP:经管人学习、答疑、交友,就上经管之家!
免流量费下载资料----在经管之家app可以下载论坛上的所有资源,并且不额外收取下载高峰期的论坛币。
涵盖所有经管领域的优秀内容----覆盖经济、管理、金融投资、计量统计、数据分析、国贸、财会等专业的学习宝库,各类资料应有尽有。
来自五湖四海的经管达人----已经有上千万的经管人来到这里,你可以找到任何学科方向、有共同话题的朋友。
经管之家(原人大经济论坛),跨越高校的围墙,带你走进经管知识的新世界。
扫描下方二维码下载并注册APP
本文关键词:

本文论坛网址:https://bbs.pinggu.org/thread-2182788-1-1.html

人气文章

1.凡人大经济论坛-经管之家转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
数据分析师 人大经济论坛 大学 专业 手机版
联系客服
值班时间:工作日(9:00--18:00)