MATLAB Answers

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

1 view (last 30 days)
Hi guys,
I am still a beginner with Matlab and I am trying to use the IP-VAR toolbox of Weber and Towbin ( . 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,
for i=1:lag+1
Xn(i).X = [];
for i=1:lag+1
for j=1:I
for nx=1:Kx
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)];
% --> 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)];
if i==lag+1
Xh=[ydata(i+(j-1)*time:j*time-lag-1+i,nx) Xh];
Xh=[xdata(i+(j-1)*time:j*time-lag-1+i,nx) Xh];
X=[X Xh];
Xhelp(j).X(:,:) = X;
Xn(i).X = [Xn(i).X
clear X
XX(i).X = Xn(i).X;
clear Xhelp(j).X Xn(i).X
% added to include interaction
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
clear Idatah
% Create intercept
X = ones(size(XX(1).X,1),1);
% Create intercept interactions
for nint=1:Ki
Xinter=[Xinter X.*Idata2(:,nint)]; % added to include interaction
X=[X Xinter]; % added to include interaction
%don't include constant (for fixed effects)
% 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];


Sign in to comment.

Accepted Answer

Stephen Cobeldick
Stephen Cobeldick on 22 May 2020
Edited: Stephen Cobeldick on 22 May 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 Comment

Kiethan Vijayabalan
Kiethan Vijayabalan on 8 Jun 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

Sign in to comment.

More Answers (0)

Translated by