Skip to content

Commit

Permalink
Merge pull request #324 from USEPA/M_withIEFs
Browse files Browse the repository at this point in the history
add new calculation for M matrix with IEFs
  • Loading branch information
bl-young authored Nov 1, 2024
2 parents 1d88467 + 70ea6d4 commit 28254f6
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
18 changes: 17 additions & 1 deletion R/ExternalImportFactors.R
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ castImportFactors <- function(IFTable, model) {
buildModelwithImportFactors <- function(model, configpaths = NULL) {
# (see Palm et al. 2019)

logging::loginfo("Building Import A (A_m) accounting for ITA in Domestic FD.\n")
logging::loginfo("Building A_m (import requirements) accounting for international trade adjustment in domestic final demand.\n")
# Re-derive import values in Use and final demand
# _m denotes import-related structures
model$UseTransactions_m <- model$UseTransactions - model$DomesticUseTransactions
Expand All @@ -126,5 +126,21 @@ buildModelwithImportFactors <- function(model, configpaths = NULL) {

model$M_m <- M_m

model$M <- calculateMwithImportFactors(model)

return(model)
}

#' Derives an M matrix for total embodied flows from domestic and imported supply chains.
#' @param model, An EEIO model object with model specs and crosswalk table loaded
#' @return An M matrix of flows x sector
calculateMwithImportFactors <- function(model) {
logging::loginfo("Calculating M matrix (total emissions and resource use per dollar) ...")

# embodied flows from the use of imports by industries to make their commodities
# both directly (from A_m) and indirectly (by scaling it to total requirements using L_d)
M_mi <- model$M_m %*% model$A_m %*% model$L_d

M <- model$M_d + M_mi
return(M)
}
17 changes: 17 additions & 0 deletions man/calculateMwithImportFactors.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 28254f6

Please sign in to comment.