gcubed.sym_data
This module contains the SymData
class, which loads and provides access to all of the
information about the model contained in the SYM model definition.
Overview
The model equations are expressed in terms of various vectors of variables and a vector of parameters.
Each vector is a different type of variable. Note the naming conventions for the lefthand side (LHS) variable vectors:
a. x1l
- the vector of left-hand side state variables
b. j1l
- the vector of left-hand side costate or jump variables
c. zel
- the vector of left-hand side expected endogenous variables
d. z1l
- the vector of left-hand side endogenous variables
These 4 vectors of variables are functions of:
x1r
is right-hand side state variablesj1r
is right-hand side costate or jump variableszer
is right-hand side endogenous variables LOGY, PRCT, PRIDexz
is right-hand side the lead expected ze variablesyxr
is right-hand side state variables lagged by 1 periodyjr
is right-hand side costate variables lagged by 1 periodexo
is exogenous variables (by definition only appearing on the right-hand side)z1r
is right-hand side endogenous variables.
The parameters are a vector of parameters, par
.
Constructor
Loads and provides access to all of the information about the model contained in the SYM model definition.
Arguments
configuration
: The configuration details for the model.
Overview
Convert a vector name in the model to the type of variable it represents
as defined by the variable summary var_type
column.
Arguments
vector_name
: The name of the vector (any one of the LHS or RHS vector names)
Exceptions
Raises an exception if the vector name is not recognised.
The dataframe of information about the model variables, loaded from the var_info file produced by processing the SYM model definition with the SYM processor.
The dataframe containing the map of the model variables, loaded from the var_map file produced by processing the SYM model definition with the SYM processor.
Arguments
lhs_vector_name
: the name of the LHS vector.
Returns
the matching RHS vector name, replacing the last character, l, with an r.
Convert a vector name in the model to the varmap file variable type to lookup for the varmap information associated with the vector.
Arguments
vector_name
: The fully qualified name of the variable
### Returns
The string ID of the projection vector that the variable is in.
A dictionary mapping from a set name to the list of set members, in the order in which they were defined in the SYM model definition.
Arguments
set_name
: The name of the SYM model definition set of interest, e.g. 'region'.
Returns
The members of the named set, as a list of strings, or the empty list if the named set is not part of the SYM model definition.
Arguments
set_name
: The name of the set.
Returns
The description of the set.
A dictionary mapping from set member name to set member description.
Arguments
set_member_name
: The name of the set member.
Returns
The description of the set member.
The list of goods produced in the economy. These are the members of the
goods
set, that is a part of every G-Cubed model SYM definition.
The number of goods produced in the economy. These are the members of the
goods
set, that is a part of every G-Cubed model SYM definition.
The list of energy goods produced in the economy. These are the outputs of the energy producing sectors in the economy.
They are identified by being members of the goods_e
set, that is a part of
every G-Cubed model SYM definition.
The number of energy goods produced in the economy. These are the outputs of sectors in the economy that deal with extraction and value addition for fuel sources (e.g.coal, gas, oil, petroleum refining etc) as well as the electricity distribution sector.
They are identified by being members of the goods_e
set, that is a part of
every G-Cubed model SYM definition.
The list of goods in the economy that are produced by electricity generation sectors. All of those sectors produce electricity, so their output is the same in some sense. However, the output of each industry is identified by its own 'good' identifier.
They are identified by being members of the goods_g
set.
The number of goods in the economy that are produced by electricity generation sectors. All of those sectors produce electricity, so their output is the same in some sense. However, the output of each industry is identified by its own 'good' identifier.
They are identified by being members of the goods_g
set.
The list of goods in the economy that are not
energy goods (those that are members of the goods_e
set).
The number of goods in the economy that are not
energy goods (those that are members of the goods_e
set).
The list of goods in the economy that are not
electricity generation goods (those that are members of the goods_g
set).
The number of goods in the economy that are not
electricity generation goods (those that are members of the goods_g
set).
A flag indicating whether the model has an electricity distribution good.
The list of electricity distribution goods produced in the model.
Typically, this is a single good is only defined in models that break out electricity into a single distribution sector that aggregates the output from one or more electricity generation sectors.
Exceptions
Raises an exception if the electricity distribution good is not defined in the model.
The list of sectors explicitly defined in the SYM model definition that have a standard treatment of their production functions (this typically just excludes the electricity distribution sector).
The number of sectors explicitly defined in the SYM model definition that are not responsible for electricity distribution.
The list of material goods in the economy (those that are not energy goods or electricity generation goods).
The number of material goods in the economy (those that are not energy goods or electricity generation goods).
The list of non-durable goods in the economy that are not electricity generation goods.
The number of non-durable goods in the economy that are not electricity generation goods.
A flag indicating whether the model has a durable manufacturing good.
The durable manufacturing good produced in the economy.
Typically there is a single sector producing a single durable manufacturing good.
The exception is the 2 sector model where there is no durable manufacturing good.
Exceptions
Raises an exception if the durable manufacturing good is not defined in the model.
The capital sectors that are part of all G-Cubed models. There are two of them:
sector Y, the sector that produces capital for firms.
sector Z, the sector that produces capital for households.
The list of all sectors defined in the SYM model definition plus the two capital producing sectors that are common to all model versions.
The number of sectors defined in the SYM model definition plus the two capital producing sectors that are common to all model versions.
The list of sectors that are explicitly defined in the SYM model definition.
These are the members of the sectors
set.
The list does not include the two capital producing sectors that are common to all model versions.
The number of sectors that are explicitly defined in the SYM model definition.
These are the members of the sectors
set.
The number does not include the two capital producing sectors that are common to all model versions.
The list of sectors explicitly defined in the SYM model definition except for sectors that are involved in electricity generation or energy.
A flag indicating whether the model has an electricity distribution sector.
The list of sectors explicitly defined in the SYM model definition that are responsible for electricity distribution.
This is typically just the first sector, in those models that include such a sector.
Exceptions
Raises an exception if the electricity distribution sector is not defined in the model.
A boolean flag indicating whether the model has electricity generation sectors.
The list of sectors explicitly defined in the SYM model definition that are responsible for electricity distribution.
The number of sectors explicitly defined in the SYM model definition except for sectors that are involved in electricity generation.
The list of sectors explicitly defined in the SYM model definition except for sectors that are involved in electricity generation.
The number of sectors explicitly defined in the SYM model definition that are not responsible for electricity generation.
The list of sectors explicitly defined in the SYM model definition that have a standard treatment of their production functions (this typically just excludes the electricity distribution sector).
The number of sectors explicitly defined in the SYM model definition that are not responsible for electricity distribution.
The list of sectors explicitly defined in the SYM model definition that are not responsible for electricity distribution.
The number of sectors explicitly defined in the SYM model definition that are not responsible for electricity distribution.
The list of sectors producting material goods in the economy (those that are not energy goods or electricity generation goods).
The number of sectors producing material goods in the economy (those that are not energy goods or electricity generation goods).
The string identifier of the gas sector.
Model versions with more than 2 sectors typically include a gas sector.
The string identifier of the oil refining sector. This is currently the sector associated with oil-related carbon emissions.
A flag indicating whether the model has a durable manufacturing sector.
The durable manufacturing sector in the economy.
Typically there is a single sector producing a single durable manufacturing good.
The exception is the 2 sector model where there is no durable manufacturing good.
Exceptions
Raises an exception if the durable manufacturing sector is not defined in the model.
The list of regions explicitly defined in the SYM model definition as part
of the regions
set.
The number of regions explicitly defined in the SYM model definition as part
of the regions
set.
The string identifier of the USA region. This must always be the first region
defined in the SYM regions
set and it will be the first region in the list
of region members.
The string identifier of the good produced by the sector that includes gas extraction and gas utilities.
The list of sectors explicitly defined in the SYM model definition that are responsible for fossil fuel extraction and production in alphabetical order of the sector identifiers.
- gas
- oil
- coal
Arguments
good
: The identifier of the good produced by the sector of interest.
Returns
the sector identifier for the sector that produces the specified good.
Arguments
goods
: The list of identifiers of the goods produced by the sectors of interest.
Returns
the list of sector identifiers for the sectors that produces the goods in the supplied list.
Arguments
sector
: The identifier of the sector that produces the good of interest.
Returns
the good identifier produced by the specified sector.
Arguments
sectors
: The list of identifiers of the sectors that produce
the goods of interest.
Returns
the list of good identifiers for the goods produced by the specified sectors.
The list of greenhouse gases that are part of the ghg
set in the SYM model definition.
The number of greenhouse gases that are part of the ghg
set in the SYM model definition.
The number of exogenous variables in the model (The length of the EXO vector).
The number of endogenous variables in the model (The length of the Z1L, Z1R vectors).
The number of expected endogenous variables in the model (The length of the ZEL, ZER and EXZ vectors).
The number of costate or jump variables in the model (The length of the J1L, J1R and YJR vectors).
The number of state variables in the model (The length of the X1L, X1R and XJR vectors).
The list of resources other than energy or material goods that are used in production.
The number of resources other than energy or material goods that are used in production.
The four string identifiers of the factors of production:
K
for capitalL
for labourE
for energyM
for material
A list of the model's LHS vector names.
Note the lowercase naming conventions for the lefthand side (LHS) variable vectors:
x1l
(the vector of state variables) X=S=Statej1l
(the vector of costate or jump variables) J=C=Costatezel
(the endogenous variables LOGY, PRCT, PRID)z1l
(the other endogenous variables)
- S - state - x1r is right hand side (RHS) state variables
- J - jump - j1r is RHS costate or jump variables
- R - ? - zer is special RHS endogenous variables LOGY, PRCT, PRID that also appear as expected next-period values on the RHS of the equations.
- exz is RHS the lead expected R (Expected value in next period of R)
- S_{t-1} yxr is RHS state variables lagged by 1 period
- yjr is RHS costate variables lagged by 1 period
- exo is exogenous variables (by definition only appearing on RHS)
- z1r is RHS other endogenous variables.
- exz is RHS the lead expected endogenous variables (Expected value in next period of a subset of the endogenous variables)
- yxr is RHS state variables lagged by 1 period
- yjr is RHS costate variables lagged by 1 period
- exo is exogenous variables (by definition only appearing on RHS)
Argument:
vector_name: The 3 character acronym identifying the LHS or RHS vector in the model.
Returns the integer length of the specified vector.
Arguments
vector_name: the name of the vector
Returns the SYM ordered fully articulated variable names for the variables in the given model vector.
This is useful for labelling the rows/columns of dataframes containing linear model partial derivatives, and SSF matrices.
Overview
Used to check whether the model includes variables with names that start with the supplied prefix. The prefix is matched as a string rather than a regular expression.
Arguments
variable_name_prefix
: The variable name prefix string.
Returns
True iff the SYM model definition includes a variable with the given root name.
Overview
Used to check whether the model includes the named variable.
Arguments
variable_name
: The complete variable name including
the set qualifier in round brackets (e.g. INFL(USA)
).
Returns
True if the SYM model definition includes a variable with the given complete name.
Overview
Used to get the integer index of a variable in the specified vector.
Arguments
variable_name
: The complete variable name including
the set qualifier in round brackets (e.g. INFL(USA)
).
Returns
The integer indicating the row index of the variable in the given vector.
Indexing starts from 0
.
Throws
An exception is thrown if the named variable is not unique within the SYM model though that should not be possible once the SYM processor has run without problems.
Arguments
vector_name: The name of the vector that contains the variable.
variable_name_prefix: The prefix is the set of characters up to but not including the round bracket that starts the full qualification of the variable based on the sets it is defined over.
e.g. use SHL for SHL(region,sector)
Returns
The units of measurement for the variables that match the given name prefix and that are of the variable type associated with the given vector name.
Overview
Provides access to the information about the variables that are associated with intertemporal constants.
The intertemporal constants are used to ensure that jump variables equal to their observed values in the year where there is available data (typically the base projection year, one year before the start of projections).
An intertemporal constant is also used in each WAGE equation to ensure that real interest rates align with nominal interest rates less expected inflation in the next year.
Returns
A dataframe containing a row per variable that has an intertemporal constant in its equation. The dataframe has the following columns:
name
variable name (complete with set identifiers for region/sector etc.)var_type
variable type (the associated LHS vector name)sequence
the index of the variable in the associated vector
Overview
Provides access to the information about the variables that have their values adjusted by the intertemporal constants. Note that this list is slightly different from the list of variables that have intertemporal constants added to their equations in the model to match up model projections with observed values at the start of the projections because a constant is added to the WAGE equation but it is used to adjust the WAGE equation in a way that leads to the required expected price inflation rate.
Returns
A dataframe containing a row per variable that has an intertemporal constant in its equation. The dataframe has the following columns:
name
variable name (complete with set identifiers for region/sector etc.)var_type
variable type (the associated LHS vector name)sequence
the index of the variable in the associated vector
Overview
This summary dataframe of the SYM information about variables should be used to drive a lot of the variable filtering during model processing.
The rows of the dataframe are the variable names.
The columns of the dataframe are:
name
- the full name of the variableprefix
- the name prefix - up to the open bracket.units
- the units code.publication_units
- the units code to use when publishing variable projections.description
- the descriptionvar_type
- one of:par
= parameterets
= expected next-period value of an endogenous variableend
= endogenoussta
= statestl
= lead state variableexo
= exogenouscos
= costate or jump
vector
- the vector name e.g.z1l
,yxr
,exo
etc.vector_code
- the vector name and index combination - e.g.exo[3]
.sequence
- the index in the vector that corresponds to the variable - e.g3
.is_intertemp
- the index of the variable in the vector of intertemporal constants (or NaN)is_adjusted
- the index of the variable in the vector of variables being adjusted by intertemporal constants (or NaN)
Returns
The variable summary dataframe.
Arguments
variable_name: The full name of the variable including details of set membership: e.g. WAGE(AA)
.
Returns
The units of measurement for the variable with the given name.
Exceptions
Raises an exception if the named variable is not in the model.
Arguments
variable_name: The full name of the variable including details of set membership: e.g. WAGE(AA)
.
Returns
The publication units of measurement for the variable with the given name.
Exceptions
Raises an exception if the named variable is not in the model.
Arguments
variable_name: The full name of the variable including details of set membership: e.g. WAGE(AA)
.
Returns
The variable type of the vector that the variable is in. One of:
par
= parameterets
= expected next-period value of an endogenous variableend
= endogenoussta
= statestl
= lead state variableexo
= exogenouscos
= costate or jump
Exceptions
Raises an exception if the named variable is not in the model.
Arguments
variable_name: The full name of the variable including details of set membership: e.g. WAGE(AA)
.
Returns
The region code for the named variable or None if the variable has no region.
Exceptions
Raises an exception if the named variable is not in the model.
Arguments
variable_name: The full name of the variable.
Returns
True
if the variable is exogenous and False
otherwise.
Throws
Exception if the named variable is not in the model.
Arguments
variable_name: The full name of the variable.
Returns
True
if the variable is a state or lead state variable and False
otherwise.
Throws
Exception if the named variable is not in the model.
Arguments
variable_name: The full name of the variable.
Returns
True
if the variable can be adjusted in a simulation layer
and False
otherwise.
Throws
Exception if the named variable is not in the model.
Overview
Some variables have equations defined for them by SYM but should instead be set to zero in the model. This method enables those variables to be selected.
Returns
The series contains True
iff the variable is to have its equation modified to ensure the
variable always evaluates to zero.
Overview
Some variables have equations defined for them by SYM but should instead be set to zero in the model. This method enables those variables to be selected.
This is used to change the python class that contains the equations in the model, replacing specific functions for the selected variables and changing the map from LHS to RHS variables to have empty RHS lists for the selected variables as LHS variables.
Returns
The extract of the variable summary dataframe for those variables that are to have their equations replaced with an equals zero.
Arguments
variable_name: The full name of the variable.
Returns
The name of the function that is to be used to calculate the value of the variable in the model.
Throws
AssertionError
if the named variable is not in the model.AssertionError
if the named variable is exogenous.AssertionError
if the named variable is a parameter.
Enables determation of the variable name from the vector name and sequence details provided in the SYM generated equation map.
Arguments
vector_name
: the name of the vector in which the variable is stored.
sequence
: the position of the variable in the vector.
Returns
The name of the variable in the model.
Overview
Used to get the list of variable names in the model that have the given prefix (the letters before the first '(').
Arguments
variable_name_prefix
: The variable name prefix string.
Returns
A series of variable names that have the given prefix.