gcubed.projections.gcubed_functions

def generate_itc_decay_factors( projection_years_count: int, itc_decay_rate: float) -> numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]]:

Generates the intertemporal constant decay factors for each projection year.

Arguments

  • projection_years_count: The number of projection years.
  • itc_decay_rate: The decay rate to apply to the intertemporal constants in each projection year.

Returns

A vector of decay factors, one for each projection year.

def first_year_projections_of_target_variables( projection_years_count: int, exogenous_projections: numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]], yxr_initial_values: numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]], parameters: gcubed.projections.gcubed_parameters.GCubedParameters, x1_intertemporal_constants: numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]], j1_intertemporal_constants: numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]], ze_intertemporal_constants: numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]], z1_intertemporal_constants: numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]]) -> numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]]:

Overview

Generates the projections for the target variables in the first projection year.

This is used to generate the baseline projections required in the calculation of the Jacobian matrix for the intertemporal constants.

Arguments

  • projection_years_count: The number of projection years.
  • exogenous_projections: The matrix of exogenous variable projections.
  • yxr_initial_values: The initial values of the YXR variables.
  • parameters: The GCubedParameters object containing all model parameters.
  • x1_intertemporal_constants a row for each X1 variable and a column for each intertemporal constant.
  • j1_intertemporal_constants a row for each J1 variable and a column for each intertemporal constant.
  • ze_intertemporal_constants a row for each ZE variable and a column for each intertemporal constant.
  • z1_intertemporal_constants a row for each Z1 variable and a column for each intertemporal constant.

Returns

A vector containing the first year projections of the target variables.

def first_year_projections_of_all_variables( projection_years_count: int, exogenous_projections: numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]], yxr_initial_values: numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]], parameters: gcubed.projections.gcubed_parameters.GCubedParameters, x1_intertemporal_constants: numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]], j1_intertemporal_constants: numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]], ze_intertemporal_constants: numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]], z1_intertemporal_constants: numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]]) -> (numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]], numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]], numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]], numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]]):

Overview

Generates the projections for all 4 model vectors in the first projection year.

Arguments

  • projection_years_count: The number of projection years.
  • exogenous_projections: The matrix of exogenous variable projections.
  • yxr_initial_values: The initial values of the YXR variables.
  • parameters: The GCubedParameters object containing all model parameters.
  • x1_intertemporal_constants a row for each X1 variable and a column for each intertemporal constant.
  • j1_intertemporal_constants a row for each J1 variable and a column for each intertemporal constant.
  • ze_intertemporal_constants a row for each ZE variable and a column for each intertemporal constant.
  • z1_intertemporal_constants a row for each Z1 variable and a column for each intertemporal constant.

Returns

A tuple containing a vector for each of the following:

  1. first year projections of X1
  2. first year projections of J1
  3. first year projections of ZE
  4. first year projections of Z1
def functions_of_constants_and_exogenous_variables( projection_years_count: int, exogenous_projections: numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]], yxr_initial_values: numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]], parameters: gcubed.projections.gcubed_parameters.GCubedParameters, x1_intertemporal_constants: numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]], j1_intertemporal_constants: numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]], ze_intertemporal_constants: numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]], z1_intertemporal_constants: numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]]) -> (numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]], numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]]):

Overview

Generates the h3 and c4 vectors for ALL projection year sand does so for each of the intertemporal constants vectors used to represent a perturbation of an intertemporal constant.

These are needed when generating the raw projections of all variables over all projection years.

Arguments

  • projection_years_count: The number of projection years.
  • exogenous_projections: The matrix of exogenous variable projections.
  • yxr_initial_values: The initial values of the YXR variables.
  • parameters: GCubedParameters object containing all model parameters.
  • x1_intertemporal_constants a row for each X1 variable and a column for each intertemporal constant.
  • j1_intertemporal_constants a row for each J1 variable and a column for each intertemporal constant.
  • ze_intertemporal_constants a row for each ZE variable and a column for each intertemporal constant.
  • z1_intertemporal_constants a row for each Z1 variable and a column for each intertemporal constant.

Returns

  1. h3t matrix with a row for each J1 variable and a column for each projection year.
  2. c4t matrix with a row for each ZE variable and a column for each projection year.
def functions_of_constants_and_exogenous_variables_for_first_year( projection_years_count: int, exogenous_projections: numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]], yxr_initial_values: numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]], parameters: gcubed.projections.gcubed_parameters.GCubedParameters, x1_intertemporal_constants: numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]], j1_intertemporal_constants: numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]], ze_intertemporal_constants: numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]], z1_intertemporal_constants: numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]]) -> (numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]], numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]]):

Overview

Generates the h3 and c4 vectors for the first projection year. These are used when generating the baseline projections of the variables whose values are adjusted by the intertemporal constants.

Arguments

  • projection_years_count: The number of projection years.
  • exogenous_projections: The matrix of exogenous variable projections.
  • yxr_initial_values: The initial values of the YXR variables.
  • parameters: The GCubedParameters object containing all model parameters.
  • x1_intertemporal_constants a row for each X1 variable and a column for each intertemporal constant.
  • j1_intertemporal_constants a row for each J1 variable and a column for each intertemporal constant.
  • ze_intertemporal_constants a row for each ZE variable and a column for each intertemporal constant.
  • z1_intertemporal_constants a row for each Z1 variable and a column for each intertemporal constant.

Returns

A Tuple containing:

  1. h3 vector
  2. c4 vector
def extract_first_year_projections_of_target_variables( parameters: gcubed.projections.gcubed_parameters.GCubedParameters, x1_first_year_projections: numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]], j1_first_year_projections: numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]], ze_first_year_projections: numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]], z1_first_year_projections: numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]]) -> numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]]:

Overview

Extracts just the projections of the target variables from the full set of first year projections.

Arguments

  • parameters: The GCubedParameters object containing all model parameters.
  • x1_first_year_projections a row for each X1 variable
  • j1_first_year_projections a row for each J1 variable
  • ze_first_year_projections a row for each ZE variable
  • z1_first_year_projections a row for each Z1 variable

Returns

The vector of first year projections for the variables targeted by the intertemporal constants.

def generate_raw_projections( projection_years_count: int, exogenous_projections: numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]], yxr_initial_values: numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]], parameters: gcubed.projections.gcubed_parameters.GCubedParameters, x1_intertemporal_constants: numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]], j1_intertemporal_constants: numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]], ze_intertemporal_constants: numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]], z1_intertemporal_constants: numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]]) -> (numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]], numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]], numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]], numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]], numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]]):

Overview

Implements the projection logic in msgsimBL.ox. This runs the various equations to project variables based on the starting state vector and the values of exogenous variables in all years.

Arguments

  • projection_years_count: The number of projection years.
  • exogenous_projections: The matrix of exogenous variable projections.
  • yxr_initial_values: The initial values of the YXR variables.
  • parameters are the GCubed parameters used in the various calculations.
  • x1_intertemporal_constants a row for each X1 variable and a column for each intertemporal constant.
  • j1_intertemporal_constants a row for each J1 variable and a column for each intertemporal constant.
  • ze_intertemporal_constants a row for each ZE variable and a column for each intertemporal constant.
  • z1_intertemporal_constants a row for each Z1 variable and a column for each intertemporal constant.

Returns

  1. The X1 projections (X1 Variables by Years JNP array)
  2. The J1 projections (J1 Variables by Years JNP array)
  3. The ZE projetions (ZE Variables by Years JNP array)
  4. The Z1 prjections (Z1 Variables by Years JNP array)

Exceptions

Exceptions are raised if any of the raw projections have NaN (not a number) values.

def compute_jacobian( projection_years_count: int, exogenous_projections: numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]], yxr_initial_values: numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]], parameters: gcubed.projections.gcubed_parameters.GCubedParameters, x1_intertemporal_constants: numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]], j1_intertemporal_constants: numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]], ze_intertemporal_constants: numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]], z1_intertemporal_constants: numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]], baseline_adjusted_variable_projections: numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]]) -> numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]]:

Computes the Jacobian used in the intertemporal constants calculation in the one pass.

Arguments

  • projection_years_count: The number of projection years.
  • exogenous_projections: The matrix of exogenous variable projections.
  • yxr_initial_values: The initial values of the YXR variables.
  • parameters are the GCubed parameters used in the various calculations.
  • x1_intertemporal_constants a row for each X1 variable and a column for each intertemporal constant.
  • j1_intertemporal_constants a row for each J1 variable and a column for each intertemporal constant.
  • ze_intertemporal_constants a row for each ZE variable and a column for each intertemporal constant.
  • z1_intertemporal_constants a row for each Z1 variable and a column for each intertemporal constant.
  • baseline_adjusted_variable_projections the vector of first year projections for the variables targeted by the intertemporal constants, before we add intertemporal constants to the system.

Returns

The Jacobian matrix with a row for each variable that has an intertemporal constant and with a column for each variable that we adjust in the first projection year using the intertemporal constants.

def perturbed_functions_of_constants_and_exogenous_variables_for_first_year( projection_years_count: int, exogenous_projections: numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]], yxr_initial_values: numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]], parameters: gcubed.projections.gcubed_parameters.GCubedParameters, x1_intertemporal_constants: numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]], j1_intertemporal_constants: numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]], ze_intertemporal_constants: numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]], z1_intertemporal_constants: numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]]) -> (numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]], numpy.ndarray[tuple[typing.Any, ...], numpy.dtype[numpy.float64]]):

Overview

Generates the h3 and c4 vectors for the first projection year and does so for each of the intertemporal constants vectors used to represent a perturbation of an intertemporal constant.

This enables us to generate all columns of the Jacobian used in the intertemporal constants calculation in the one pass.

Arguments

  • projection_years_count: The number of projection years.
  • exogenous_projections: The matrix of exogenous variable projections.
  • yxr_initial_values: The initial values of the YXR variables.
  • parameters: The GCubedParameters object containing all model parameters.
  • x1_intertemporal_constants a row for each X1 variable and a column for each intertemporal constant.
  • j1_intertemporal_constants a row for each J1 variable and a column for each intertemporal constant.
  • ze_intertemporal_constants a row for each ZE variable and a column for each intertemporal constant.
  • z1_intertemporal_constants a row for each Z1 variable and a column for each intertemporal constant.

Returns

  1. h3 matrix with a column vector for each intertemporal constant.
  2. c4 matrix with a column vector for each intertemporal constant.