gcubed.benchmarking.benchmarks

This module contains the Benchmarks class, used to create a set of benchmarking information about a G-Cubed model.

This enables comparisons of models across models and across versions of the gcubed package used to run them.

class Benchmarks(gcubed.base.Base):

Overview

Create a set of benchmark results associated with a model and a version of Ox.

Benchmarks( working_directory: str, configuration_file: str, relinearisation_years: list[int] = [], experiment_design_file: str = None)

Overview

Generates all of the benchmarks that can be used to determine the outcome of running the given experiment.

Arguments

working_directory: The directory where the results and logs are to be stored.

configuration_file: The location of the configuration file, as an absolute path or relative to the specified working directory.

relinearisation_years: The list of years where a relinearisation is required. This list can be empty in which case the model is not relinearised. To generate a list of years, from 2018 to say, 2030, you can supply the following as as this parameter value: list(range(2018, 2031)). (Note that the upper bound is not included in the range.) Defaults to the empty list.

experiment_design_file: The optional location of the experiment design CSV file, as a relative path directory to the experiment design file from the simulations directory within the model directory (the model directory contains the configuration file).

start_projections_from_the_neutral_real_interest_rate: bool

True if the baseline linearisation is around neutral real interest rates and False if they are around database values.

Defaults to True.

linearise_around_the_neutral_real_interest_rate: bool

True if the baseline linearisation is around the neutral real interest rate and False if it is around database values.

relinearise_around_the_neutral_real_interest_rate: bool

True if relinearisations are around the neutral real interest rate and False if they are around previous projection values in the relinearisation year.

relinearise_in_event_years: bool

True if the runner is to relinearise the model in all event years as well as the years specified and False if the runner is to relinearise the model only in the years specified.

Defaults to False.

If necessary, modify this setting once the running is instantiated but before the experiment is run.

python_version: str

The version of Python used to run the model.

gcubed_version: str

The version of G-Cubed used to run the model.

gcubed_build: str

The build of G-Cubed used to run the model.

working_directory: str

The working directory for Python.

configuration_file: str

The configuration file name and location relative to the working directory.

experiment_design_file: str

The experiment design file name or None if no experiment is to be run.

relinearisation_years: list[int]

The (possibly empty) list of relinearisation years (all in YYYY format).

linearise_around_strict_model_solution: bool

True if the model linearisation is done around a strict model solution and False if the model linearisation is to instead be done around actual data values sourced from the model database or from a previous model projection. Set this to False for standard linearisation as has been done for G-Cubed for decades. Set this to True if the actual data values are to be adjusted to find similar values that exactly solve all of the equations in the model before then linearising around those similar values.

This property defaults to False.

start_relinearisation_projections_from_the_neutral_real_interest_rate: bool

True if the relinearisation starts with neutral real interest rates and False otherwise.

Defaults to False.

def produce_benchmarks(self):

Generate the benchmarks data by running the experiment.

first_year_observed_values_of_variables_adjusted_by_intertemporal_constants: pandas.core.frame.DataFrame

The first projection year observed (database) values of variables adjusted by intertemporal constants.

first_year_original_projections_of_variables_adjusted_by_intertemporal_constants: pandas.core.frame.DataFrame

The first projection year original (not adjusted by intertemporal constants) projections of variables adjusted by intertemporal constants

def first_projection_year_ssf_lhs_vector_values(self, lhs_vector_name: str) -> pandas.core.frame.DataFrame:

Arguments

lhs_vector_name: The name of the LHS vector.

Returns

The first projection year State Space Form evaluation for the given LHS vector.

def first_projection_year_data_difference_from_ssf(self, vector_name: str) -> pandas.core.frame.DataFrame:

Arguments

vector_name: The name of the RHS version of the LHS vector (e.g. x1r for vector x1l)

Returns

The first projection year data difference from State Space Form evaluation for the given vector.

def first_projection_year_original_projections(self, vector_name: str) -> pandas.core.frame.DataFrame:

Arguments

lhs_vector_name: The name of the vector - one of:

  • yxr
  • yjr
  • exz
  • z1l

Returns

The first projection year original (not adjusted by constants) projection for the named vector.

partial_derivatives_wrt_intertemporal_constants: pandas.core.frame.DataFrame

The partial_derivatives wrt intertemporal constants used in Newton's method to compute the intertemporal constants.

intertemporal_constants: pandas.core.frame.DataFrame

The intertemporal constants used to match costate variable projections to their observed values in the first projection year.

population: pandas.core.frame.DataFrame

The population growth projections for all regions

def productivity(self, region: str) -> pandas.core.frame.DataFrame:

Arguments

region: The region code

Returns

The productivity growth projections for the region

def effective_labour_productivity(self, region: str) -> pandas.core.frame.DataFrame:

Arguments

region: The region code

Returns

The effective labour productivity growth projections for the region

potential_output_growth: pandas.core.frame.DataFrame

Potential output growth, for all regions, with rows indexed by region.

def energy_usage_efficiency_gain(self, region: str) -> pandas.core.frame.DataFrame:

Arguments

region: the region to get the energy usage efficiency gain for.

Returns

The energy usage efficiency gain projections for all sectors in the region.

consumption_energy_usage_efficiency_gains: pandas.core.frame.DataFrame

Consumption energy usage efficiency gains for all regions, with rows indexed by region.

baseline_exogenous_variable_projections: pandas.core.frame.DataFrame

The baseline exogenous variable projections.

baseline_c4t: pandas.core.frame.DataFrame

The baseline c4t matrix.

baseline_h3t: pandas.core.frame.DataFrame

The baseline h3t matrix.

baseline_initial_state_vector: pandas.core.frame.DataFrame

The baseline yxr (state) vector in the first projection year.

baseline_constantBL: pandas.core.frame.DataFrame

The baseline constantBL matrix.

all_projections: list[tuple]

A list of tuples where each tuple contains the details about a projection. The projections can be baseline projections or simulation layers.

The projection details are listed in the order that they were generated.

The details for each projection are:

  1. The first projection year
  2. The last projection year
  3. The projection name
  4. The raw projections dataframe
  5. The database projections dataframe
  6. The publishable projections dataframe
  7. The annotated publisable projections dataframe
model_version: str

The G-Cubed model version.

model_build: str

The G-Cubed model build.

model_build_number: str

The G-Cubed model build number.

name: str

The name of the benchmarks - used for reporting mismatches.

first_projection_year: str

The first projection year.

last_projection_year: str

The last projection year.

projection_years: list[int]

The list of projection years, as integers.

projection_year_labels: list[str]

The list of projection years, as column labels for data frames.

lhs_vector_names: list[str]

The list of LHS vector names.

rhs_vector_names: list[str]

The list of RHS vector names.

ssf_rhs_vector_names: list[str]

The list of RHS vector names for the state space form of the model.

rhs_versions_of_lhs_vector_names: list[str]

The list of RHS vector names, for vectors that are also LHS vectors in the model.

sym_summary: pandas.core.frame.DataFrame

The summary of the model variables.

regions: list[str]

The list of region codes.

sectors: list[str]

The list of sector codes.

goods: list[str]

The list of good codes.

parameter_values: pandas.core.frame.DataFrame

The dataframe of calibrated model parameter values, indexed by parameter names.

all_parameters: dict[str, pandas.core.frame.DataFrame]

A dictionary of all parameters, keyed by parameter name. This makes it easier to relate parameter values to specific set members.

def initial_rhs_vector_values(self, rhs_vector_name: str) -> str:

Arguments

rhs_vector_name: The RHS vector name

Returns

Initial (first projection year) RHS vector values, used in linearisation.

* Linearisation information. *

def nonlinear_equation_vector_values(self, lhs_vector_name) -> str:

Arguments

lhs_vector_name: The LHS vector name

Returns

The values for the LHS vectors computed using the nonlinear equations in the model for the first projection year.

* Linearisation information. *

def linearisation_partial_derivatives(self, lhs_vector_name: str, rhs_vector_name: str) -> str:

Arguments

lhs_vector_name: The LHS vector name

rhs_vector_name: The RHS vector name

Returns

The partial derivatives matrix relating the LHS vector to the RHS vector in the linearised model.

* Linearisation information. *

def ssf_matrix(self, lhs_vector_name: str, rhs_vector_name: str) -> str:

Arguments

lhs_vector_name: The LHS vector name

rhs_vector_name: The RHS vector name

Returns

The delta matrix relating the LHS vector to the RHS vector in the state space form of the model.

* Linearisation information. *

eigenvalues: pandas.core.frame.DataFrame

The eigenvalues of the transition matrix of the stable manifold.

H1: pandas.core.frame.DataFrame

The H1 matrix of the stable manifold.

H2: pandas.core.frame.DataFrame

The H2 matrix of the stable manifold.

M1: pandas.core.frame.DataFrame

The M1 matrix of the stable manifold.

M2: pandas.core.frame.DataFrame

The M2 matrix of the stable manifold.

mu1: pandas.core.frame.DataFrame

The mu1 matrix of the stable manifold.

mu2: pandas.core.frame.DataFrame

The mu2 matrix of the stable manifold.

Anew: pandas.core.frame.DataFrame

The Anew transition matrix of the stable manifold.

Znew: pandas.core.frame.DataFrame

The Znew matrix of the stable manifold.

Gamma_st: pandas.core.frame.DataFrame

The Gamma_st matrix of the stable manifold.

Gamma_jt: pandas.core.frame.DataFrame

The Gamma_jt matrix of the stable manifold.

Gamma_rT: pandas.core.frame.DataFrame

The Gamma_rT matrix of the stable manifold.

psi_rj: pandas.core.frame.DataFrame

The psi_rj matrix of the stable manifold.

psi_rs: pandas.core.frame.DataFrame

The psi_rs matrix of the stable manifold.

psi_rx: pandas.core.frame.DataFrame

The psi_rx matrix of the stable manifold.

tau_sjt: pandas.core.frame.DataFrame

The tau_sjt matrix of the stable manifold.

common_factor: pandas.core.frame.DataFrame

The common_factor matrix of the stable manifold.