全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件
1428 4
2019-05-27
T=11; % number of time periods
N=31; % number of regions
% row-normalize W
W=normw(W1); % function of LeSage
y=A(:,[4]); % column number in the data matrix that corresponds to the dependent variable
x=A(:,[5,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=char('CXST','x1','x2','x3','x4','x5','x6','x7');
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);


结果:
Wrong # of variable names in prt_reg -- check vnames argument
will use generic variable names

Ordinary Least-squares Estimates
R-squared      =    0.0440
Rbar-squared   =    0.0383
sigma^2        =  119.5661
Durbin-Watson  =    0.3193
Nobs, Nvars    =    341,     3
****************************************??***********************
Variable        Coefficient      t-statistic    t-probability
variable 1         9.906080        11.754521         0.000000
variable 2         0.175004         1.236923         0.216974
variable 3         0.045317         3.524113         0.000483


loglikols =

  -1.2980e+03

LM test no spatial lag, probability          =  143.5858,    0.000
robust LM test no spatial lag, probability   =    0.7348,    0.391
LM test no spatial error, probability        =  144.8356,    0.000
robust LM test no spatial error, probability =    1.9846,    0.159
LM lag test for omitted spatial lag in panel data

LM value                 143.58581315
Marginal Probability       0.00000000
chi(1) .01 value           6.64000000

LM error test for spatial errors in panel data

LM value                 144.83556667
Marginal Probability       0.00000000
chi(1) .01 value           6.64000000

Robust LM lag test for omitted spatial lag in panel data

LM value                   0.73480738
Marginal Probability       0.39132935
chi(1) .01 value           6.64000000

Robust LM error test for spatial errors in panel data

LM value                   1.98456090
Marginal Probability       0.15891075
chi(1) .01 value           6.64000000

二维码

扫码加我 拉你入群

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

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

全部回复
2019-6-3 09:27:52
我觉得有可能是你的:x=A(:,[5,11]); % column numbers in the data matrix that
你改成[5,6,7..]这样的试试,就是一直列到11
看看是不是就好啦
二维码

扫码加我 拉你入群

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

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

2019-6-3 09:28:03
我觉得有可能是你的:x=A(:,[5,11]); % column numbers in the data matrix that
你改成[5,6,7..]这样的试试,就是一直列到11
看看是不是就好啦
二维码

扫码加我 拉你入群

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

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

2019-6-3 09:28:27
我觉得有可能是你的:x=A(:,[5,11]); % column numbers in the data matrix that
你改成[5,6,7..]这样的试试,就是一直列到11
看看是不是就好啦
二维码

扫码加我 拉你入群

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

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

2019-6-3 09:32:22
您好,我也在做这个,我想跟您交流一下,我也是运行跟您一模一样的程序,但是出现了空:未定义函数或变量 'lmlag_panel’,就卡在lm1=lmlag_panel(y,[xconstant x],W);就执行不下去了。请问您知道可能是什么原因嘛?你的工具箱安装了别的安装包吗?急求!
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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