diff --git a/.zenodo.json b/.zenodo.json
index 03c8cbd8..a151aecc 100644
--- a/.zenodo.json
+++ b/.zenodo.json
@@ -6,22 +6,22 @@
"creators": [
{
"affiliation": "General Dynamics Information Technology, Inc.",
- "name": "Mo Li"
+ "name": "Mo Li",
"orcid": "https://orcid.org/0000-0002-3672-1622"
},
{
"affiliation": "US Environmental Protection Agency",
- "name": "Wesley Ingwersen"
+ "name": "Wesley Ingwersen",
"orcid": "https://orcid.org/0000-0002-9614-701X"
},
{
"affiliation": "University of Florida",
- "name": "Joao-Pedro Ferreira"
+ "name": "Joao-Pedro Ferreira",
"orcid": "https://orcid.org/0000-0002-6726-7856"
},
{
"affiliation": "University of Florida",
- "name": "Christa Court"
+ "name": "Christa Court",
"orcid": "https://orcid.org/0000-0002-2690-9015"
},
{
diff --git a/R/BuildModel.R b/R/BuildModel.R
index 8b5b7145..0fee8fda 100644
--- a/R/BuildModel.R
+++ b/R/BuildModel.R
@@ -761,6 +761,7 @@ assembleTwoRegionIO <- function(year, iolevel, disagg_specs=NULL) {
## Two-region Domestic Use table with interregional exports and imports
TwoRegionIO[["DomesticUsewithTrade"]][[state]] <- TwoRegionDomesticUseModel[1:4]
+ TwoRegionIO[["UsewithTrade"]][[state]] <- TwoRegionUseModel[1:4]
## Two-region Commodity Output
SoI_CommodityOutput <- rowSums(TwoRegionDomesticUseModel[["SoI2SoI"]][, c(industries, FD_cols, ITA_col, "ExportResidual")]) +
diff --git a/R/UtilityFunctions.R b/R/UtilityFunctions.R
index 6a6c4fca..3636ce55 100644
--- a/R/UtilityFunctions.R
+++ b/R/UtilityFunctions.R
@@ -178,7 +178,7 @@ getFlowsaData <- function(dataname, year) {
# Define file directory
directory <- file.path(rappdirs::user_data_dir(), subdirectory)
if (!file.exists(file.path(directory, filename))) {
- url <- paste0("https://edap-ord-data-commons.s3.amazonaws.com/", subdirectory)
+ url <- paste0("https://dmap-data-commons-ord.s3.amazonaws.com/", subdirectory)
logging::loginfo(paste0("file not found, downloading from ", url))
# Check for and create directory if necessary
if (!file.exists(directory)) {
@@ -201,7 +201,7 @@ getFlowsaData <- function(dataname, year) {
#' "flowsa/FlowByActivity".
#' @return A dataframe of StateIO data registry on Data Commons.
getRegistryonDataCommons <- function(data_group = "stateio") {
- registry_ls <- aws.s3::get_bucket(bucket = "edap-ord-data-commons",
+ registry_ls <- aws.s3::get_bucket(bucket = "dmap-data-commons-ord",
prefix = data_group)
registry <- cbind.data.frame(basename(sapply(registry_ls, `[[`, "Key")),
sapply(registry_ls, `[[`, "LastModified"),
@@ -217,6 +217,10 @@ findLatestStateIODataonDataCommons <- function(filename) {
registry <- getRegistryonDataCommons(data_group = "stateio")
f <- registry[startsWith(registry$Key, filename) &
endsWith(registry$Key, ".rds"), ]
+ f$version <- sub(paste0(filename, "_"), "", f$Key)
+ f$version <- sub(".[^.]*$", "", f$version)
+ # sort so latest version on top in case of duplicate LastModified dates
+ f <- f[order(f$version, decreasing=TRUE), ]
f <- basename(f[which.max(as.Date(f$LastModified)), "Key"])
if (length(f) == 0) {
stop(paste(filename, "not avaialble on Data Commons."))
@@ -255,7 +259,7 @@ downloadStateIODatafromDataCommons <- function(filename, ver = NULL) {
f <- paste0(paste(filename, ver, sep = "_"), ".rds")
}
# Download file
- url <- "https://edap-ord-data-commons.s3.amazonaws.com/stateio"
+ url <- "https://dmap-data-commons-ord.s3.amazonaws.com/stateio"
utils::download.file(file.path(url, f),
file.path(directory, f), mode = "wb", quiet = TRUE)
}
@@ -300,7 +304,7 @@ loadStateIODataFile <- function(filename, ver = NULL) {
"not found in local data directory, either."))
message("Please confirm ", filename, " is correctly spelled. ",
"You should be able to find the correctly spelled file on ",
- "https://edap-ord-data-commons.s3.amazonaws.com/index.html?prefix=stateio/. ",
+ "https://dmap-data-commons-ord.s3.amazonaws.com/index.html?prefix=stateio/. ",
"If it's not found there, please open an issue at ",
"https://github.com/USEPA/stateior/issues/new ",
"and inform package maintainers.\n",
diff --git a/README.md b/README.md
index 9267a294..fba50d71 100644
--- a/README.md
+++ b/README.md
@@ -1,12 +1,15 @@
# stateior
[![R CI/CD test](https://github.com/USEPA/stateior/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/USEPA/stateior/actions/workflows/R-CMD-check.yaml)
-[![v0.1.0](http://img.shields.io/badge/v0.1.0-10.5281/zenodo.6954423-blue.svg)](https://doi.org/10.5281/zenodo.6954423)
+[![DOI](https://zenodo.org/badge/279373285.svg)](https://zenodo.org/badge/latestdoi/279373285)
+[![StateIO paper](http://img.shields.io/badge/StateIO%20paper-10.3390/app12094469-blue.svg)](https://doi.org/10.1177/01600176221145874)
+
`stateior` is an R package for building multi-regional economic input-output (MRIO) tables of states in the United States, refered to as **StateIO** models.
Currently, `stateior` is capable of creating IO tables for each US state and building two-region MRIO models based on those state IO tables at the [BEA](https://www.bea.gov/) Summary level of resolution in the US for all years from 2012-2020.
The two regions are State of Interest (SoI) and Rest of the US (RoUS).
`stateior` was initially conceived in support of creating state-specific versions of [USEEIO models](https://www.epa.gov/land-research/us-environmentally-extended-input-output-useeio-models), but may be used for other purposes where state input-output tables are used.
+The methodology used to build the StateIO models is described in a [paper in International Regional Science Review](https://doi.org/10.1177/01600176221145874).
The package is intended to add transparency and reproducibility to the complex process of generating subnational input-output tables, which are not compiled by any statistical agency.
`stateior` implements a robust commodity-industry modeling framework that models supply, use and trade of commodities by industries and final users in 50 U.S. states plus the District of Columbia and includes international import and export.
@@ -27,10 +30,15 @@ Install the most recent release version of `stateior` and attach it to the curre
```r
install.packages("devtools")
-devtools::install_github("USEPA/stateior@v0.2.0")
+devtools::install_github("USEPA/stateior")
library(stateior)
```
+```r
+# For a specific release:
+devtools::install_github("USEPA/stateior@0.2.1")
+```
+
Load desired StateIO data. See [One Region Data](format_specs/OneRegionData.md#data) and [Two Region Data](format_specs/TwoRegionData.md#data) for names and details of one- and two-region MRIO data sets that are currently available, respectively.
```r
diff --git a/format_specs/OneRegionData.md b/format_specs/OneRegionData.md
index ff6d75a8..840114ea 100644
--- a/format_specs/OneRegionData.md
+++ b/format_specs/OneRegionData.md
@@ -12,7 +12,7 @@ One region IO data created by `stateior` are data for single states saved as `.r
| Commodity Output | State_Summary_CommodityOutput_`year`_`version` | numeric vector | [Output Vectors](https://github.com/USEPA/useeior/blob/v1.1.0/format_specs/Model.md#output-vectors) |
| Industry Output | State_Summary_IndustryOutput_`year`_`version` | numeric vector | [Output Vectors](https://github.com/USEPA/useeior/blob/v1.1.0/format_specs/Model.md#output-vectors)|
-1 Data names on [Data Commons](https://edap-ord-data-commons.s3.amazonaws.com/index.html?prefix=stateio/). `year` and `version` are subject to change.
+1 Data names on [Data Commons](https://dmap-data-commons-ord.s3.amazonaws.com/index.html?prefix=stateio/). `year` and `version` are subject to change.
2 These Use tables add, as the final column, the international trade adjustment (ITA) containing the value of all transportation and insurance services and customs duties
diff --git a/format_specs/TwoRegionData.md b/format_specs/TwoRegionData.md
index c86e36b8..edc350cc 100644
--- a/format_specs/TwoRegionData.md
+++ b/format_specs/TwoRegionData.md
@@ -19,7 +19,7 @@ Each two-region matrix has a four-quadrant structure. In each matrix, `SoI` is r
| Commodity Output | TwoRegion_Summary_CommodityOutput_`year`_`version` | numeric vector | [Two-region total output by commodity](#Two-Region-Output-Vectors) |
| Industry Output | TwoRegion_Summary_IndustryOutput_`year`_`version` | numeric vector | [Two-region total output by industry](#Two-Region-Output-Vectors) |
-1 Data names on [Data Commons](https://edap-ord-data-commons.s3.amazonaws.com/index.html?prefix=stateio/). `year` and `version` are subject to change.
+1 Data names on [Data Commons](https://dmap-data-commons-ord.s3.amazonaws.com/index.html?prefix=stateio/). `year` and `version` are subject to change.
### Two Region Make
The two-region Make is an `industry x commodity` matrix with amounts of commodities (in model year USD) being made by industries.