Loop over parameters - human capital model

Dear Prof. Pfeifer,

Many thanks for your help and reply. I am still experiencing further problems. I saw Running a loop on a parameter, and I transformed the given codes in order to solve my problem:

dynare dsge_humancapital nostrict
phi = 0.1:0.1:1;
first_time = 1;
for i=1:length(phi)
if first_time
set_param_value(‘x’,phi(i));
dynare dsge_humancapital nostrict;
first_time = 0;
else
set_param_value(‘x’,phi(i));
perfect_foresight_setup;
perfect_foresight_solver;
if oo_.deterministic_simulation.status ~= 1;
disp([‘Computation fails for x =’ num2str(x)]);
end;
end
end

However, when I run the code, I get the following error:

Attempted to access phi(2); index out of bounds because numel(phi)=1.

Error in ==> proba1 at 10
set_param_value(‘x’,phi(i));

What is the difference between my code/my problem and the problem in Running a loop on a parameter ? What should I change in my code?

Many thanks in advance!!

Dóra

dsge_humancapital.mod (1.1 KB)
forum loop.m (455 Bytes)