gEconpy.model.model.Model#

class gEconpy.model.model.Model(variables, shocks, equations, steady_state_relationships, steady_state_equations, ss_solution_dict, param_dict, hyper_param_dict, deterministic_dict, calib_dict, priors, is_linear=False, mode=None, error_func='squared')#

A Dynamic Stochastic General Equilibrium (DSGE) Model.

Stores model primitives (variables, parameters, shocks, equations) and compiles steady-state and linearization functions lazily on first use. Construction accepts raw sympy objects; all graph building and pytensor compilation is deferred to the point of use so that only the graphs actually needed are ever built.

Methods

Model.__init__(variables, shocks, equations, ...)

Initialize a DSGE model from sympy primitives.

Model.equation_tensors([filter_known])

Pytensor graphs for the model's steady-state equations.

Model.evaluate_residual(ss_dict, param_dict)

Evaluate the steady-state residual at given variable and parameter values.

Model.get(name)

Get a model variable or parameter by name.

Model.linearize_model([order, ...])

Linearize the model around the deterministic steady state.

Model.param_tensors([include_free, ...])

Pytensor scalar variables for the model's parameters.

Model.parameters(**updates)

Compute the full set of free parameters for the model, including deterministic parameters.

Model.solve_model([solver, log_linearize, ...])

Solve for the linear approximation to the policy function via perturbation.

Model.ss_tensors([filter_known])

Pytensor scalar variables for the model's steady-state symbols.

Model.steady_state([how, use_jac, use_hess, ...])

Solve for the deterministic steady state of the DSGE model.

Model.symbolic_linearization([order, ...])

Return the symbolic pytensor graphs for the linearized Jacobian matrices.

Attributes

backward_variables

Variables that appear at t-1 in at least one equation (state variables).

calibrated_params

List of calibrated parameters in the model, stored as sympy.Symbol objects.

deterministic_params

List of deterministic parameters in the model, stored as sympy.Symbol objects.

dr_order

Decision-rule order classifying variables and equations into block-triangular form.

eq_order

Row permutation reordering equations as [static | lag_only | lead_only | both].

equations

List of equations in the model, stored as Sympy expressions.

f_params

Compiled function mapping free parameter values to the full parameter dictionary.

f_ss

Compiled function mapping parameters to known steady-state values, or None if no analytical solutions.

forward_variables

Forward-looking (jump) variables.

hyper_params

List of hyperparameters in the model, stored as sympy.Symbol objects.

inv_eq_order

Inverse of eq_order.

inv_var_order

Inverse of var_order.

lead_var_idx

Column indices of forward-looking variables in the Jacobian matrices.

n_backward

Number of backward-looking (state) variables.

n_forward

Number of forward-looking (jump) variables.

n_symbolic_forward

n_variables

Number of endogenous variables in the model.

param_priors

Dictionary of prior distributions for the model parameters.

params

List of parameters in the model, stored as sympy.Symbol objects.

shock_priors

Dictionary of prior distributions for the model shocks.

shocks

List of shocks in the model, stored as Sympy symbols.

steady_state_relationships

List of model equations, evaluated at the deterministic steady state.

symbolic_forward_variables

Variables appearing at t+1 in any equation (purely syntactic).

sympy_to_pytensor_cache

Cache mapping sympy symbol identifiers to pytensor graph nodes.

var_order

Column permutation reordering variables as [static | pred_only | mixed | forward_only].

variables

List of variables in the model, stored as Sympy symbols.