楼主: karlier
5208 7

为什么运行此MATLAB程序报错? [推广有奖]

  • 0关注
  • 0粉丝

本科生

8%

还不是VIP/贵宾

-

威望
0
论坛币
23 个
通用积分
0
学术水平
1 点
热心指数
1 点
信用等级
0 点
经验
867 点
帖子
41
精华
0
在线时间
75 小时
注册时间
2009-12-17
最后登录
2016-6-4

楼主
karlier 发表于 2010-10-6 21:42:57 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

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

经管之家联合CDA

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

感谢您参与论坛问题回答

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

+2 论坛币
% 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);
二维码

扫码加我 拉你入群

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

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

关键词:MATLAB程序 MATLAB matla atlab Lab 运行 MATLAB 程序

沙发
epoh 发表于 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

藤椅
stanleyjunjun 发表于 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的时间不长,多花点时间就可以了。
天行健,君子自强不息!

板凳
liuxin9023 发表于 2010-10-7 16:12:45
你下的代码是不是octave的啊 否则那就是缺乏依赖的程序包了

报纸
karlier 发表于 2010-10-7 17:00:24
3# stanleyjunjun
是的,以前学过,但只是懂点皮毛,我会努力的,谢谢!

地板
karlier 发表于 2010-10-7 17:15:49
2# epoh
非常感谢!我去看看~~

7
karlier 发表于 2010-10-7 17:16:43
4# liuxin9023
我在论坛下的,不知道是不是,不是很懂唉~~

8
suli0917 发表于 2011-10-12 04:59:55
补充一下,下载了LeSage的package以后,记得set path

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

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-7 00:37