cge_modeling.base.cge.CGEModel.generate_SAM#
- CGEModel.generate_SAM(param_dict, initial_variable_guess, solve_method='root', fixed_values=None, use_jac=True, use_hess=True, n_steps=100, **solver_kwargs)#
Generate a Social Accounting Matrix (SAM) from the model parameters.
- Parameters:
- param_dict: dict[str, np.ndarray]
A dictionary of parameter values. The keys should be the names of the parameters, and the values should be numpy arrays of the same shape as the parameter.
- initial_variable_guess: dict[str, np.ndarray]
A dictionary of initial values for the model variables. The keys should be the names of the variables, and the values should be numpy arrays of the same shape as the variable.
- fixed_values: dict[str, np.ndarray], optional
A dictionary of exact values for a subset of model variables. The keys should be the names of the variables to be changed, and the values should be numpy arrays of the same shape as the variable.
- solve_method: str
The method to use to solve the model. One of ‘root’, ‘minimize’, or ‘euler’. Defaults to ‘root’.
Note that Euler is not recommended for generating a SAM, because it assumes the initial point is itself a SAM (in which case you don’t need this function). It is included for testing purposes only.
- use_jac: bool
Whether to use the Jacobian of the system of equations when solving with the root or minimize methods. Defaults to True.
- use_hess: bool
Whether to use the Hessian of the loss function when solving with the minimize method. Ignored if method is not ‘minimize’. Defaults to True.
- n_steps: int
The number of steps to use when solving with the Euler method. Ignored if method is not ‘euler’. Defaults to 100.
- **solver_kwargs: dict
Additional keyword arguments to pass to the solver, either scipy.optimize.root or scipy.optimize.minimize, depending on the chosen method. See those docstrings for details.
- Returns:
- variable_dict:
dict[str,np.ndarray] A dictionary of variable values. The keys are the names of the variables, and the values are numpy arrays of the same shape as the variable.
- variable_dict:
Notes
This function generates a “SAM” by solving for the values of the model variables that are implied by the provided parameter values. This mapping is valid by construction, because the structure of a correctly specified CGE model will ensure all markets clear, resulting in a closed system of economic transactions between model agents.
Initial variables need to be provided in order to pin down the level of the economy. In general, an infinite number of solutions exist for a given set of parameter values. What is returned is just one solution, which is close to the provided initial values.