楼主: 王少鹏1
3799 2

[其他] 求解:用MATLAB生成空间距离倒数矩阵后面板分析出现下面的几句警告 [推广有奖]

  • 22关注
  • 1粉丝

已卖:19份资源

博士生

37%

还不是VIP/贵宾

-

威望
0
论坛币
765 个
通用积分
2.3573
学术水平
1 点
热心指数
7 点
信用等级
2 点
经验
31381 点
帖子
358
精华
0
在线时间
152 小时
注册时间
2012-1-24
最后登录
2020-5-24

楼主
王少鹏1 发表于 2014-7-20 21:00:27 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
请问大神们如何解决呢?Warning: Matrix is close to singular or badly scaled.
         Results may be inaccurate. RCOND = 5.736767e-019.
> In ols at 51
  In demoLMsarsem_panel at 30

Ordinary Least-squares Estimates
Dependent Variable =    LFDI         
R-squared      = -251.3651
Rbar-squared   = -260.5117
sigma^2        =  922.5813
Durbin-Watson  =    0.2789
Nobs, Nvars    =    630,    23


Warning: Matrix is close to singular or badly scaled.         Results may be inaccurate. RCOND = 1.450489e-018. > In LMsarsem_panel at 37  In demoLMsarsem_panel at 38LM test no spatial lag, probability          =   47.3846,    0.000 robust LM test no spatial lag, probability   = 2010.5871,    0.000 LM test no spatial error, probability        =  736.5092,    0.000 robust LM test no spatial error, probability = 2699.7117,    0.000 Warning: Matrix is close to singular or badly scaled.         Results may be inaccurate. RCOND = 1.450489e-018. > In lmlag_panel at 50  In demoLMsarsem_panel at 43LM lag test for omitted spatial lag in panel data

附带程序A=wk1read('cigardemo.wk1',1,0); % data set with T=30W1=wk1read('spat-sym-us1.wk1');% Dataset downloaded from www.wiley.co.uk/baltagi/% Spatial weights matrix constructed by Elhorst%% written by: J.Paul Elhorst summer 2010% University of Groningen% Department of Economics% 9700AV Groningen% the Netherlands% j.p.elhorst@rug.nl%% REFERENCES: % Elhorst JP (2010) Matlab Software for Spatial Panels. Under review.%% Elhorst JP (2010) 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 problemT=10; % number of time periodsN=63; % number of regions% row-normalize WW=normw(W1); % function of LeSagey=A(:,[26]); % column number in the data matrix that corresponds to the dependent variablex=A(:,[4:25]); % column numbers in the data matrix that correspond to the independent variablesxconstant=ones(N*T,1);[nobs K]=size(x);%% % ols estimation results=ols(y,[xconstant x]);vnames=char('LFDI','intercept','LNGDP','LNRPGDP','LNPOP','LNHM','LNUPCDIF','LNUFPCCS','LNOPOP','LNWAGE','LNLFEXP','LNTFAI','LNLAREA','LNROTG','LNOHDEP','LNLTFI','LNEDUCATION','LNRSCG','LNTIOV','LNFFETIOV','LNSUMFDI','LNAVLAREA','LNFFETIOVRATE','LNROTGRATE');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;
% The (robust)LM tests developed by Elhorst
LMsarsem_panel(results,W,y,[xconstant x]); % (Robust) LM tests
% The lm tests developed by Donald Lacombe% see http://www.rri.wvu.edu/lacombe/~lacombe.htm
lm1=lmlag_panel(y,[xconstant x],W);prt_tests(lm1);
lm2=lmerror_panel(y,[xconstant x],W);prt_tests(lm2);
lm3=lmlag_robust_panel(y,[xconstant x],W);prt_tests(lm3);
lm4=lmerror_robust_panel(y,[xconstant x],W);prt_tests(lm4);
%%% spatial fixed effects + (robust) LM tests for spatial lag and spatial error model% fixed effects, within estimator% demeaning of the y and x variablesmodel=1;[ywith,xwith,meanny,meannx,~,meantx]=demean(y,x,N,T,model);results=ols(ywith,xwith);vnames=char('LNFDI','LNGDP','LNRPGDP','LNPOP','LNHM','LNUPCDIF','LNUFPCCS','LNOPOP','LNWAGE','LNLFEXP','LNTFAI','LNLAREA','LNROTG','LNOHDEP','LNLTFI','LNEDUCATION','LNRSCG','LNTIOV','LNFFETIOV','LNSUMFDI','LNAVLAREA','LNFFETIOVRATE','LNROTGRATE'); % should be changed if x is changedprt_reg(results,vnames);sfe=meanny-meannx*results.beta; % including the constant termyme = y - mean(y);et=ones(T,1);error=y-kron(et,sfe)-x*results.beta;rsqr1 = error'*error;rsqr2 = yme'*yme;FE_rsqr2 = 1.0 - rsqr1/rsqr2; % r-squared including fixed effectssige=results.sige*((nobs-K)/nobs);logliksfe=-nobs/2*log(2*pi*sige)-1/(2*sige)*results.resid'*results.resid;LMsarsem_panel(results,W,ywith,xwith); % (Robust) LM tests
lm1=lmlag_panel(ywith,xwith,W);prt_tests(lm1);
lm2=lmerror_panel(ywith,xwith,W);prt_tests(lm2);
lm3=lmlag_robust_panel(ywith,xwith,W);prt_tests(lm3);
lm4=lmerror_robust_panel(ywith,xwith,W);prt_tests(lm4);%% % time-period fixed effects + (robust) LM tests for spatial lag and spatial error model% fixed effects, within estimator% demeaning of the y and x variablesmodel=2;[ywith,xwith,~,~,meanty,meantx]=demean(y,x,N,T,model);results=ols(ywith,xwith);vnames=char('LNFDI','LNGDP','LNRPGDP','LNPOP','LNHM','LNUPCDIF','LNUFPCCS','LNOPOP','LNWAGE','LNLFEXP','LNTFAI','LNLAREA','LNROTG','LNOHDEP','LNLTFI','LNEDUCATION','LNRSCG','LNTIOV','LNFFETIOV','LNSUMFDI','LNAVLAREA','LNFFETIOVRATE','LNROTGRATE'); % should be changed if x is changedprt_reg(results,vnames);tfe=meanty-meantx*results.beta; % including the constant termyme = y - mean(y);en=ones(N,1);error=y-kron(tfe,en)-x*results.beta;rsqr1 = error'*error;rsqr2 = yme'*yme;FE_rsqr2 = 1.0 - rsqr1/rsqr2; % r-squared including fixed effectssige=results.sige*((nobs-K)/nobs);logliktfe=-nobs/2*log(2*pi*sige)-1/(2*sige)*results.resid'*results.resid;LMsarsem_panel(results,W,ywith,xwith); % (Robust) LM tests
lm1=lmlag_panel(ywith,xwith,W);prt_tests(lm1);
lm2=lmerror_panel(ywith,xwith,W);prt_tests(lm2);
lm3=lmlag_robust_panel(ywith,xwith,W);prt_tests(lm3);
lm4=lmerror_robust_panel(ywith,xwith,W);prt_tests(lm4);%% % 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 variablesmodel=3;[ywith,xwith,meanny,meannx,meanty,meantx]=demean(y,x,N,T,model);results=ols(ywith,xwith);vnames=char('LNFDI','LNGDP','LNRPGDP','LNPOP','LNHM','LNUPCDIF','LNUFPCCS','LNOPOP','LNWAGE','LNLFEXP','LNTFAI','LNLAREA','LNROTG','LNOHDEP','LNLTFI','LNEDUCATION','LNRSCG','LNTIOV','LNFFETIOV','LNSUMFDI','LNAVLAREA','LNFFETIOVRATE','LNROTGRATE'); % should be changed if x is changedprt_reg(results,vnames);intercept=mean(y)-mean(x)*results.beta; sfe=meanny-meannx*results.beta-kron(en,intercept);tfe=meanty-meantx*results.beta-kron(et,intercept);yme = y - mean(y);ent=ones(N*T,1);error=y-kron(tfe,en)-kron(et,sfe)-x*results.beta-kron(ent,intercept);rsqr1 = error'*error;rsqr2 = yme'*yme;FE_rsqr2 = 1.0 - rsqr1/rsqr2; % r-squared including fixed effectssige=results.sige*((nobs-K)/nobs);loglikstfe=-nobs/2*log(2*pi*sige)-1/(2*sige)*results.resid'*results.resid;
LMsarsem_panel(results,W,ywith,xwith); % (Robust) LM tests
lm1=lmlag_panel(ywith,xwith,W);prt_tests(lm1);
lm2=lmerror_panel(ywith,xwith,W);prt_tests(lm2);
lm3=lmlag_robust_panel(ywith,xwith,W);prt_tests(lm3);
lm4=lmerror_robust_panel(ywith,xwith,W);prt_tests(lm4);%% % Tests for the joint significance of spatial and/or time-period fixed effectsLR=-2*(logliktfe-loglikstfe);dof=N;probability=1-chis_prb(LR,dof);% Note: probability > 0.05 implies rejection of spatial fixed effectsfprintf(1,'LR-test joint significance spatial fixed effects, degrees of freedom and probability = %9.4f,%6d,%9.4f \n',LR,dof,probability);LR=-2*(logliksfe-loglikstfe);dof=T;probability=1-chis_prb(LR,dof);% Note: probability > 0.05 implies rejection of spatial fixed effectsfprintf(1,'LR-test joint significance time-periode fixed effects, degrees of freedom and probability = %9.4f,%6d,%9.4f \n',LR,dof,probability);

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:MATLAB atlab matla Mat Lab Matrix sigma close 倒数 空间

沙发
haohanzhihai 发表于 2015-5-30 18:29:05
我不懂啊

藤椅
宏尘 在职认证  发表于 2016-11-22 14:25:57
请问大神你的问题得到解决了吗?有没有相关的程序包分享一下,论坛币好商量

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
jg-xs1
拉您进交流群
GMT+8, 2025-12-26 11:11