gcubed.data.database_validator
This class validates the database of a G-Cubed model by checking the consistency of various variables and their relationships.
Overview
Provides convenience methods for all classes.
All G-Cubed classes inherit from this base class.
Overview
Initialize the DatabaseValidator class by setting the model property.
Arguments
model_configuration: An instance of ModelConfiguration containing the model configuration.sym_data: An instance of SymData containing the symbolic data for the model.parameters: An instance of Parameters containing the model parameters.data: A DataFrame containing the model self.data.results_folder: The folder where the results will be saved. Defaults toNone.log_differences: A boolean indicating whether to log differences as they are found. Defaults toFalse.
Exceptions
AssertionError: If the input parameters are not valid.AssertionError: If the data is empty or does not contain valid year columns.
Overview
Get the results folder where the validation results will be saved.
Returns
Path: The path to the results folder.
Overview
Check if differences should be logged.
Returns
bool:Trueif differences should be logged,Falseotherwise.
Overview
Check if the results should be saved.
Returns
bool:Trueif the results folder is set,Falseotherwise.
Overview
Get the model configuration.
Returns
ModelConfiguration: The model configuration of the G-Cubed model.
Overview
Get the symbolic data property of the model.
Returns
SymData: The symbolic data of the G-Cubed model.
Overview
Get the parameters property of the model.
Returns
Parameters: The parameters of the G-Cubed model.
Overview
Get the data to be validated.
Returns
pd.DataFrame: The data of the G-Cubed model.
Overview
Get the first year of the data.
Returns
str: The first year of the G-Cubed model data.
Overview
Get the last year of the data.
Returns
str: The last year of the G-Cubed model data.
Overview
Get the years of the data.
Returns
List[str]: The self.years of the G-Cubed model data.
Overview
Get all years except the first.
Returns
List[str]: The self.t_plus_1_years of the G-Cubed model data.
Overview
Get all years except the last
Returns
List[str]: The self.t_minus_1_years of the G-Cubed model data.
Overview
Get the names of the data index.
Returns
pd.Index: The names of the G-Cubed model data index.
Overview
Get the names of the data index that match a given prefix.
Arguments
prefix: The prefix to match against the data index names.
Returns
pd.Index: The names of the G-Cubed model data index that match the prefix.
Overview
Check if the data contains variables that match a given prefix.
Arguments
prefix: The prefix to match against the data index names.
Returns
bool:Trueif the variables are in the model and in the data,Falseotherwise.
Overview
Check if the model has all the specified parameters.
Arguments
parameter_names: A list of parameter names to check.
Returns
bool:Trueif all parameters are present,Falseotherwise.
Overview
Check if the data contains variables with each of the prefixes.
Arguments
variable_prefixes: A list of prefixes to match against the data index names.
Returns
bool:Trueif all prefixes are matched to variables.
Overview
Get the data for a specific variable prefix and years.
Arguments
prefix: The prefix of the variable to match against the data index names.years: The years for which to retrieve the data.
Returns
pd.DataFrame: The data for the specified variable prefix and years.
Overview
Check that the two dataframes are equal, within chosen levels of precision.
Arguments
a: The first dataframe to compare.b: The second dataframe to compare.atol: The absolute tolerance between the elements. Defaults to 1e-8.rtol: The relative tolerance between the elements. Defaults to 1e-5.
Returns
Trueif the dataframes are equal.
Overview
Create a DataFrame with a single row containing zeros for each year in the model.
These are a useful benchmark for checking totals sum to zero.
Returns
A DataFrame with a single row named "ZEROS()" and columns for each year.
Overview
lead(BOND) = DEFI + BOND*(1-labgrow) - PBAG ;
Returns
None: This function does not return anything, it only performs validation checks.
Overview
```sym INV = ( (1+.5*(TOB-1))*(TOB-1)CAP/phi )forei + ( (1+.5(TPA-1))(TPA-1)CAP/phi )(1-forei) + SHKI ;
Overview
JNV = ( INV + (phi/2)*(base_jk^2)*CAP )/(1+phi*base_jk) ;
Overview
Check capital accumulation
lead(CAP) = JNV + (1-delta-labgrow)*CAP
Overview
Region-wide price paid by the sectors for raw capital.
PRII = cd_oR*( delta_oR(k)*PRKY
+ delta_oR(l)*WAGE
+ delta_oR(e)*PRIE
+ delta_oR(m)*PROI
- delta_oR(l)*SHLY
)
+ (1-cd_oR)*ln( delta_oR(k)*exp(PRKY )^(1-sigma_oR)
+ delta_oR(l)*exp(WAGE-SHLY)^(1-sigma_oR)
+ delta_oR(e)*exp(PRIE)^(1-sigma_oR)
+ delta_oR(m)*exp(PROI )^(1-sigma_oR)
) / (1-sigma_oR*(1-cd_oR))
- SHYY ;
Overview
Validate the ASSE variable in the G-Cubed model database by checking its consistency with other variables.
lead(ASSE) = ASSE*( 1-labgrow(owner) ) + ( ashr*ABUY + aeye*(CURR(owner)-ABUY) ) / exp(REXN(currency)) ;
Overview
Check that the TBAL variables summed across regions equal zero.
Overview
Check that the TBAU variables summed across regions equal zero.
Overview
Check that the IRAS variables summed across regions equal zero.
Overview
Check that the CURR variables summed across regions equal zero.
Overview
Check that the CURN variables summed across regions equal zero.
Overview
Check that the sum of the EXQT values across regions equals the sum of the IMQT values across regions
Overview
Check that the sum of the IMQ values across goods equals IMQT value for a region
Overview
Validate the PRCO variable in the G-Cubed model database by checking its consistency with other variables.
Overview
INTF = INTN - (lead(log(PRID)) - log(PRID))
Overview
Validate the INFP variable.
INFP = 100 * (log(PRID) - log(PRDL))
Overview
Validate the INFL variable in the G-Cubed model database by checking its consistency with other variables.
Overview
Check similarity of INFL and INFCL inflation rates
Overview
Validate the INFCL variable in the G-Cubed model database by checking its consistency with other variables.
Overview
Validate the INFP variable in the G-Cubed model database by checking its consistency with other variables.
Overview
Validate the WAGE_INFLATION variable in the G-Cubed model database by checking its consistency with other variables.
Overview
Validate the OUTP variable in the G-Cubed model database by checking its consistency with other variables.
Overview
LEAD(LAM) = (1+INTR+RISE+delta)*LAM
- (1-TCOR)*(PRK/PRID)
- (1-TITC)*(PRII/PRID)*(phi/2)*(JNV/CAP)^2 ;
Overview
Validate the EYGR variable in the G-Cubed model database by checking its consistency with other variables.
EYGR = 100 * (log(lead(OUTP)) - log(OUTP))
Overview
Validate the WELH variable in the G-Cubed model database by checking its consistency with other variables.
lead(WELH) = (
(1 + RISW + RISH + INTR - labgrow)*WELH
- TRAN
+ TAXH
+ TAXL
- ( exp(WAGE)*(IITL+CNPL) + exp(WAGG)*GOVL + sum(sec_std,exp(WAG)*LAB) ) / exp(PRID)
) ;
Overview
EYGREUR = ln(lead(OUTPEUR)) - ln(OUTPEUR) ;
Overview
NGOEUR = ln( sum(regions, eurowt * ( (OUTP-TBAL)*exp(PRID) ) ) ) ;
Overview
Validate the G-Cubed model database by checking the consistency of various variables and their relationships.
Overview
Validate the European variables in the G-Cubed model database by checking their relationships and consistency.
Overview
Generate investment to capital ratios by sector for the G-Cubed model database.
The values are to be interpreted as percentages, so they are multiplied by 100. A value of 10 means that investment is 10% of capital.
This function calculates the investment to capital ratios for each sector in the G-Cubed model database. It uses the investment (INV) and capital (CAP) variables to compute the ratios and stores them in a new variable.
Overview
Generate output to domestic output ratios by sector for the G-Cubed model database.
The values are to be interpreted as percentages, so they are multiplied by 100. A value of 10 means that output is 10% of domestic output.
This function calculates the output to domestic output ratios for each sector in the G-Cubed model database. It uses the output (OUTP) and domestic output (OUTD) variables to compute the ratios and stores them in a new variable.
Values should be greater than 100 %.
Overview
Generate metrics for the G-Cubed model database to assess the consistency and relationships of various variables.