This function sends stock changes flows to a balancing matrix B. The Balancing matrix is akin to an additional final demand matrix, meaning that flows akin to final demand (i.e. where stocks increase) will be positive, while flows akin to supply (i.e. where stocks decrease) will be negative.

stock_changes_to_balancing(
  .tidy_iea_df,
  flow = IEATools::iea_cols$flow,
  matnames = IEATools::mat_meta_cols$matnames,
  e_dot = IEATools::iea_cols$e_dot,
  ledger_side = IEATools::iea_cols$ledger_side,
  stock_changes = IEATools::interface_industries$stock_changes,
  balancing_matrix = "B"
)

Arguments

.tidy_iea_df

The .tidy_iea_df for which Stock changes flows need to be sent to the Balancing matrix.

flow, e_dot, ledger_side

See IEATools::iea_cols.

matnames

The column name of the column having matrices names. Default is IEATools::mat_meta_cols$matnames.

stock_changes

The name of the Stock changes flows. Default is "Stock changes".

balancing_matrix

The name of the Balancing matrix. Default is "B".

Value

A .tidy_iea_df with Stock changes flows sent to the Balancing matrix.

Details

See the Balancing matrix vignette for more information. Note: one needs to add the column containing matrices names first, most likely using the IEATools::add_psut_matnames() function.

Examples

tidy_AB_data %>%
tibble::add_row(
Country = "A",
Method = "PCM",
Energy.type = "Energy",
Last.stage = "Final",
Year = 2018,
Ledger.side = "Supply",
Flow.aggregation.point = "Supply",
Flow = "Stock changes",
Product = "Crude oil",
Unit = "ktoe",
E.dot = 10
) %>%
IEATools::add_psut_matnames() %>%
stock_changes_to_balancing() %>%
dplyr::filter(stringr::str_detect(Flow, "Statistical differences")) %>%
print()
#> # A tibble: 0 × 12
#> # ℹ 12 variables: Country <chr>, Method <chr>, Energy.type <chr>,
#> #   Last.stage <chr>, Year <dbl>, Ledger.side <chr>,
#> #   Flow.aggregation.point <chr>, Flow <chr>, Product <chr>, Unit <chr>,
#> #   E.dot <dbl>, matnames <chr>