pyperfectforesight.solve_steady_state#
- pyperfectforesight.solve_steady_state(compiled_ss, params_dict, initial_guess=None, exog_ss=None)[source]#
Solve for the steady state using pre-compiled functions.
Uses the bundle produced by
compile_steady_state_funcs()so that no symbolic work is repeated. Intended for parameter sweeps where the model structure is fixed but parameter values change across calls, and for computing terminal steady states at non-zero exogenous levels.- Parameters:
compiled_ss (dict) – Bundle returned by
compile_steady_state_funcs().params_dict (dict) – Parameter values. Must contain every parameter symbol detected during compilation (i.e., every key in
compiled_ss['param_syms']).initial_guess (ndarray, optional) – Initial guess for steady-state values (default: ones vector of length
n_endo). When the model has multiple steady states or the solver struggles to converge, providing a better initial guess (e.g. a nearby known steady state) can help.exog_ss (array-like of shape (n_exo,) or dict {str: float}, optional) –
Steady-state values for the exogenous variables. Determines the long-run equilibrium at which the steady state is computed.
array-like — values in the same order as
vars_exopassed tocompile_steady_state_funcs().dict — maps exogenous variable names (strings) to their steady-state values; missing variables default to zero.
None (default) — all exogenous variables are set to zero, which is the standard assumption for deviation models.
Pass the last row of an
exog_pathhere to compute the terminal steady state implied by the long-run exogenous level:>>> ss_terminal = solve_steady_state(compiled_ss, params, exog_ss=exog_path[-1])
- Returns:
Steady-state values for each variable in
vars_dynorder, wrapped in aSteadyStateobject that records the parameter values and exogenous levels used. Transparently usable as a plain ndarray via__array__.- Return type:
- Raises:
ValueError – If
params_dictis missing a required parameter symbol, or ifexog_sscannot be converted/flattened to a 1D array of lengthn_exo.
Examples
Standard use — exogenous variables at zero (deviation model):
>>> ss = solve_steady_state(compiled_ss, params)
Permanent technology shock — compute new terminal steady state at z=1.05:
>>> compiled_ss = compile_steady_state_funcs(equations, vars_dyn, vars_exo=['z']) >>> ss_terminal = solve_steady_state(compiled_ss, params, exog_ss=np.array([1.05])) >>> result = solve_perfect_foresight( ... T, params, ss_terminal, model_funcs, vars_dyn, ... exog_path=exog_path, ss_initial=ss_initial, ... endval=ss_terminal, ... )