楼主: a314072619
4316 5

[空间经济学] 急,matlab做空间计量,出现了未定义normw,求教 [推广有奖]

  • 0关注
  • 0粉丝

初中生

90%

还不是VIP/贵宾

-

威望
0
论坛币
495 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
118 点
帖子
7
精华
0
在线时间
33 小时
注册时间
2016-9-22
最后登录
2019-2-21

100论坛币
能不能帮我看看  我的结果是未定义函数或变量 'normw'。怎么做才好?
load pc.mat;
load w1.mat;
% 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=14; % number of time periods
N=11; % number of regions
% row-normalize W
W=normw(w1); % function of LeSage
y=consume(:,1); % column number in the data matrix that corresponds to the dependent variable
x=consume(:,[2,3]); % 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','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,~,~]=demean(y,x,N,T,model);
results=ols(ywith,xwith);
vnames=strvcat('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=strvcat('logcit','logp','logpn','logy'); % should be changed if x is changed
prt_reg(results,vnames);
LMsarsem_panel(results,W,ywith,xwith); % (Robust) LM tests

关键词:MATLAB matla atlab Norm 空间计量
沙发
潇夏 发表于 2019-2-22 10:14:51 |只看作者 |坛友微信交流群
你好,请教一下,你“未定义函数或变量 'normw'”这个问题是怎么解决的?

使用道具

藤椅
Hallow~影枫 学生认证  发表于 2019-4-23 19:23:33 |只看作者 |坛友微信交流群
下载normw函数即可,lesage工具包里有

使用道具

板凳
誉满天下. 发表于 2019-5-25 18:47:29 |只看作者 |坛友微信交流群
Hallow~影枫 发表于 2019-4-23 19:23
下载normw函数即可,lesage工具包里有
请教大神,安装 lesage外部命令包后,又显示未定义函数或变量 'lmlag_panel'怎么办呀

使用道具

报纸
appliedstatist 发表于 2019-12-24 15:52:40 |只看作者 |坛友微信交流群
Hallow~影枫 发表于 2019-4-23 19:23
下载normw函数即可,lesage工具包里有
您好!下载了你说的包,还是报错,可否交流下

使用道具

地板
eve依凡 发表于 2021-7-8 19:50:37 |只看作者 |坛友微信交流群
我也是同样错误,后来又在results那一步出错

使用道具

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

本版微信群
加JingGuanBbs
拉您进交流群

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

GMT+8, 2024-4-26 21:20