balancing_matrix.Rmd
In this vignette we show how to use the balancing matrix B to modify the Energy Conversion Chain.
The balancing matrix is an extension of the original Physical Supply Use Table (PSUT) framework (see Heun, Owen, and Brockway (2018)) and has been introduced in Aramendia et al. (2022). The figure below shows the expanded PSUT framework with the balancing B matrix.
Warning: Before detailing further the use of the balancing matrix, the user needs to be aware that its use makes more complex the conduction of downstream Input-Output analysis (for instance with the Recca
package). Indeed, by relocating flows to the balancing matrix, one is changing the definition of the matrices and vectors structuring the PSUT. Vectors may then be defined differently with a supply and with a consumption perspective. So, while the use of the B matrix may prove helpful, we recommend its use only if the implications of the given use are fully understood. We also recommend reading the paper that introduces the B matrix (Aramendia et al. (2022)).
The B matrix enables analysts to:
To scale up or down the supply of a given industry i by a factor \(\lambda\), one can proceed according to the table below, extracted from Aramendia et al. (2022) .
To modify the final demand without loosing energy balance, one can simply redirect energy flows belonging to the final demand (Y matrix) to the balancing matrix B.
Let us use the AB world example introduced in the Get started vignette, but let us add flows, so that:
# Fix product-level balances within each country
tidy_AB_data_added_flows <- tidy_AB_data %>%
# First, adding statistical differences providing 100 ktoe of crude oil in country A:
tibble::add_row(Country = "A", Method = "PCM", Energy.type = "E", Last.stage = "Final", Year = 2018,
Ledger.side = "Supply", Flow.aggregation.point = "TFC compare",
Flow = "Statistical differences", Product = "Crude oil", Unit = "ktoe", E.dot = 100) %>%
# Second, adding the submarine race organised in country A:
tibble::add_row(Country = "A", Method = "PCM", Energy.type = "E", Last.stage = "Final", Year = 2018,
Ledger.side = "Consumption", Flow.aggregation.point = "Industry",
Flow = "Submarine race", Product = "Crude oil", Unit = "ktoe", E.dot = 100) %>%
# Third, adding the stock changes supplying 400 ktoe of coke oven coke in country B:
tibble::add_row(Country = "B", Method = "PCM", Energy.type = "E", Last.stage = "Final", Year = 2018,
Ledger.side = "Supply", Flow.aggregation.point = "Total primary energy supply",
Flow = "Stock changes", Product = "Coke oven coke", Unit = "ktoe", E.dot = 400) %>%
# Fourth, adding the bonfire sessions in country B:
tibble::add_row(Country = "B", Method = "PCM", Energy.type = "E", Last.stage = "Final", Year = 2018,
Ledger.side = "Consumption", Flow.aggregation.point = "Industry",
Flow = "Bonfires", Product = "Coke oven coke", Unit = "ktoe", E.dot = 400) %>%
# Fifth, adding stock build-up of 200 ktoe of coke oven coke in country A
tibble::add_row(Country = "A", Method = "PCM", Energy.type = "E", Last.stage = "Final", Year = 2018,
Ledger.side = "Supply", Flow.aggregation.point = "Total primary energy supply",
Flow = "Stock changes", Product = "Coke oven coke", Unit = "ktoe", E.dot = -200) %>%
# Sixth, adding imports of 200 ktoe of coke oven coke by country A
tibble::add_row(Country = "A", Method = "PCM", Energy.type = "E", Last.stage = "Final", Year = 2018,
Ledger.side = "Supply", Flow.aggregation.point = "Total primary energy supply",
Flow = "Imports [of Coke oven coke]", Product = "Coke oven coke", Unit = "ktoe", E.dot = 200) %>%
dplyr::glimpse()
## Rows: 108
## Columns: 11
## $ Country <chr> "A", "A", "A", "A", "A", "A", "A", "A", "A", "A…
## $ Method <chr> "PCM", "PCM", "PCM", "PCM", "PCM", "PCM", "PCM"…
## $ Energy.type <chr> "E", "E", "E", "E", "E", "E", "E", "E", "E", "E…
## $ Last.stage <chr> "Final", "Final", "Final", "Final", "Final", "F…
## $ Year <dbl> 2018, 2018, 2018, 2018, 2018, 2018, 2018, 2018,…
## $ Ledger.side <chr> "Consumption", "Consumption", "Consumption", "C…
## $ Flow.aggregation.point <chr> "Industry", "Industry", "Industry", "Industry",…
## $ Flow <chr> "Iron and steel", "Iron and steel", "Iron and s…
## $ Product <chr> "Blast furnace gas", "Electricity", "Heat", "Ke…
## $ Unit <chr> "ktoe", "ktoe", "ktoe", "ktoe", "ktoe", "ktoe",…
## $ E.dot <dbl> 500, 2920, 50, 1750, 500, 365, 200, 120, 700, 2…
We can now verify that the adjusted ECC remains balanced:
# Fix product-level balances within each country
tidy_AB_data_added_flows %>%
IEATools::calc_tidy_iea_df_balances() %>%
IEATools::tidy_iea_df_balanced()
## [1] TRUE
Now, let’s assume that we want to modify the given ECC as follows:
Note: Statistical differences and stock changes will not necessarily need to be relocated to the balancing B matrix. This is an option available to the analyst that we use here as example, which may prove appropriate in some situations and for some purposes.
We will make use of the following functions:
IEATools::add_psut_matnames()
will add a column stating the matrix to which each flow belongs (function belonging to the IEATools
package);stat_diffs_to_balancing()
will move statistical difference flows, whether they are supply or use flows, to the balancing B matrix;stock_changes_to_balancing()
will move stock changes flows, whether they are supply or use flows, to the balancing B matrix.The code is as follows:
tidy_AB_data_relocated_flows <- tidy_AB_data_added_flows %>%
IEATools::add_psut_matnames() %>%
stat_diffs_to_balancing() %>%
stock_changes_to_balancing() %>%
dplyr::glimpse()
## Rows: 108
## Columns: 12
## $ Country <chr> "A", "A", "A", "A", "A", "A", "A", "A", "A", "A…
## $ Method <chr> "PCM", "PCM", "PCM", "PCM", "PCM", "PCM", "PCM"…
## $ Energy.type <chr> "E", "E", "E", "E", "E", "E", "E", "E", "E", "E…
## $ Last.stage <chr> "Final", "Final", "Final", "Final", "Final", "F…
## $ Year <dbl> 2018, 2018, 2018, 2018, 2018, 2018, 2018, 2018,…
## $ Ledger.side <chr> "Consumption", "Consumption", "Consumption", "C…
## $ Flow.aggregation.point <chr> "Industry", "Industry", "Industry", "Industry",…
## $ Flow <chr> "Iron and steel", "Iron and steel", "Iron and s…
## $ Product <chr> "Blast furnace gas", "Electricity", "Heat", "Ke…
## $ Unit <chr> "ktoe", "ktoe", "ktoe", "ktoe", "ktoe", "ktoe",…
## $ E.dot <dbl> 500, 2920, 50, 1750, 500, 365, 200, 120, 700, 2…
## $ matnames <chr> "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y", "Y…
Now, we can see that the Statistical differences and Stock changes flows belong to the balancing B matrix:
tidy_AB_data_relocated_flows %>%
dplyr::filter(stringr::str_detect(Flow, "Statistical differences")) %>%
dplyr::glimpse()
## Rows: 1
## Columns: 12
## $ Country <chr> "A"
## $ Method <chr> "PCM"
## $ Energy.type <chr> "E"
## $ Last.stage <chr> "Final"
## $ Year <dbl> 2018
## $ Ledger.side <chr> "balancing"
## $ Flow.aggregation.point <chr> "TFC compare"
## $ Flow <chr> "Statistical differences"
## $ Product <chr> "Crude oil"
## $ Unit <chr> "ktoe"
## $ E.dot <dbl> -100
## $ matnames <chr> "B"
and:
tidy_AB_data_relocated_flows %>%
dplyr::filter(stringr::str_detect(Flow, "Stock changes")) %>%
dplyr::glimpse()
## Rows: 2
## Columns: 12
## $ Country <chr> "B", "A"
## $ Method <chr> "PCM", "PCM"
## $ Energy.type <chr> "E", "E"
## $ Last.stage <chr> "Final", "Final"
## $ Year <dbl> 2018, 2018
## $ Ledger.side <chr> "balancing", "balancing"
## $ Flow.aggregation.point <chr> "Total primary energy supply", "Total primary e…
## $ Flow <chr> "Stock changes", "Stock changes"
## $ Product <chr> "Coke oven coke", "Coke oven coke"
## $ Unit <chr> "ktoe", "ktoe"
## $ E.dot <dbl> -400, 200
## $ matnames <chr> "B", "B"
Finally, let’s verify that the Energy Conversion Chain remains balanced once flows are relocated to the balancing B matrix:
tidy_AB_data_relocated_flows %>%
IEATools::calc_tidy_iea_df_balances() %>%
IEATools::tidy_iea_df_balanced()
## [1] TRUE
Note regarding the sign convention in the balancing matrix: Flow appearing as positive in the B matrix are akin to final demand flows. For instance, final demand flows relocated to B will be positive, a build-up in energy products stocks will be positive. Conversely, flows akin to supply will be registered as negative in B: for instance, flows removed from supply, energy products drawn from stocks, will all appear as negative values.
In conclusion, the analyst may use directly some functions directly available, such as stat_diffs_to_balancing()
and stock_changes_to_balancing()
. Alternatively, the analyst may directly relocate a flow to B by modifying the matrix name column of the flow that needs to be modified. Be careful with the sign convention!