new_R_ps | R Documentation |
This function calculates the effect of changing the resources available to an ECC,
i.e. of a new resources matrix R_prime on the rest of the ECC matrices (U, V, W, and Y).
New versions of the U, V, W, and Y matrices are returned,
and respectively called U_prime
, V_prime
, W_prime
, and Y_prime
.
This function assumes that each industry's inputs are perfectly substitutable (ps).
new_R_ps(
.sutmats = NULL,
method = c("solve", "QR", "SVD"),
tol = .Machine$double.eps,
R_prime = "R_prime",
U = "U",
U_feed = "U_feed",
V = "V",
Y = "Y",
q = "q",
f = "f",
G_pxp = "G_pxp",
G_ixp = "G_ixp",
O_s = "O_s",
D_s = "D_s",
D_feed_s = "D_feed_s",
Z_s = "Z_s",
U_prime = "U_prime",
U_feed_prime = "U_feed_prime",
U_eiou_prime = "U_EIOU_prime",
r_eiou_prime = "r_EIOU_prime",
V_prime = "V_prime",
Y_prime = "Y_prime"
)
.sutmats |
a data frame of supply-use table matrices with matrices arranged in columns. |
method |
One of "solve", "QR", or "SVD". Default is "solve". See details. |
tol |
The tolerance for detecting linear dependencies during matrix inversion.
Default is |
R_prime |
The name of the new R matrix column in the input data frame, for which the new ECC must be assessed. Default is "R_prime". |
U |
The name of the U matrix column in the input data frame. Default is "U". |
U_feed |
The name of the U_feed matrix column in the input data frame. Default is "U_feed". |
V |
The name of the V matrix column in the input data frame. Default is "V". |
Y |
The name of the Y matrix column in the input data frame. Default is "Y". |
q |
The name of the q vector column in the input data frame. Default is "q". |
f |
The name of the f vector column in the input data frame. Default is "f". |
G_pxp |
The name of the G_pxp matrix column in the input data frame. Default is "G_pxp". |
G_ixp |
The name of the G_ixp matrix column in the input data frame. Default is "G_ixp". |
O_s |
The name of the O_s matrix column in the input data frame. Default is "O_s", where "_s" indicates supply-sided. |
D_s |
The name of the D_s matrix column in the input data frame. Default is "D_s", where "_s" indicates supply-sided. |
D_feed_s |
The name of the D_feed_s matrix column in the input data frame. Default is "D_feed_s", where "_s" indicates supply-sided. |
Z_s |
The name of the Z_s matrix column in the input data frame. Default is "Z_s", where "_s" indicates supply-sided. |
U_prime |
The name of the output column containing the new U matrices. Default is "U_prime". |
U_feed_prime |
The name of the output column containing the new U_feed matrices. Default is "U_feed_prime". |
U_eiou_prime |
The name of the output column containing the new U_EIOU matrices. Default is "U_EIOU_prime". |
r_eiou_prime |
The name of the output column containing the new r_EIOU matrices. Default is "r_EIOU_prime". |
V_prime |
The name of the output column containing the new V matrices. Default is "V_prime". |
Y_prime |
The name of the output column containing the new Y matrices. Default is "Y_prime". |
Each industry must be unit-homogeneous on its inputs.
If not, a matrix populated with NA
is returned as the result for
U_prime, V_prime, and Y_prime.
Calculating the new matrices requires
a matrix inversion operation.
The method
argument specifies which method should be used for
calculating the inverse.
"solve" uses base::solve()
and the value of tol
.
"QR" uses base::solve.qr()
and the value of tol
.
"SVD" uses matrixcalc::svd.inverse()
, ignoring the tol
argument.
Both tol
and method
should be a single values and apply to all matrices in a
.
A data frame with added columns representing each of the new U_prime, U_feed_prime, U_EIOU_prime, r_EIOU_prime, V_prime, and Y_prime matrices.
UKEnergy2000mats %>%
tidyr::spread(key = "matrix.name", value = "matrix") %>%
# When LastStage is "services", we get units problems.
# Avoid by using only ECCs with "Final" and "Useful" as the LastStage.
dplyr::filter(LastStage != IEATools::last_stages$services) %>%
# Calculate the input-output matrices which are inputs to the new_R function.
calc_io_mats(direction = "downstream") %>%
# Make an R_prime matrix that gives twice the resource inputs to the economy.
dplyr::mutate(
R_prime = matsbyname::hadamardproduct_byname(2, R)
) %>%
# Now call new_R_ps() which will calculate
# updated U, V, and Y matrices (U_prime, V_prime, and Y_prime)
# given R_prime.
# Each of the *_prime matrices should be 2x their originals,
# because R_prime is 2x relative to R.
new_R_ps()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.