SyntheticGovernmentEntities¶
The SyntheticGovernmentEntities class is an abstract base class that serves as a container for preprocessed government entity data. It manages data about government entities that consume and invest in goods and services produced in the economy.
Core Functionality¶
The class organizes data about:
-
Government Consumption:
- Sectoral consumption patterns
- Consumption in local currency and USD
- Historical consumption growth trends
- Consumption model parameter estimation
-
Entity Structure:
- Number of government entities
- Entity size distribution
- Consumption allocation across entities
- Entity-industry relationships
-
Environmental Impact:
- Emissions from government consumption
- Fuel-specific emission tracking
Key Attributes¶
country_name: Country identifier for data collectionyear: Base year for data preprocessingnumber_of_entities: Number of government entitiesgov_entity_data: Main DataFrame containing entity informationgovernment_consumption_model: Model for projecting consumption growth
Main Methods¶
total_emissions: Property that calculates total CO2 emissions from government consumption activities
Implementation¶
Module for preprocessing synthetic government entity data.
This module provides a framework for preprocessing and organizing data about government entities that consume and invest in goods and services produced by the economy. Key preprocessing tasks include:
- Government Consumption Data:
- Sectoral consumption patterns
- Consumption in local currency and USD
- Historical consumption growth trends
-
Consumption model parameter estimation
-
Entity Structure:
- Number of government entities determination
- Entity size distribution
- Consumption allocation across entities
-
Entity-industry relationships
-
Environmental Impact:
- Emissions from government consumption
- Fuel-specific emission tracking
- Environmental policy parameters
Note
This module is NOT used for simulating government behavior. It only handles the preprocessing and organization of government entity data that will later be used to initialize behavioral models in the simulation package.
SyntheticGovernmentEntities
¶
Container for preprocessed government entity data.
This class organizes data about government entities that consume and invest in goods and services produced in the economy. It processes and structures data about consumption patterns, entity relationships, and environmental impact. It does NOT implement any government behavior - it only handles data preprocessing.
The preprocessing workflow includes: 1. Consumption Data Processing: - Historical consumption patterns by sector - Currency conversion and normalization - Growth trend analysis - Consumption model estimation
- Entity Structure Organization:
- Entity count determination based on economic size
- Consumption allocation across entities
- Industry relationship mapping
-
Size distribution calculation
-
Environmental Impact Processing:
- Emissions from consumption activities
- Fuel-type specific tracking
- Environmental policy parameters
- Impact distribution across entities
The government entity data is stored in a pandas DataFrame with columns
- Consumption in LCU: Entity consumption in local currency
- Consumption in USD: Entity consumption in US dollars
- Consumption Emissions: CO2 emissions from consumption (if tracked)
- {Fuel} Consumption Emissions: Fuel-specific emissions (if tracked)
Attributes:
| Name | Type | Description |
|---|---|---|
country_name |
str
|
Country identifier for data collection |
year |
int
|
Base year for data preprocessing |
number_of_entities |
int
|
Number of government entities |
gov_entity_data |
DataFrame
|
Preprocessed entity data |
government_consumption_model |
Optional[LinearRegression]
|
Model for projecting consumption growth patterns |
country_name = country_name
instance-attribute
¶
year = year
instance-attribute
¶
number_of_entities = number_of_entities
instance-attribute
¶
gov_entity_data = gov_entity_data
instance-attribute
¶
government_consumption_model = government_consumption_model
instance-attribute
¶
total_emissions
property
¶
Get total CO2 emissions from government consumption activities.
This property calculates the total emissions across all government entities based on their consumption patterns and the associated emission factors.
Returns:
| Type | Description |
|---|---|
|
pd.Series: Total emissions by government entity, with index matching the entity identifiers in gov_entity_data. |
__init__(country_name: str, year: int, number_of_entities: int, gov_entity_data: pd.DataFrame, government_consumption_model: Optional[LinearRegression])
abstractmethod
¶
DefaultSyntheticGovernmentEntities¶
DefaultSyntheticGovernmentEntities is a concrete implementation of SyntheticGovernmentEntities that provides preprocessing of government entity data using standard data sources. This class handles the initialization and organization of data that will be used to initialize behavioral models in the simulation package.
Data Source Integration¶
The class integrates data from multiple sources:
- OECD business demography statistics
- National accounts government consumption data
- Industry-level consumption patterns
- Environmental impact factors
Initial State Processing¶
The class processes:
- Entity count calculation based on economic size
- Consumption allocation by industry
- Size-based distribution
- Growth rate calculation
Parameter Estimation¶
Key parameters estimated include:
- Government consumption growth model
- Entity size distribution
- Industry-specific consumption patterns
- Environmental impact factors
Factory Methods¶
The class provides a factory method from_readers that creates a DefaultSyntheticGovernmentEntities instance by:
- Reading and processing data from various sources
- Calculating entity counts and distributions
- Setting up initial state data
- Estimating growth models if requested
- Processing environmental impact data if provided
Implementation¶
Module for preprocessing default synthetic government entity data.
This module provides a default implementation for preprocessing government entity data using standard data sources such as OECD and national accounts. It handles the organization of government consumption and investment data using commonly available economic statistics.
DefaultSyntheticGovernmentEntities
¶
Default implementation for preprocessing government entity data.
This class provides a standard implementation for processing government entity data using common data sources like OECD statistics and national accounts. It organizes data about government consumption, investment, and environmental impact using widely available economic indicators.
The preprocessing workflow includes: 1. Data Collection: - OECD business demography statistics - National accounts government consumption data - Industry-level consumption patterns - Environmental impact factors
- Entity Structure:
- Entity count calculation based on economic size
- Optional single-entity consolidation
- Consumption allocation by industry
-
Size-based distribution
-
Growth Model:
- Historical consumption pattern analysis
- Growth rate calculation
- Linear regression model estimation
-
Future consumption projection parameters
-
Environmental Impact:
- Fuel-specific consumption tracking
- Emission factor application
- Industry-specific impact calculation
- Total emissions aggregation
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
country_name
|
Country
|
Country identifier for data collection |
required |
year
|
int
|
Base year for preprocessing |
required |
number_of_entities
|
int
|
Number of government entities |
required |
gov_entity_data
|
DataFrame
|
Preprocessed entity data |
required |
government_consumption_model
|
Optional[LinearRegression]
|
Model for projecting consumption growth patterns |
None
|
Note
This implementation uses default data sources and standard preprocessing methods. For specialized preprocessing needs, create a new implementation of the base SyntheticGovernmentEntities class.
__init__(country_name: Country, year: int, number_of_entities: int, gov_entity_data: pd.DataFrame, government_consumption_model: Optional[LinearRegression] = None)
¶
from_readers(readers: DataReaders, country_name: Country, year: int, quarter: int, exogenous_country_data: ExogenousCountryData, industry_data: dict[str, pd.DataFrame], single_government_entity: bool, create_model: bool = False, emission_factors: Optional[EmissionsData] = None)
classmethod
¶
Create preprocessed government entity data from standard data sources.
This method processes government entity data using default data sources: 1. Extracts historical consumption from national accounts 2. Calculates growth rates and estimates model parameters 3. Determines entity count based on economic indicators 4. Processes industry-specific consumption patterns 5. Applies emission factors if environmental tracking is enabled
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
readers
|
DataReaders
|
Access to standard data sources |
required |
country_name
|
Country
|
Country to process data for |
required |
year
|
int
|
Base year for preprocessing |
required |
quarter
|
int
|
Base quarter for preprocessing |
required |
exogenous_country_data
|
ExogenousCountryData
|
External economic data |
required |
industry_data
|
dict[str, DataFrame]
|
Industry-level statistics |
required |
single_government_entity
|
bool
|
Whether to consolidate into one entity |
required |
create_model
|
bool
|
Whether to estimate growth model. Defaults to False |
False
|
emission_factors
|
Optional[EmissionsData]
|
Environmental impact data |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
DefaultSyntheticGovernmentEntities |
Container with preprocessed data |