Skip to content

Commit

Permalink
cleanup and update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
bl-young committed Nov 16, 2023
1 parent ad90e65 commit 634b1b3
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 39 deletions.
24 changes: 0 additions & 24 deletions R/IOFunctions.R
Original file line number Diff line number Diff line change
Expand Up @@ -174,19 +174,6 @@ calculateLeontiefInverse <- function(A) {
#' @param model, An EEIO model object with model specs and crosswalk table loaded
#' @return A Domestic Use table with rows as commodity codes and columns as industry and final demand codes
generateDomesticUse <- function(Use, model) {
# Load Import matrix

# if (model$specs$BaseIOLevel != "Sector") {
# Import <- get(paste(model$specs$BaseIOLevel, "Import",
# model$specs$IOYear, "BeforeRedef", sep = "_"))*1E6
# } else {
# # Load Summary level Import matrix
# Import <- get(paste("Summary_Import", model$specs$IOYear, "BeforeRedef", sep = "_"))*1E6
# # Aggregate Import from Summary to Sector
# Import <- as.data.frame(aggregateMatrix(as.matrix(Import), "Summary", "Sector", model))
# }
# Import <- Import[rownames(Use), colnames(Use)]

Import <- model$ImportMatrix
# Adjust Import matrix to BAS price if model is in BAS price
# Note: according to the documentation in BEA Import matrix, import values in
Expand Down Expand Up @@ -231,17 +218,6 @@ generateDomesticUse <- function(Use, model) {
#' @param model, An EEIO model object with model specs and crosswalk table loaded
#' @return An international trade adjustment vector with names as commodity codes
generateInternationalTradeAdjustmentVector <- function(Use, model) {
# Load Import matrix

# if (model$specs$BaseIOLevel!="Sector") {
# Import <- get(paste(model$specs$BaseIOLevel, "Import", model$specs$IOYear, "BeforeRedef", sep = "_"))*1E6
# } else {
# # Load Summary level Import matrix
# Import <- get(paste("Summary_Import", model$specs$IOYear, "BeforeRedef", sep = "_"))*1E6
# # Aggregate Import from Summary to Sector
# Import <- as.data.frame(aggregateMatrix(as.matrix(Import), "Summary", "Sector", model))
# }

Import <- model$ImportMatrix
# Define Import code
ImportCode <- getVectorOfCodes(model$specs$BaseIOSchema, model$specs$BaseIOLevel, "Import")
Expand Down
8 changes: 3 additions & 5 deletions R/LoadExternalImportFactors.R
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# Functions for loading external import factors

#' Prepare economic components of an EEIO form USEEIO model.
#' Load and prepare import coefficients
#' @param model An EEIO form USEEIO model object with model specs loaded
#' @param configpaths str vector, paths (including file name) of model configuration file
#' If NULL, built-in config files are used.
#' @return A list with EEIO form USEEIO model economic components.
loadExternalImportFactors <- function(model, configpaths = NULL) {
#' @return M_m, matrix of import coefficients (flow x sector).
loadExternalImportFactors <- function(model) {

# Read in file with Import factors
IFSpec <- model$specs$ImportFactors[[1]]
Expand Down
3 changes: 1 addition & 2 deletions R/LoadIOTables.R
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ loadNationalIOData <- function(model, io_codes) {
io_codes$FinalDemandCodes <- colnames(BEA$FinalDemand)

BEA$ImportMatrix <- loadImportMatrix(model, io_codes)
model$ImportMatrix <- BEA$ImportMatrix

# Generate domestic Use transaction and final demand
DomesticUse <- generateDomesticUse(cbind(BEA$UseTransactions, BEA$FinalDemand), model)
Expand Down Expand Up @@ -295,7 +294,7 @@ loadBEAtables <- function(specs, io_codes) {
#' Load, format, and save import matrix as a USEEIO model object.
#' @param model A model object with model specs loaded.
#' @param io_codes A list of BEA IO codes.
#' @return A USEEIO model with import matrix object.
#' @return Import, a use table import matrix.
loadImportMatrix <- function(model, io_codes) {
# Load Import matrix
if (model$specs$BaseIOLevel != "Sector") {
Expand Down
2 changes: 1 addition & 1 deletion man/calculateAndValidateImportA.Rd

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

11 changes: 4 additions & 7 deletions man/loadExternalImportFactors.Rd

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

19 changes: 19 additions & 0 deletions man/loadImportMatrix.Rd

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

0 comments on commit 634b1b3

Please sign in to comment.