Fill missing U and V matrices
replace_null_UV.Rd
In some cases (e.g., bunkers where Last.stage
is "final"),
U, U_feed, U_EIOU, and V matrices can be missing, because
Imports (which appear in the R matrix) are consumed directly
in the final demand (Y) matrix,
without any intermediate processing.
When a data frame is pivoted wider by matrices,
the U_feed, U_EIOU, r_EIOU, and V columns
will contain NULL
entries.
This function fills those NULL
entries with reasonable defaults.
Usage
replace_null_UV(
.sutmats = NULL,
R = IEATools::psut_cols$R,
U_feed = IEATools::psut_cols$U_feed,
U_eiou = IEATools::psut_cols$U_eiou,
U = IEATools::psut_cols$U,
r_eiou = IEATools::psut_cols$r_eiou,
V = IEATools::psut_cols$V,
Y = IEATools::psut_cols$Y,
manufacture = IEATools::transformation_processes$manufacture,
manufacture_notation = RCLabels::of_notation,
resources_ind_notation = RCLabels::of_notation,
raw_product_notation = RCLabels::from_notation,
.R_temp_name = ".R_temp",
.U_temp_name = ".U_temp",
.U_feed_temp_name = ".U_feed_temp",
.U_eiou_temp_name = ".U_EIOU_temp",
.r_eiou_temp_name = ".r_EIOU_temp",
.V_temp_name = ".V_temp",
R_name = IEATools::psut_cols$R,
U_name = IEATools::psut_cols$U,
U_feed_name = IEATools::psut_cols$U_feed,
U_eiou_name = IEATools::psut_cols$U_eiou,
r_eiou_name = IEATools::psut_cols$r_eiou,
V_name = IEATools::psut_cols$V,
tol = 1e-06
)
Arguments
- .sutmats
A data frame of metadata columns and named matrix columns
- R, U_feed, U_eiou, U, r_eiou, V, Y
See
IEATools::psutcols
. Default values are names for variables incoming with.sutmats
. Can be overridden with actual matrices.- manufacture
The string name of the "Manufacture" industry. Default is
IEATools::transformation_processes$manufacture
.- manufacture_notation, resources_ind_notation, raw_product_notation
Row and column label notations for the manufacture industry, the resources industry, and raw material products. Defaults are
RCLabels::of_notation
,RCLabels::of_notation
, andRCLabels::from_notation
.- .R_temp_name, .U_temp_name, .U_feed_temp_name, .U_eiou_temp_name, .r_eiou_temp_name, .V_temp_name
Names of temporary variables unused internally to the function.
- R_name, U_name, U_feed_name, U_eiou_name, r_eiou_name, V_name
See
IEATools::psutcols
. The final names for matrices in the output.- tol
The tolerance for deciding whether energy flows are in balance. Default is
1e-6
.
Value
A version of .sutmats
with R, U, U_feed, U_EIOU, or V
filled with 0 matrices if they were missing.
Details
Reasonable defaults are obtained by introducing one new industry for each product in the R and Y matrices. The new industry is called "Manufacture [of XYZ]", where "XYZ" is the name of the product. The new "Manufacture" industries have 100% efficiency.
Examples
# Set up a PSUT data frame with NULL for
# U_feed, U_EIOU, and V in 1971 for GHA.
R <- matrix(c(10, 0,
0, 200), nrow = 2, ncol = 2, byrow = TRUE,
dimnames = list(c("Imports [of Fuel oil]",
"Imports [of Aviation gasoline]"),
c("Fuel oil", "Aviation gasoline")))
Y <- matrix(c(10, 0,
0, 200), nrow = 2, ncol = 2, byrow = TRUE,
dimnames = list(c( "Fuel oil", "Aviation gasoline"),
c("International marine bunkers",
"International aviation bunkers")))
# Replace the missing **U** and **V** matrices.
replace_null_UV(R = R, Y = Y)
#> $R
#> Fuel oil [from Imports]
#> Imports [of Fuel oil] 10
#> Imports [of Aviation gasoline] 0
#> Aviation gasoline [from Imports]
#> Imports [of Fuel oil] 0
#> Imports [of Aviation gasoline] 200
#>
#> $U
#> Manufacture [of Fuel oil]
#> Fuel oil [from Imports] 10
#> Aviation gasoline [from Imports] 0
#> Manufacture [of Aviation gasoline]
#> Fuel oil [from Imports] 0
#> Aviation gasoline [from Imports] 200
#>
#> $U_feed
#> Manufacture [of Fuel oil]
#> Fuel oil [from Imports] 10
#> Aviation gasoline [from Imports] 0
#> Manufacture [of Aviation gasoline]
#> Fuel oil [from Imports] 0
#> Aviation gasoline [from Imports] 200
#>
#> $U_EIOU
#> Manufacture [of Aviation gasoline]
#> Aviation gasoline [from Imports] 0
#> Fuel oil [from Imports] 0
#> Manufacture [of Fuel oil]
#> Aviation gasoline [from Imports] 0
#> Fuel oil [from Imports] 0
#>
#> $r_EIOU
#> Manufacture [of Aviation gasoline]
#> Aviation gasoline [from Imports] 0
#> Fuel oil [from Imports] 0
#> Manufacture [of Fuel oil]
#> Aviation gasoline [from Imports] 0
#> Fuel oil [from Imports] 0
#>
#> $V
#> Fuel oil Aviation gasoline
#> Manufacture [of Fuel oil] 10 0
#> Manufacture [of Aviation gasoline] 0 200
#>