搜索
人大经济论坛 附件下载

附件下载

所在主题:
文件名:  权重矩阵和变量矩阵.txt
资料下载链接地址: https://bbs.pinggu.org/a-1261707.html
附件大小:
52.15 KB   举报本内容
我在用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);
本人是初学,还请哪位大虾指点一下,不胜感激!


    熟悉论坛请点击新手指南
下载说明
1、论坛支持迅雷和网际快车等p2p多线程软件下载,请在上面选择下载通道单击右健下载即可。
2、论坛会定期自动批量更新下载地址,所以请不要浪费时间盗链论坛资源,盗链地址会很快失效。
3、本站为非盈利性质的学术交流网站,鼓励和保护原创作品,拒绝未经版权人许可的上传行为。本站如接到版权人发出的合格侵权通知,将积极的采取必要措施;同时,本站也将在技术手段和能力范围内,履行版权保护的注意义务。
(如有侵权,欢迎举报)
二维码

扫码加我 拉你入群

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

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

GMT+8, 2026-1-4 02:17