全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 MATLAB等数学软件专版
5140 7
2010-10-06
% PURPOSE: An example of using the fixed effects spatial panel estimation
% and spatial autocorrelation tests toolbox                        
%---------------------------------------------------
% Written by N. Debarsy* and C. Ertur**
% * University of Namur
%   Centre de recherches en Economie R間ionale et Politique Economique (CERPE)
%   Rempart de la vierge, 8
%   5000 Namur, Belgium
%   nicolas.debarsy@fundp.ac.be
%** Universit�d'Orl閍ns
%   UFR Droit-Economie-Gestion
%   Laboratoire d'Economie d'Orl閍ns - UMR 6221 CNRS
%   Domaine Universitaire
%   Rue de Blois - BP 6739
%   45067 ORLEANS Cedex 2, France
%   cem.ertur@univ-orleans.fr
% REFERENCE :
% Debarsy N, C. Ertur (2009), Testing for spatial autocorrelation in a fixed effects
% panel data model, Document de recherche du LEO, 2009-12.
% --------------------------------------------------------------------
clear all;
% Creation of data
N=81;
T=8;
x=randn(N*T,3);
b=[1;2;3];
In=eye(N);
It=eye(T);
v=randn(N*T,1);
rho=0.7;
lam=-0.5;
% Loading the spatial weight matrix
load mat81q;
W=mat81q;
clear mat81q;
A=In-rho*W;
B=In-lam*W;
Ai=inv(A);
Bi=inv(B);
% Creation of the individual fixed effects
mu=-50+100*rand(N,1);
mu=kron(ones(T,1),mu);
%Generation of the DGP
y=kron(It,Ai)*(x*b+mu)+kron(It,Ai*Bi)*v;
%Use of the tests
%Joint LM test
res=lm_f_joint(y,x,W,W,N);
prt(res)
% LM test for spatially autocorrelated errors
res1=lm_f_err(y,x,W,N);
prt(res1)
% LM test for a SAR specification
res2=lm_f_sar(y,x,W,N);
prt(res2)
% LM test for SAR specification when spatially autocorrelated errors are
% already accounted for
res3=lm_f_err_c(y,x,W,W,N);
prt(res3)
% LM test for spatially autocorrelated errors when a SAR specification is
% already accounted for
res4=lm_f_sar_c(y,x,W,W,N);
prt(res4)
%Joint LR test
res5=lr_f_joint(y,x,W,W,N);
prt(res5)
% LR test for spatially autocorrelated errors
res6=lr_f_err(y,x,W,N);
prt(res6)
% LR test for a SAR specification
res7=lr_f_sar(y,x,W,N);
prt(res7)
% LR test for SAR specification when spatially autocorrelated errors are
% already accounted for
res8=lr_f_err_c(y,x,W,W,N);
prt(res8)
% LR test for spatially autocorrelated errors when a SAR specification is
% already accounted for
res9=lr_f_sar_c(y,x,W,W,N);
prt(res9)
% Estimation of fixed effects spatial panel data models
% Variables names
vnames=strvcat('dependent','x1','x2','x3');
info.lflag=0;
% Fixed effects SEM panel data estimation
res10=sem_panel_FE_LY(y,x,W,N,info);
prt(res10,vnames);
% Fixed effects SAR panel data estimation
res11=sar_panel_FE_LY(y,x,W,N,info);
prt(res11,vnames);
% Fixed effects SARAR panel data estimation
res12=sarar_panel_FE_LY(y,x,W,W,N,info);
prt(res12,vnames);


报错信息:
??? Undefined command/function 'ols'.
Error in ==> lm_f_joint at 63
fe=ols(y,x);
Error in ==> demo at 56
res=lm_f_joint(y,x,W,W,N);
二维码

扫码加我 拉你入群

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

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

全部回复
2010-10-7 11:03:10
你应该要安装最新版的Econometrics Toolbox(updated 3/2010)
http://www.spatial-econometrics.com/
里面有很多工具箱spatial,regress,distrib,util,.....
function会相互调用,ols 就在regress里面.
要用spatial,路径最起码要加入regress,distrib,util
二维码

扫码加我 拉你入群

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

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

2010-10-7 13:58:35
你缺少下面这两个函数(function)
fe=ols(y,x);
res=lm_f_joint(y,x,W,W,N);

这两个函数应该是自己编写的,其中ols函数,即最小二乘楼上的说了Lesage的工具包中有下载,但还要注意函数输入和输出是否同你这个程序一致,否则还会出错。至于lm_f_joint函数是自定义的,估计作者会有,如果你自己能看懂整个程序,也可以自己编。

看来你用Matlab的时间不长,多花点时间就可以了。
二维码

扫码加我 拉你入群

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

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

2010-10-7 16:12:45
你下的代码是不是octave的啊 否则那就是缺乏依赖的程序包了
二维码

扫码加我 拉你入群

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

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

2010-10-7 17:00:24
3# stanleyjunjun
是的,以前学过,但只是懂点皮毛,我会努力的,谢谢!
二维码

扫码加我 拉你入群

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

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

2010-10-7 17:15:49
2# epoh
非常感谢!我去看看~~
二维码

扫码加我 拉你入群

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

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

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

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