new_k_ps | R Documentation |
This function calculates the effect of changing perfectly-substitutable (ps) inputs
to an intermediate industry.
New versions of U
and V
matrices are returned
as U_prime
and V_prime
.
Changes are made upstream of the changed industry inputs.
The final demand matrix (Y
) is unchanged.
new_k_ps(
.sutmats = NULL,
k_prime = "k_prime",
R = "R",
U = "U",
V = "V",
Y = "Y",
K = "K",
L_ixp = "L_ixp",
L_pxp = "L_pxp",
Z = "Z",
D = "D",
f = "f",
R_prime = "R_prime",
U_prime = "U_prime",
V_prime = "V_prime"
)
.sutmats |
a data frame of supply-use table matrices with matrices arranged in columns. |
k_prime |
a new column vector for the |
R |
resource ( |
U |
use ( |
V |
make ( |
Y |
final demand ( |
K |
a |
L_ixp |
an ( |
L_pxp |
an ( |
Z |
a |
D |
a |
f |
an |
R_prime |
name for the |
U_prime |
name for the |
V_prime |
name for the |
Note that inputs K
, L_ixp
, L_pxp
,
Z
, D
, and f
can be
conveniently calculated by the function calc_io_mats()
.
Internally, this function uses matsindf::matsindf_apply()
,
and documentation assumes that
.sutmats
is not NULL
and is a data frame.
If .sutmats
is present, output is a data frame with columns named by string values of output arguments, and
input arguments should be character strings that name columns in .sutmats
.
If .sutmats
is NULL
(the default), output is a list with items named by output strings,
and input arguments should be single matrices or vectors.
a list or data frame containing U_prime
and V_prime
matrices
library(dplyr)
library(matsbyname)
library(tidyr)
# To demonstrate calculating changes to an energy conversion chain due to changes
# in perfectly-substitutable inputs to an intermediate industry,
# we use the PerfectSubmats data frame.
# But we need to calculate several important input-output matrices first.
io_mats <- PerfectSubmats %>%
tidyr::spread(key = "matrix.name", value = "matrix") %>%
calc_io_mats()
# Next, find the K matrix that contains the fraction of each type of energy
# that enters each industry
K <- io_mats$K[[1]]
# Develop a new column vector for inputs to the Electric transport sector.
# As provided, the Electric transport sector is dominated by Renewable elec.
# What if the electricity input to the Electric transport sector
# were split 50/50 between Renewable elect and FF elec?
k_prime_vec <- K[, "Electric transport", drop = FALSE]
k_prime_vec["FF elec", "Electric transport"] <- 0.5
k_prime_vec["Ren elec", "Electric transport"] <- 0.5
# Add k_prime_vec to the io_mats data frame.
io_mats <- io_mats %>%
dplyr::mutate(
# Set up a new k_prime vector for Electric transport.
# That vector will be used for the infininte substitution calculation.
k_prime = matsbyname::select_cols_byname(K,
retain_pattern = RCLabels::make_or_pattern("Electric transport",
pattern_type = "exact")),
k_prime = RCLabels::make_list(k_prime_vec, n = 1)
)
# Now do the calculation of U_prime and V_prime matrices.
new_UV <- new_k_ps(io_mats)
# There is much more FF extraction now than before.
io_mats$U[[1]]["FF", "FF extraction"]
new_UV$U_prime[[1]]["FF", "FF extraction"]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.