error Undefined operator '.*' for input arguments of type 'table'.

2 vues (au cours des 30 derniers jours)
Kiethan Vijayabalan
Kiethan Vijayabalan le 22 Mai 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

Réponse acceptée

Stephen23
Stephen23 le 22 Mai 2020
Modifié(e) : Stephen23 le 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):
  • () parentheses refer to the container array itself.
  • {} curly braces refer to the contents of the container array.
  1 commentaire
Kiethan Vijayabalan
Kiethan Vijayabalan le 8 Juin 2020
Hi Stephen,
My apologies for this utterly late reply. I did not think that my question would be answered this swiftly!
Thanks for taking the time and making the effort to assist me!
So in the end I found out that the mistake was in the way I imported the excel data into Matlab. It should have been a matrix, but it was imported as a table. Luckily that is fixed right now!
However, I am completely stuck on something else with the toolbox ( mostly questions related to pre-and post- estimation of the IP-VAR).
Do you maybe have experience with the toolbox, or are you aware of any posts about the IP-VAR toolbox of Weber and Towbin?
Kind regards,
Kiethan Vijayabalan

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by