I have a simple model with neither forward nor backward-looking variables.
I have one exogenous shock, whose value I’d like to specify and then solve for a deterministic transition path.
I use

I keep getting the warning:
“”"
Index in position 2 is invalid. Array indices must be positive integers or logical values.
“”"
Appearantly the error occurs in:
“”"
Error in sim1_purely_backward (line 42)
yb = endogenousvariables(:,it-1); % Values at previous period, also used as guess value for current period
“”"
And I can’t figure out why.
Following advice on this forum, I am not specifying values for period 0, since I don’t have lagged variables.
Is there something similar for the case of not having forward-looking variables?

Dear Professor Pfeifer,
thank you very much for your quick reply.
I include a minimal example that replicates the error (mod file attached as well).

% declare variables and parameters
var
Y
;
varexo
A
;
parameters
alpha
;
% define the model
model;
Y = A;
end;
% set parameter values
alpha = 0.3;
% set initial values
initval(all_values_required);
A = 1;
Y = 1;
end;
% look at residual and compute steady state
resid;
steady;
% now I want to set a sequence of A's
% initial value
initval;
A=1;
end;
% define value for a specified number of periods
shocks;
var A;
periods 1:4;
values 2.0;
end;
% define value in the end
endval;
A=1;
end;
% compute a perfect foresight path
perfect_foresight_setup(periods=4);
perfect_foresight_solver;

Thank you very much for your help and many greetings minimal_example.mod (645 Bytes)

Dear Professor Pfeifer,
thank you very much for your quick reply!
I have version 4.6.3.
I will upgrade and see what happens.
Thank you very much and many greetings

thank you very much for your help.
Since I shied away from building from source, I found a hack that does the job :
Introducing a (needless) variable that is forward-looking, e.g.

% expected value for Y in the next period
EYnext = Y(+1);

fixes the problem =).
Therefore I conjecture the problem was indeed related to having no forward-looking variable.
Thank you very much and many greetings.