Reference to non-existent field 'rsqr'.

1 view (last 30 days)
Henok Fasil Telila
Henok Fasil Telila on 21 Jun 2019
Edited: Henok Fasil Telila on 26 Jun 2019
The error is
Dynamic sar model with spatial fixed effects
Reference to non-existent field 'rsqr'.
Error in prt_sardynamic (line 77)
fprintf(fid,'R-squared = %9.4f \n',results.rsqr);
I'm estimating a dynamic spatial panel model. In case, the necessary files are all attached including scripts.
% PURPOSE: An example of using sar_jihai_time
ylevelb=xlsread('C:\Users\Desktop\dynamic\Y (in niveaus minus item 6).xls'); % minus item 6
x=xlsread('C:\Users\Desktop\dynamic\X.xls');
WA=xlsread('C:\Users\Desktop\dynamic\Weights matrix (distance capitals).xls');
W = normw(WA);
n = 62;
t = 30;
%info = struct('n','t','rmin','rmax','lflag','tl','stl','ted'); %ted=1 or ted=2
info = struct('n',n,'t',t,'rmin',0,'rmax',1,'lflag',0,'tl',1,'stl',1,'ted',1); %ted=1 or ted=2
%vnames = strvcat('y','const','x1','x2');
%vnames = strvcat('BANK','CUR','DEBT','RECESSION','HINFL','FIRSTYEAR','IMF','USINT','LEFT','RIGHT','DEMO','GOVFRAC');
%vnames1=strvcat('FL(t)','FL(t-1)','W*FL(t-1)','BANK','CUR','DEBT','RECESSION','HINFL');
%vnames2=strvcat('FL(t)','FL(t-1)','W*FL(t-1)','BANK','CUR','DEBT','RECESSION','HINFL','FIRSTYEAR','IMF');
%vnames3=strvcat('FL(t)','FL(t-1)','W*FL(t-1)','BANK','CUR','DEBT','RECESSION','HINFL',...
% 'FIRSTYEAR','IMF','LEFT','RIGHT','DEMO','GOVFRAC');
%vnames=vnames3;
fid=1;
T=30;
N=62;
%WC=zeros(N,N);
%for i=1:N
% if (WCC(i,2)~=0 ) WC(i,WCC(i,2))=1; end
% if (WCC(i,3)~=0 ) WC(i,WCC(i,3))=1; end
%end
%WC=normw(WC);
%Winvdist=1./Wdist;
%for i=1:N
% Winvdist(i,i)=0;
% Wdist(i,i)=0;
%end
%Wtwee=normw(Winvdist^2);
%
% Choice of model
%
% Choose one of the two dependent variables
%ylevel=ylevela;fprintf(1,'Y alle items \n');
ylevel=ylevelb;fprintf(1,'Y minus item 6 \n');
ylevel=100*ylevel;
% Choose one of the W matrices
W=WA;fprintf(1,'W obv distance capitals \n');p=eig(W);eigmax=p(2);peig=1;
%W=Wtwee;fprintf(1,'W obv distance capitals squared\n');p=eig(W);eigmax=p(2);peig=1;
%W=WB;fprintf(1,'W obv bilateral trade flows \n');p=eig(W);eigmax=p(3);peig=1;
%W=WC;fprintf(1,'W obv regionals leaders \n');p=eig(W);eigmax=0;peig=1;
%W=WA5;fprintf(1,'W obv distance capitals < 5,000 km\n');p=eig(W);eigmax=max(p);
%W=WA10;fprintf(1,'W obv distance capitals < 10,000 km\n');p=eig(W);eigmax=max(p);
%W=WA15;fprintf(1,'W obv distance capitals < 15,000 km\n');p=eig(W);eigmax=max(p);
% Choose one of the different sets of control variables
x1=x(:,1:5);
x2=x(:,1:7);
x3=x(:,[1:7,9:12]);
vnames1=strvcat('FL(t)','FL(t-1)','W*FL(t-1)','BANK','CUR','DEBT','RECESSION','HINFL');
vnames2=strvcat('FL(t)','FL(t-1)','W*FL(t-1)','BANK','CUR','DEBT','RECESSION','HINFL','FIRSTYEAR','IMF');
vnames3=strvcat('FL(t)','FL(t-1)','W*FL(t-1)','BANK','CUR','DEBT','RECESSION','HINFL',...
'FIRSTYEAR','IMF','LEFT','RIGHT','DEMO','GOVFRAC');
%x=x1;vnames=vnames1;fprintf(1,'x var 1-5 \n');
%x=x2;vnames=vnames2;fprintf(1,'x var 1-7 \n');
x=x3;vnames=vnames3;fprintf(1,'x var 1-7 + 9-12 \n');
%
% End choice of model
%
for t=1:T+1
t1=1+(t-1)*N;t2=t*N;
Wylevel(t1:t2,1)=W*ylevel(t1:t2,1);
end
y=ylevel(N+1:end)-ylevel(1:end-N);
%
results=sar_jihai(y(1:end),[x(N+1:end,:) x(1:end-N,:)],W,info);
prt_sardynamic(results,vnames,fid)
Any help is appreciated. The excel file is also attached in this link.spatial-panels

Answers (1)

KALYAN ACHARJYA
KALYAN ACHARJYA on 21 Jun 2019
Edited: KALYAN ACHARJYA on 21 Jun 2019
All custom functions files should be save individually in different matlab files, also file names should be same as functions name.
After saving, call the functions in main script.
function results=sar_jihai_time(y,x,W,info);
%....................^^^... Function name
Read here
  1 Comment
Henok Fasil Telila
Henok Fasil Telila on 24 Jun 2019
Edited: Henok Fasil Telila on 26 Jun 2019
Dear @KALYAN ACHARJYA, Based on that, I have reorganized the question, please revise it again for my new error.

Sign in to comment.

Categories

Find more on MATLAB in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!