Skip to content

Commit

Permalink
initial updates for import factors for two-region models
Browse files Browse the repository at this point in the history
  • Loading branch information
bl-young committed Nov 15, 2023
1 parent 1af3d6d commit 18e0638
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion R/IOFunctions.R
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,9 @@ buildModelwithImportFactors <- function(model) {

# Including InternationalTradeAdjustment in DomesticFinalDemand for import factors calculations
model$DomesticFDWithITA <- model$DomesticFinalDemand
model$DomesticFDWithITA[,"F050/US"] <- model$InternationalTradeAdjustment
if(model$specs$IODataSource != "stateior") {
model$DomesticFDWithITA[,"F050/US"] <- model$InternationalTradeAdjustment
}
model$ImportFinalDemand <- model$FinalDemand - model$DomesticFDWithITA

if(model$specs$CommodityorIndustryType == "Commodity") {
Expand Down
8 changes: 7 additions & 1 deletion R/LoadExternalImportFactors.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,19 @@ loadExternalImportFactors <- function(model, configpaths = NULL) {
# Convert from basic to producer price using TAU of CurrencyYear
Tau <- model$Tau[, as.character(meta$CurrencyYear)]
names(Tau) <- gsub("/.*","",names(Tau))
# For state models, keep only unique names
Tau <- Tau[unique(names(Tau))]
IFTable <- merge(IFTable, as.data.frame(Tau), by.x = 'Sector', by.y = 0, all.y = FALSE)
IFTable['FlowAmount'] <- IFTable['FlowAmount'] * IFTable['Tau']
IFTable['PriceType'] <- 'Producer'
IFTable['CurrencyYear'] <- model$specs$IOYear

if(model$specs$IODataSource =="stateior") {
#TODO
IFTable_SoI <- IFTable
IFTable_SoI['Location'] <- model$specs$ModelRegionAcronyms[[1]]
IFTable_RoUS <- IFTable
IFTable_RoUS['Location'] <- model$specs$ModelRegionAcronyms[[2]]
IFTable <- rbind(IFTable_SoI, IFTable_RoUS)
} else {
# assumes that if IODataSource is not stateior, it is a one a region model
IFTable['Location'] <- "US"
Expand Down

0 comments on commit 18e0638

Please sign in to comment.