- () 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'.
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Stephen23
2020-5-22
编辑:Stephen23
2020-5-22
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):
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!