楼主: lvgod
14555 21

[问答] 请教matlab做空间面板如何做LM和robust-LM检验? [推广有奖]

  • 1关注
  • 55粉丝

讲师

34%

还不是VIP/贵宾

-

威望
0
论坛币
6658 个
通用积分
52.3729
学术水平
19 点
热心指数
24 点
信用等级
7 点
经验
11622 点
帖子
431
精华
0
在线时间
502 小时
注册时间
2006-10-6
最后登录
2024-3-19

2论坛币
请教matlab做空间面板如何做LM和robust-LM检验?还有固定效应模型中的个体效应和时间效应如何显示?   

工具箱中有个demoLMsarsem-panel.m 运行结果是这样的:结果看得不是很懂,如果是lm检验是不是应该有无固定效应、有个体效应、有时间效应、即有个体又有时间   然后模型有sam sem  那就应该有八个检验借结果吧,下面的好像不是?有懂的请指教啊!
Ordinary Least-squares Estimates
Dependent Variable =        logcit   
R-squared      =    0.3861
Rbar-squared   =    0.3794
sigma^2        =    0.0320
Durbin-Watson  =    1.8047
Nobs, Nvars    =    276,     4
***************************************************************
Variable       Coefficient      t-statistic    t-probability
intercept         1.605485         5.435955         0.000000
logp             -1.041989        -8.610354         0.000000
logpn             0.146363         1.176771         0.240316
logy              0.703143        10.651591         0.000000

LM test no spatial lag, probability          =    2.8677,    0.090
robust LM test no spatial lag, probability   =    1.5139,    0.219
LM test no spatial error, probability        =    6.3199,    0.012
robust LM test no spatial error, probability =    4.9661,    0.026

Ordinary Least-squares Estimates
Dependent Variable =           logcit
R-squared      =    0.4634
Rbar-squared   =    0.4595
sigma^2        =    0.0015
Durbin-Watson  =    1.8004
Nobs, Nvars    =    276,     3
***************************************************************
Variable      Coefficient      t-statistic    t-probability
logp            -0.597372       -12.071931         0.000000
logpn            0.162570         2.598087         0.009883
logy             0.335686         9.102462         0.000000


FE_rsqr2 =

    0.9716


loglikfe =

  509.8241

LM test no spatial lag, probability          =   12.7208,    0.000
robust LM test no spatial lag, probability   =    4.7332,    0.030
LM test no spatial error, probability        =   23.6084,    0.000
robust LM test no spatial error, probability =   15.6207,    0.000

Ordinary Least-squares Estimates
Dependent Variable =           logcit
R-squared      =    0.4272
Rbar-squared   =    0.4230
sigma^2        =    0.0013
Durbin-Watson  =    2.0461
Nobs, Nvars    =    276,     3
***************************************************************
Variable      Coefficient      t-statistic    t-probability
logp            -0.648719       -13.267854         0.000000
logpn            0.067473         1.072247         0.284556
logy             0.317823         4.891167         0.000002

LM test no spatial lag, probability          =    0.9402,    0.332
robust LM test no spatial lag, probability   =    3.8306,    0.050
LM test no spatial error, probability        =    4.0933,    0.043
robust LM test no spatial error, probability =    6.9837,    0.008
>>



关键词:robust MATLAB matla atlab 空间面板 matlab sigma 工具箱 空间 如何

本帖被以下文库推荐

沙发
lvgod 发表于 2015-1-26 16:47:31 |只看作者 |坛友微信交流群
这里是代码:
clear all;

A=wk1read('cigardemo.wk1',1,0);
W1=wk1read('Spat-Sym-US.wk1');
% Dataset downloaded from www.wiley.co.uk/baltagi/
% Spatial weights matrix constructed by Elhorst
%
% written by: J.Paul Elhorst summer 2008
% University of Groningen
% Department of Economics
% 9700AV Groningen
% the Netherlands
% j.p.elhorst@rug.nl
%
% REFERENCES:
% Elhorst JP (2009) 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=6; % 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,5,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=char('logcit','intercept','logp','logpn','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;
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=char('logcit','logp','logpn','logy'); % 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=char('logcit','logp','logpn','logy'); % should be changed if x is changed
prt_reg(results,vnames);
LMsarsem_panel(results,W,ywith,xwith); % (Robust) LM tests

使用道具

藤椅
木美紫凝 发表于 2015-1-26 23:18:37 |只看作者 |坛友微信交流群
4个检验结果里面分别有LM和robust-LM检验的结果,我也想知道里面第一个是无固定效应的检验吗?我做的东西里面说有奇异矩阵,那是不是出来的结果就是不准确的呀?有没有高人来回答一下??

使用道具

板凳
lvgod 发表于 2015-1-27 10:27:38 |只看作者 |坛友微信交流群
木美紫凝 发表于 2015-1-26 23:18
4个检验结果里面分别有LM和robust-LM检验的结果,我也想知道里面第一个是无固定效应的检验吗?我做的东西里 ...
我看到只有三个检验结果啊

使用道具

报纸
木美紫凝 发表于 2015-1-27 15:01:08 |只看作者 |坛友微信交流群
这是第二个模型的代码,在别的m文件里面的,可以多看看各个文件。
% ----------------------------------------------------------------------------------------
model=2;
[ywith,xwith,meanny,meannx,meanty,meantx]=demean(y,x,N,T,model);
results=ols(ywith,xwith);
vnames=strvcat('gy','logy0','logpc','gpc','emp','edu','inv','fir'); % should be changed if x is changed
prt_reg(results,vnames);
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

%moran检验
res=moran(ywith,xwith,W1);
prt(res);

使用道具

地板
lvgod 发表于 2015-1-27 16:04:00 |只看作者 |坛友微信交流群
木美紫凝 发表于 2015-1-27 15:01
这是第二个模型的代码,在别的m文件里面的,可以多看看各个文件。
% ----------------------------------- ...
你知道在哪里能看到各个地区的时间效应和各年的空间效应的估计结果吗?

使用道具

7
木美紫凝 发表于 2015-1-27 16:21:32 |只看作者 |坛友微信交流群
这个我也不清楚,各年的空间效应我是用作业文件夹下面的全国MORAN I程序进行的检验,把数据放里面计算的每一年的值。

使用道具

8
jerrybian 发表于 2015-3-10 19:05:28 |只看作者 |坛友微信交流群
木美紫凝 发表于 2015-1-27 16:21
这个我也不清楚,各年的空间效应我是用作业文件夹下面的全国MORAN I程序进行的检验,把数据放里面计算的每一 ...
您好,我最近也在做类似的课题,下了工具箱,里面没有“作业”那个文件夹,论坛里搜了搜,都要金币才能下载的,我没有金币了,您能不能给我邮箱发一份。matlab我不太会,没有实例参考我实在做不出来,谢谢你!!!

使用道具

9
一雅 发表于 2015-3-10 22:44:10 |只看作者 |坛友微信交流群
jerrybian 发表于 2015-3-10 19:05
您好,我最近也在做类似的课题,下了工具箱,里面没有“作业”那个文件夹,论坛里搜了搜,都要金币才能下 ...
谢谢你

使用道具

10
yousp 发表于 2015-4-27 12:45:12 |只看作者 |坛友微信交流群
楼主,我也遇到同样问题,不知你是否已经解决了?

使用道具

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

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

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

GMT+8, 2024-4-26 14:33