Not enough input arguments ==> if isinteger(x)

Dear everyone!

I am comparing two models and I get the following error:
Not enough input arguments.

Error in var (line 73)

if isinteger(x)

Error in compa_4 (line 21)

for jj=1:length(var)

My code is:
dynare thesimy.mod;
irf1 = oo_.irfs;
save thesimy.mat irf1;
dynare thesimy2.mod;
irf2 = oo_.irfs;
save thesimy2.mat irf2;
load(‘thesimy.mat’,‘irf1’);
load(‘thesimy2.mat’,‘irf2’);
ending_cell={’_eps_a’,’_eps_r’,’_eps_g’,‘eps_tau’};
%‘Hiato do produto’, ‘Inflação Doméstico’, ‘Consumo Doméstico’,
%‘PIB’,‘Inflação IP’,‘Termo de Troca’, ‘Salário Real’, ‘Horas de
%Trabalho’,‘Dívida’,‘Câmbio Nominal’,‘Balanço Comercial’,‘Taxa de Juros Real’
for ii=1:length(ending_cell)
HOR=1:options
.irf;
var_titles = {‘Hiato do produto’, ‘Inflação Doméstico’, ‘Consumo Doméstico’, ‘PIB’, ‘Inflação IPC’, ‘Termo de Troca’, ‘Salário Real’, ‘Horas de Trabalho’,‘Dívida’, ‘Câmbio Nominal’,‘Balanço Comercial’,‘Taxa de Juros Real’};
figure
for jj=1:length(var)
subplot(4,4,jj)
eval([‘irf1.’ var{1,jj},ending_cell{1,ii}]);
eval([‘irf2.’ var{1,jj},ending_cell{1,ii}]);
hold on
plot(HOR,[eval([‘irf1.’ var{1,jj},ending_cell{1,ii}])],’-k’,HOR,[eval([‘irf2.’ var{1,jj},ending_cell{1,ii}])],’–r’,‘LineWidth’,2);
title([var_titles{1,jj}] )
end
legend(‘Modelo com HP’, ‘Modelo com TC’, ‘AutoUpdate’,‘off’)
end

Var is a function and var_titles is a variable.

When I put some variables (a small number of variables, 5 variables for example) in var_titles (1, 2, …5), the model executes normally without any problem. But when I put a lot of variables (12 variables for example ) in var_titles(1, 2, 3 …12), the model shows the above problem.

Thank you for helping to resolve the issue.

Without the full files it is impossible to tell.

1 Like

Thank you very much Professor.
Here is the full files.
thesimyp1.mod (5.0 KB)
thesimyp2.mod (5.0 KB)
compa_4.m (1.2 KB)

You did not define any variables for var, so Matlab thinks it is the command for computing the variance.

1 Like

Dear Professor!

I tried to create a scalar structure to resolve the ‘‘var’’ problem.

I received the following error:

Error using copyfile

Cannot write to destination: C:\Users\abdel\Documents. Use the ‘f’ option to override.

Error in testcom (line 12)

copyfile(‘S1.mat’,‘S3.mat’)

Please take a look at what I did.

dynare thesimyp1.mod;

irf1 = oo_.irfs;

S1 = ‘thesimyp1’;

save S1.mat S1

dynare thesimyp2.mod;

irf2 = oo_.irfs;

S2 = ‘thesimyp2’;

save S2.mat S2

copyfile(‘S1.mat’,‘S3.mat’)

S = load(‘S2.mat’);

save(‘S3.mat’,’-struct’,‘S’,’-append’)

ending_cell={’_eps_a’,’_eps_r’,’_eps_g’,’_eps_tau’};

%‘Hiato do produto’, ‘Inflação Doméstico’, ‘Consumo Doméstico’,

%‘PIB’,‘Inflação IP’,‘Termo de Troca’, ‘Salário Real’, 'Horas de

%Trabalho’,‘Dívida’,‘Câmbio Nominal’,‘Balanço Comercial’,‘Taxa de Juros Real’

for ii=1:length(ending_cell)

HOR=1:options_.irf;

var_titles = {‘Hiato do produto’, ‘Inflação Doméstico’, ‘Consumo Doméstico’, ‘PIB’, ‘Inflação IPC’, ‘Termo de Troca’, ‘Salário Real’, ‘Horas de Trabalho’,‘Dívida’, ‘Câmbio Nominal’,‘Balanço Comercial’,‘Taxa de Juros Real’};

figure

for jj=1:length(S)

subplot(3,3,jj)

irf1.([S{1,jj},ending_cell{1,ii}]);

irf2.([S{1,jj},ending_cell{1,ii}]);

hold on

plot(HOR,[([‘irf1.’ S{1,jj},ending_cell{1,ii}])],’-k’,HOR,[([‘irf2.’ S{1,jj},ending_cell{1,ii}])],’–r’,‘LineWidth’,2);

title([var_titles{1,jj}])

end

legend(‘Modelo com HP’, ‘Modelo com TC’, ‘AutoUpdate’,‘off’)

end

Professor, my objective is to do a similar figure.

I appreciate any kind of help.

Best regard,

Hi Mohamed,

you asked this question before and I send you code that does just that, why not just ask there if something is unclear? (Subplot construction - #2 by DoubleBass)
It should do just what you are trying to achieve, what is the exact problem?

In the code you linked above, as is also explained in the pseudo code I linked,

var = {}

contains the variables with the names you gave them in Dynare, not how you want them to be called afterwards. This is how Matlab evaluates them when you use

eval([‘irf1.’ var{1,jj},ending_cell{1,ii}])

Just look at the structures you create in irf1 for each variable. This is exactly what jpfeifer meant when he said that you did not define any variables for var. Hope this helps, otherwise just feel free to ask.

Best

1 Like

Dear @DoubleBass!
Thank you very much for your reply.
When I try to do with exact variable names inserted in the Dynare, I get the following error:

<< Error using plot
Vectors must be the same length.
Error in compa_4 (line 26)
plot(HOR,[eval([‘irf1.’ var{1,jj},ending_cell{1,ii}])],’-k’,HOR,[eval([‘irf2.’ var{1,jj},ending_cell{1,ii}])],’–r’,‘LineWidth’,2); >>

My code is:

dynare thesimyp1.mod;
irf1 = oo_.irfs;
save thesimyp1.mat irf1;

dynare thesimyp2.mod;
irf2 = oo_.irfs;
save thesimyp2.mat irf2;

load(‘thesimyp1.mat’,‘irf1’);
load(‘thesimyp2.mat’,‘irf2’);

ending_cell={’_eps_a’,’_eps_r’,’_eps_g’,’_eps_tau’};

%‘ytil’, ‘pid’, ‘c’,‘ybreve’,‘pi’,‘h’, ‘real_wage’, ‘l’,‘b’,‘e’,‘bc’,‘rr’

for ii=1:length(ending_cell)
HOR=1:options_.irf;
var = {‘ytil’, ‘pid’, ‘c’,‘ybreve’,‘pi’,‘h’, ‘real_wage’, ‘l’,‘b’,‘e’,‘bc’,‘rr’};
figure
for jj=1:length(var)
subplot(3,3,jj)
eval([‘irf1.’ var{1,jj},ending_cell{1,ii}]);
eval([‘irf2.’ var{1,jj},ending_cell{1,ii}]);
hold on
plot(HOR,[eval([‘irf1.’ var{1,jj},ending_cell{1,ii}])],’-k’,HOR,[eval([‘irf2.’ var{1,jj},ending_cell{1,ii}])],’–r’,‘LineWidth’,2);
title([var{1,jj}] )
end

legend('modelo hp', 'modelo tc', 'AutoUpdate','off')

end

Best regard,

When I put some variables (a small number of variables, 5 variables for example) in var_titles (1, 2, … 5), the model runs normally without any problems. Either with the proper names of the variables or with any other names that I want the variables to be called.

But when I put many variables (12 variables, for example) in var_titles (1, 2, 3… 12), the model shows the following problem:

Not enough input arguments.
Error in var (line 73)
if isinteger(x)
Error in compa_4 (line 21)
for jj=1:length(var)

Note that in this case, the names of the variables are different from the original names of the variables.

When I put a large number of variables using ‘’ var ‘’, with the proper names variables, I get the following error:

Error using plot
Vectors must be the same length.
Error in compa_4 (line 26)
plot(HOR,[eval([‘irf1.’ var{1,jj},ending_cell{1,ii}])],’-k’,HOR,[eval([‘irf2.’ var{1,jj},ending_cell{1,ii}])],’–r’,‘LineWidth’,2);

Hi Mohamed,

you have to put the same length of your IRF’s in stoch_simul(). This is what causes the problems, in thesimyp1.mod it was irf=10 and in thesimyp1.mod it was irf=20.
For it works after adjusting this.

Best

1 Like

Dear @DoubleBass!
My model worked well. Thank you very much for your help.