pyperfectforesight.make_initial_guess#
- pyperfectforesight.make_initial_guess(T, ss_initial, ss_terminal, method='linear', decay=0.9)[source]#
Generate an initial guess path for the perfect foresight solver.
Replicates the spirit of Dynare’s
perfect_foresight_setuppath initialisation and adds an exponential option that better matches the saddle-path dynamics typical of DSGE models.- Parameters:
T (int) – Number of periods (rows of the returned array).
ss_initial (array-like, shape (n,)) – Starting values — typically the initial steady state or the period-0 values you expect the path to begin near.
ss_terminal (array-like, shape (n,)) – Terminal values — typically the terminal steady state
ss.method ({'linear', 'exponential', 'constant'}, default 'linear') –
How to interpolate between
ss_initialandss_terminal:'linear'— evenly spaced fromss_initial(t=0) toss_terminal(t=T-1). Matches Dynare’s defaultperfect_foresight_setupbehaviour when bothinitvalandendvalare supplied.'exponential'— geometric convergencex(t) = ss_terminal + (ss_initial - ss_terminal) * decay**t. The path closes most of the gap in early periods and flattens nearss_terminal, mimicking saddle-path dynamics. The gap never reaches exactly zero; usedecayto control the speed.'constant'—ss_terminalrepeated for all periods. Equivalent tonp.tile(ss_terminal, (T, 1)).
decay (float, default 0.9) – Decay rate for
method='exponential'. Must be in(0, 1). Smaller values converge faster (e.g.0.5closes half the gap each period); values near 1 converge slowly and approach linear. Ignored for other methods.
- Returns:
X0 – Initial guess array, ready to pass as
X0tosolve_perfect_foresightorsolve_perfect_foresight_expectation_errors.- Return type:
ndarray, shape (T, n)
Examples
Linear interpolation (Dynare default):
>>> X0 = make_initial_guess(T, ss_initial=ss, ss_terminal=ss_new)
Exponential interpolation with faster convergence:
>>> X0 = make_initial_guess(T, ss_initial=ss, ss_terminal=ss_new, ... method='exponential', decay=0.85)