pyperfectforesight.SteadyState#

class pyperfectforesight.SteadyState(values, params=None, exog_ss=None, vars_dyn=None, vars_exo=None)[source]#

Bases: object

A steady-state solution with full provenance (params and exogenous values).

Wraps a numpy array of endogenous steady-state values and records the model parameters and exogenous variable levels at which they were computed. Transparently interoperates with numpy — a SteadyState can be passed wherever a plain ndarray is expected (endval, ss, ss_initial, etc.) without any code changes in the callers.

values#

Endogenous variable steady-state values in vars_dyn order.

Type:

ndarray, shape (n_endo,)

params#

Model parameter values (string-keyed) used to compute this steady state.

Type:

dict {str: float}

exog_ss#

Exogenous variable values at which this steady state was computed. None when the model has no exogenous variables.

Type:

ndarray of shape (n_exo,) or None

vars_dyn#

Names of the endogenous variables in the same order as values.

Type:

list of str or None

vars_exo#

Names of the exogenous variables in the same order as exog_ss.

Type:

list of str or None

Examples

solve_steady_state returns a SteadyState automatically:

>>> compiled_ss = compile_steady_state_funcs(equations, vars_dyn, vars_exo)
>>> ss = solve_steady_state(compiled_ss, params, exog_ss=np.array([1.05]))
>>> ss.values            # endogenous steady-state values
array([2.972514, 40.998601])
>>> ss.exog_ss           # exogenous level this steady state corresponds to
array([1.05])
>>> ss.params            # parameters used
{'alpha': 0.36, 'beta': 0.99, 'delta': 0.025}
>>> ss.vars_exo          # exogenous variable names
['z']

Pass directly as endval — callers see a plain array:

>>> result = solve_perfect_foresight(
...     T, params, ss_terminal, model_funcs, vars_dyn,
...     exog_path=exog_path, ss_initial=ss_initial, endval=ss_terminal,
... )

You can also construct one manually to annotate a pre-computed vector:

>>> ss = SteadyState(
...     my_ss_values, params={"alpha": 0.36, "beta": 0.99},
...     exog_ss=np.array([1.05]), vars_dyn=["c", "k"], vars_exo=["z"],
... )
__init__(values, params=None, exog_ss=None, vars_dyn=None, vars_exo=None)[source]#
Parameters:
  • values (array-like, shape (n_endo,)) – Endogenous variable steady-state values.

  • params (dict {str: float}, optional) – Model parameter values (string-keyed) used to compute this steady state. Storing these alongside the solution makes it easy to verify which calibration produced a given steady state.

  • exog_ss (array-like of shape (n_exo,), optional) – Exogenous variable values at which this steady state was computed. Pass None (default) when the model has no exogenous variables or when the exogenous level is zero by convention.

  • vars_dyn (list of str, optional) – Names of the endogenous variables in the same order as values.

  • vars_exo (list of str, optional) – Names of the exogenous variables in the same order as exog_ss.

Methods

__init__(values[, params, exog_ss, ...])

Attributes

shape

Shape of the values array, e.g. (n_endo,).

size

Total number of elements in the values array.

property shape#

Shape of the values array, e.g. (n_endo,).

property size#

Total number of elements in the values array.