Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor updates to support two region disaggregation #328

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
6 changes: 4 additions & 2 deletions R/DisaggregateFunctions.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ disaggregateModel <- function (model){
#Disaggregating Crosswalk
model$crosswalk <- disaggregateMasterCrosswalk(model, disagg)

#Disaggregate Margins
model$Margins <- disaggregateMargins(model, disagg)
if (model$specs$IODataSource != "stateior") {
#Disaggregate Margins, one region models only see #290
model$Margins <- disaggregateMargins(model, disagg)
}
model$TaxLessSubsidies <- disaggregateTaxLessSubsidies(model, disagg)

# Transform model FinalDemand, DomesticFinalDemand, and InternationalTradeAdjustment to by-industry form
Expand Down
4 changes: 3 additions & 1 deletion R/StateiorFunctions.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
#' @return A list of two-region IO data of model iolevel and year.
getTwoRegionIOData <- function(model, dataname) {
# Define state, year and iolevel
alias <- ifelse(!is.na(model$specs$alias), model$specs$alias, NULL)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is an alias now part of a model specification file or was it added as a part of specs after reading in the spec file in and parsing it out of the model name?

if(!"US-DC" %in% model$specs$ModelRegionAcronyms) {
state <- state.name[state.abb == gsub(".*-", "", model$specs$ModelRegionAcronyms[1])]
} else {
state <- "District of Columbia"
}
# Define data file name
filename <- paste(lapply(c("TwoRegion", model$specs$BaseIOLevel, dataname,
model$specs$DisaggregationSpecs, model$specs$IOYear,
alias, model$specs$IOYear,
model$specs$IODataVersion),
function(x) x[!is.na(x)]), collapse = "_")
# Adjust filename to fit what is on the Data Commons
Expand All @@ -33,6 +34,7 @@ getTwoRegionIOData <- function(model, dataname) {
filename <- gsub(dataname, "UsewithTrade", filename)
}
# Load data
logging::loginfo(paste0("Loading ", filename))
TwoRegionIOData <- readRDS(loadDataCommonsfile(paste0("stateio/", filename, ".rds")))
# Keep SoI and RoUS only
TwoRegionIOData <- TwoRegionIOData[[state]]
Expand Down
9 changes: 9 additions & 0 deletions inst/extdata/disaggspecs/UtilityDisaggregation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Disaggregation:
22/US:
OriginalSectorCode: "22/US"
OriginalSectorName: "Utilities"
DisaggregationType: "Userdefined"
SectorFile: UtilityDisaggregation_Sectors.csv
MakeFile: UtilityDisaggregationSummary_Make.csv # Ratios from 2012 US Make table
UseFile: UtilityDisaggregationSummary_Use.csv # Ratios from 2012 US Use table
package: "useeior"
46 changes: 46 additions & 0 deletions inst/extdata/disaggspecs/UtilityDisaggregationSummary_Make.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
"IndustryCode","CommodityCode","PercentMake","Note"
"221100/US","221100/US",0.781090503048714,"IntersectionDisagg"
"221200/US","221100/US",0.000439612613365103,"IntersectionDisagg"
"221300/US","221100/US",0.00055830801897368,"IntersectionDisagg"
"221100/US","221200/US",0.0170679597139001,"IntersectionDisagg"
"221200/US","221200/US",0.174154734847652,"IntersectionDisagg"
"221300/US","221200/US",0.000153864414677786,"IntersectionDisagg"
"221100/US","221300/US",0.00225521270656298,"IntersectionDisagg"
"221200/US","221300/US",0,"IntersectionDisagg"
"221300/US","221300/US",0.0242798046361546,"IntersectionDisagg"
"486/US","221100/US",0,"CommodityDisagg"
"486/US","221200/US",1,"CommodityDisagg"
"486/US","221300/US",0,"CommodityDisagg"
"GFE/US","221100/US",1,"CommodityDisagg"
"GFE/US","221200/US",0,"CommodityDisagg"
"GFE/US","221300/US",0,"CommodityDisagg"
"GSLG/US","221100/US",0,"CommodityDisagg"
"GSLG/US","221200/US",0,"CommodityDisagg"
"GSLG/US","221300/US",1,"CommodityDisagg"
"GSLE/US","221100/US",0.485727541327864,"CommodityDisagg"
"GSLE/US","221200/US",0.0557712499694772,"CommodityDisagg"
"GSLE/US","221300/US",0.458501208702659,"CommodityDisagg"
"GFGN/US","221100/US",0,"CommodityDisagg"
"GFGN/US","221200/US",0,"CommodityDisagg"
"GFGN/US","221300/US",1,"CommodityDisagg"
"221100/US","211/US",0,"IndustryDisagg"
"221200/US","211/US",1,"IndustryDisagg"
"221300/US","211/US",0,"IndustryDisagg"
"221100/US","23/US",0.86417221937468,"IndustryDisagg"
"221200/US","23/US",0.13070220399795,"IndustryDisagg"
"221300/US","23/US",0.00512557662737058,"IndustryDisagg"
"221100/US","4A0/US",0.722222222222222,"IndustryDisagg"
"221200/US","4A0/US",0.222222222222222,"IndustryDisagg"
"221300/US","4A0/US",0.0555555555555556,"IndustryDisagg"
"221100/US","486/US",0.281609195402299,"IndustryDisagg"
"221200/US","486/US",0.718390804597701,"IndustryDisagg"
"221300/US","486/US",0,"IndustryDisagg"
"221100/US","5412OP/US",0.811023622047244,"IndustryDisagg"
"221200/US","5412OP/US",0.165354330708661,"IndustryDisagg"
"221300/US","5412OP/US",0.0236220472440945,"IndustryDisagg"
"221100/US","5415/US",0.748815165876777,"IndustryDisagg"
"221200/US","5415/US",0.23696682464455,"IndustryDisagg"
"221300/US","5415/US",0.014218009478673,"IndustryDisagg"
"221100/US","GSLE/US",0,"IndustryDisagg"
"221200/US","GSLE/US",0,"IndustryDisagg"
"221300/US","GSLE/US",1,"IndustryDisagg"
Loading
Loading