Fix bugs in perfect foresight in master
The ramst_augmented_histval.mod
in #1140 crashes. The mod-file itself takes the ramst.mod
and adds an autonomous deterministic AR(2)-process. For that reason, i) the solution for capital and consumption should be identical to the mod-file without the AR(2)-process and ii) the decay of the AR(2)-process should be correctly computed. Both is not the case.
There are at least three separate problems as far as I can see:
-
The translation from
initval
andhistval
into a one-lag problem inmake_y_
seems to be wrong. In the originalramst.mod
the first column ofoo_.endo_simul
is1.53; 12.76
, coinciding with theinitval
block. In the augmented file, we enter theelse % the first NaNs take care of the case where there are lags > 1 on % exogenous variables oo_.endo_simul = [M_.endo_histval ... oo_.steady_state*ones(1,options_.periods+M_.maximum_lead)];
part. Thus, the first column is initialized purely on the basis of the histval-block, ignoring the initval part, which here is stored in oo_.steady_state.
-
This example shows that the first lag of a variable can be set by both
initval
andhistval
and we never specify or document which one takes precedence. -
Because of error 1) the mod-file enters the homotopy step in
perfect_foresight_solver
. That is where another bug occurs. The updating inoo_.endo_simul(:,[initperiods, lastperiods]) = ... new_weight*oo_.endo_simul(:,[initperiods, lastperiods])+(1-new_weight)*endoinit(:,[initperiods, lastperiods]);
must be incorrect, because upon convergence, the initial values in the first column of
oo_.endo_simul
differ from what was specified. In particular, the 2 has becomes a 1.5.