全部版块 我的主页
论坛 经济学论坛 三区 区域经济学
3738 2
2014-07-20
请问大神们如何解决呢?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);

二维码

扫码加我 拉你入群

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

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

全部回复
2015-5-30 18:29:05
我不懂啊
二维码

扫码加我 拉你入群

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

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

2016-11-22 14:25:57
请问大神你的问题得到解决了吗?有没有相关的程序包分享一下,论坛币好商量
二维码

扫码加我 拉你入群

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

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

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群