楼主: 果果1106
5358 11

[问答] elhost的LMsarsem_panal错误警告 [推广有奖]

  • 2关注
  • 2粉丝

本科生

72%

还不是VIP/贵宾

-

威望
0
论坛币
285 个
通用积分
0
学术水平
0 点
热心指数
5 点
信用等级
0 点
经验
3505 点
帖子
58
精华
0
在线时间
113 小时
注册时间
2012-3-2
最后登录
2018-5-8

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
%A=wk1read('C:\Program Files\MATLAB\R2010a\elhorst\cigarette.wk1',1,0); % data set with T=30
%W1=wk1read('C:\Program Files\MATLAB\R2010a\elhorst\Spat-Sym-US.wk1');
load cigarette_mat;
load US_W;
% 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 problem
T=30; % number of time periods
N=46; % number of regions
% row-normalize W
W=normw(W1); % function of LeSage
y=A(:,[3]); % column number in the data matrix that corresponds to the dependent variable
x=A(:,[4,6]); % 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('logcit','intercept','logp','logy');
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 variables
model=1;
[ywith,xwith,meanny,meannx,meanty,meantx]=demean(y,x,N,T,model);
results=ols(ywith,xwith);
vnames=strvcat('logcit','logp','logy'); % should be changed if x is changed
prt_reg(results,vnames);
sfe=meanny-meannx*results.beta; % including the constant term
yme = 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 effects
sige=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 variables
model=2;
[ywith,xwith,meanny,meannx,meanty,meantx]=demean(y,x,N,T,model);
results=ols(ywith,xwith);
vnames=strvcat('logcit','logp','logy'); % should be changed if x is changed
prt_reg(results,vnames);
tfe=meanty-meantx*results.beta; % including the constant term
yme = 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 effects
sige=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 variables
model=3;
[ywith,xwith,meanny,meannx,meanty,meantx]=demean(y,x,N,T,model);
results=ols(ywith,xwith);
vnames=strvcat('logcit','logp','logy'); % should be changed if x is changed
prt_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 effects
sige=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 effects
LR=-2*(logliktfe-loglikstfe);
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);
LR=-2*(logliksfe-loglikstfe);
dof=T;
probability=1-chis_prb(LR,dof);
% Note: probability > 0.05 implies rejection of spatial fixed effects
fprintf(1,'LR-test joint significance time-periode fixed effects, degrees of freedom and probability = %9.4f,%6d,%9.4f \n',LR,dof,probability);


        以上是elhost写的LMsarsem_panal程序,我运行时总是出现下面这个错误警告,不知道怎么回事,可有同学有解?不胜感激~
Undefined function 'LMlag_panel' for input arguments of type 'double'.

Error in demoLMsarsem_panel (line 45)
LM1=LMlag_panel(y,[xconstant x],W);


二维码

扫码加我 拉你入群

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

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

关键词:Panal lmsar host SARS Anal MATLAB程序

沙发
modivenn 在职认证  发表于 2015-4-28 08:12:26 |只看作者 |坛友微信交流群
你没有LMlag_panel的m文件所以才会报错

使用道具

藤椅
果果1106 在职认证  发表于 2015-5-24 21:56:02 |只看作者 |坛友微信交流群
modivenn 发表于 2015-4-28 08:12
你没有LMlag_panel的m文件所以才会报错
恩恩  是的  谢谢~~

使用道具

板凳
loveym0726 发表于 2015-9-12 00:59:21 |只看作者 |坛友微信交流群
modivenn 发表于 2015-4-28 08:12
你没有LMlag_panel的m文件所以才会报错
您好,请问您有这个文件吗,还有lmerror_panel的文件

使用道具

报纸
慕溪xian 发表于 2015-10-8 20:01:58 |只看作者 |坛友微信交流群
您好!!请问这个问题您解决了?请问有没有prt_tests文件啊!!!

使用道具

地板
果果1106 在职认证  发表于 2015-10-9 09:39:09 |只看作者 |坛友微信交流群
慕溪xian 发表于 2015-10-8 20:01
您好!!请问这个问题您解决了?请问有没有prt_tests文件啊!!!
有 我的问题后来解决了 但是结果还是不理想 后来换了stata做的 ,用的xsmle

使用道具

7
saber幽戏 发表于 2016-1-25 11:45:26 |只看作者 |坛友微信交流群
果果1106 发表于 2015-10-9 09:39
有 我的问题后来解决了 但是结果还是不理想 后来换了stata做的 ,用的xsmle
你好,请问您有LMlag_panel  以及lmerror_panel 的文件吗

使用道具

8
wangbbs 发表于 2016-1-25 23:07:35 |只看作者 |坛友微信交流群
如果你运行的程序里没有必要的文件可以去Elhorst的个人主页去下载.

使用道具

9
matlab-007 发表于 2016-8-27 21:03:03 |只看作者 |坛友微信交流群
自己进行单步运行调试,应该很容易锁定问题出错的地方

使用道具

10
无他 发表于 2016-8-30 10:43:14 |只看作者 |坛友微信交流群
缺少必要的工具包文件里的函数吧
可能是下载的包不全
记得elhorst和jplv7貌似都要的

使用道具

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

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-4-28 10:26