cge_modeling.base.cge.CGEModel.__init__#
- CGEModel.__init__(coords=None, variables=None, parameters=None, equations=None, numeraire=None, parse_equations_to_sympy=True)#
Main interface for interacting with the a CGE model.
- Parameters:
- coords: dict[str, Sequence[str]]
A dictionary of dimension names and labels associated with each dimension. For example, if certain objects in the model are indexed by “sector”, then coords should contain a key “sector” with a list of sector labels as values: {“sector”: [“Agriculture”, “Industry”, “Service”]}.
- variables: list of Variables
A list of endogenous variables associated with the model. These will be solved for during simulation.
- parameters: list of Parameters
A list of parameters associated with the model. These are fixed during simulation. Note that exogenous variables should be included as parameters.
- equations: list of Equations
A list of equations associated with the model. These define relationships between the variables and parameters.
- numeraire: Variable, optional
The numéraire variable. If supplied, the numéraire will be removed from the model, and all instances of the numéraire in model equations will be set to 1. NOTE: It is not currently recommended to use this feature. Instead, add an equation to the model
fixing the numéraire variable to 1.
- parse_equations_to_sympy: bool, default
If True, the equations will be parsed to sympy expressions. This is required for the model to be compiled to the “numba” backend. If False, the equations will be converted to symbolic pytensor expressions. This is required for the model to be compiled to the “pytensor” backend. Defaults to True.
Notes
Computable General Equilibrium models are used to study the change in economic equilibria following shifts in model parameters. The purpose of this class is to provide an organized framework for declaring and studying this class of models.
At it’s most basic, a CGE model is comprised of three types of objects: variables, parameters, and equations. Each of these should declared separately using the appropriate object type. For example, to declare a variable, use the Variable class. Distinction between variables and parameters is enforced to check that the model is square (there are as many equations as there are variables), and to determine which objects to solve for during simulation.
Another important job of a model is to hold information about the dimensions of the model. Variables and parameters are declared with abstract indices, called dims. This is meant to match the notation used in the literature. For example, a variable representing the demand for capital in sector i would be written as ..math :: K_{d,i}. To represent this in a CGE model, we would declare a Variable with name “K_d” and dims “i”. The dims on the Variable are arbitrary, but become concrete when placed in the context of a model. Therefore, the model must be supplied with a dictionary of dimension names and labels, called “coordinates” in packages for multi-dimensional array handing (e.g. xArray). For example, if the model will recieve data with dimension i, then the coords dictionary should provide a mapping from “i” to a list of labels for the dimension i. For example, {“i”: [“Agriculture”, “Industry”, “Service”]}.
When considering the “squareness” of a model, the “unpacked” dimensions of the variables and equations are considered. Therefore, it may not be the case that the number of variables declared is equal to the number of equations declared.