gcubed.linearisation.state_space_form

This module contains the StateSpaceForm class.

The state space form is simply a matrix representation of the linearised model, after eliminating the vectors on the left-hand side of the equations from the right-hand side of the equations.

class StateSpaceForm(gcubed.base.Base):

The algebra embodied in this class follows https://www.msgpl.com.au/Manuals2021/GGGv20JManual/softwaremanual/algorithm.pdf

The notation has been extended to also include equations for expected endogenous variables to include exogenous variables.

This class provides the ability to work with the model equations. It constructs the matrices of constants associated with the state-space form of the linearised model. This involves eliminating the endogenous variables from the model via substitution.

To use this class instantiate it with a linear_model. run the generate_state_space_form() method.

To understanding the naming conventions, the partial derivatives matrix associated with the partials of x1l with respect to z1r are stored in a property called x1l_z1r_partials. The same naming convention is used for all partials matrices: __partials.

The SSF matrices follow a similar naming convention: _

StateSpaceForm(linear_model: gcubed.linearisation.linear_model.LinearModel)

Constructor

Arguments

linear_model: The linear approximation to the model that will be algebraicly manipulated to produce the state-space form of that linear approximation.

The linear model underpinning this state-space form.

The full, non-linear model that has this state-space form for the given linear approximation.

The SYM definition of the model.

The model configuration details.

def delta(self, lhs_vector_name, rhs_vector_name) -> numpy.ndarray:

Overview

Use the name of the LHS vector and the RHS vector to retrieve the matrix for the state-space form.

Arguments

lhs_vector_name: The name of the LHS vector.

rhs_vector_name: THe name of the RHS vector

Returns

The matrix with one row for each equation associated with the LHS vector an one column for each variable in the RHS vector.

def delta_as_dataframe(self, lhs_vector_name, rhs_vector_name) -> pandas.core.frame.DataFrame:

Arguments

lhs_vector_name: The name of the LHS vector.

rhs_vector_name: THe name of the RHS vector

Returns

The delta matrix as a dataframe labelling rows with LHS variable names and columns with RHS variable names.

def process(self, lhs_vector_name: str):

Overview

Do the SSF algebra for the vector of equations associated with the given LHS vector name.

Looks for the same vectors as that specified in the lhs_vector_name, but on the RHS of the vector equation and if it is there, it rearranges the equation to eliminate the vector from the RHS of the equation.

It then works through all other vector equations, substituting out the RHS occurrences of the vector specified by the lhs_vector_name so that the vector is eliminated from the RHS of all equations.

Arguments:

  • lhs_vector_name: The name of the LHS vector.
def select_delta_coefficients( self, lhs_vector_name: str, rhs_vector_name: str, lhs_variable_name_prefix: str = None, rhs_variable_name_prefix: str = None) -> pandas.core.frame.DataFrame:

Overview Retrieve the partial derivatives for the specified LHS vector.

Arguments

lhs_vector_name: The name of the LHS vector, e.g. x1l or j1l.

rhs_vector_name: The name of the RHS vector, e.g. yxr or j1r.

lhs_variable_name_prefix: The prefix to use for the LHS variable names, e.g. PRID(USA. Defaults to None in which case all rows are returned.

rhs_variable_name_prefix: The prefix to use for the RHS variable names, e.g. TCPS(a11,g02,USA. Defaults to None in which case all columns are returned.

Returns

The dataframe with the matched rows and columns of the chosen SSF matrix.

def delta_coefficients_for_given_lhs_variable( self, lhs_variable_name_prefix: str = None) -> pandas.core.frame.DataFrame:

Overview Retrieve the delta coefficients for the specified LHS variables.

Arguments

lhs_variable_name_prefix: The prefix to use for the LHS variable names, e.g. PRID(USA. Defaults to None in which case all rows are returned.

Returns

The dataframe with the partial derivatives for the selected LHS variables.