- () parentheses refer to the container array itself.
- {} curly braces refer to the contents of the container array.
error Undefined operator '.*' for input arguments of type 'table'.
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Kiethan Vijayabalan
am 22 Mai 2020
Kommentiert: Kiethan Vijayabalan
am 8 Jun. 2020
Hi guys,
I am still a beginner with Matlab and I am trying to use the IP-VAR toolbox of Weber and Towbin ( http://sebastianweber.weebly.com/codes.html) . Unfortunatly I am running into an error when I am estimating my InteractPvar. The error indicates " error Undefined operator '.*' for input arguments of type 'table'. "
Does anyone know what is happening here? I have indicated the line with the Error below.
Many thanks in advance!
Kind regards,
Kiethan
%-----------------------------------------------------------------------------------------------------
% CREATE REGRESSORS
%----------------------------------------------------------------------------------------------------
for i=1:lag+1
Xn(i).X = [];
end
for i=1:lag+1
for j=1:I
X=[];
for nx=1:Kx
Xh=[];
for nint=1:Ki
start = 1+lag+(j-1)*time;
ende = j*time;
if i==lag+1
Xh=[Xh ydata(i+(j-1)*time:j*time-lag-1+i,nx).*Idata(start:ende,nint)];
else
% --> this is the line with the error according to Matlab --> Xh=[Xh xdata(i+(j-1)*time:j*time-lag-1+i,nx).*Idata(start:ende,nint)];
end
end
if i==lag+1
Xh=[ydata(i+(j-1)*time:j*time-lag-1+i,nx) Xh];
else
Xh=[xdata(i+(j-1)*time:j*time-lag-1+i,nx) Xh];
end
X=[X Xh];
end
Xhelp(j).X(:,:) = X;
Xn(i).X = [Xn(i).X
Xhelp(j).X];
clear X
end
XX(i).X = Xn(i).X;
clear Xhelp(j).X Xn(i).X
end
% added to include interaction
Idata2=[];
for i=1:I
start = (i-1)*time;
ende = i*time;
Idatah = Idata(1+lag+start:ende,:); % Idata(1+lag+(j-1)*time:j*time,:) for time t;
Idata2= [Idata2
Idatah];
clear Idatah
end
% Create intercept
X = ones(size(XX(1).X,1),1);
% Create intercept interactions
Xinter=[];
for nint=1:Ki
Xinter=[Xinter X.*Idata2(:,nint)]; % added to include interaction
end
X=[X Xinter]; % added to include interaction
%don't include constant (for fixed effects)
%X=[Xinter];
% Create Regressors (NOTE: THE ORDER IS REVERSED, i.e. XX(2).X is the first
% lag in a PVAR(2) and XX(1).X is the second lag!!)
for i=1:lag+1
X = [XX(i).X X];
end
0 Kommentare
Akzeptierte Antwort
Stephen23
am 22 Mai 2020
Bearbeitet: Stephen23
am 22 Mai 2020
The problem is very simple: you are using the wrong type of indexing: instead of () you should be using {} to access the contents of tables. This is explained in the MATLAB documentation:
The rule is the same for container arrays (e.g. cell, string, table):
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Tables finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!