From 62c5a02cd0c230bf0cdd6cf8dcfc8f0c26572761 Mon Sep 17 00:00:00 2001 From: Mo Li Date: Fri, 31 Mar 2023 08:04:54 -0700 Subject: [PATCH 01/11] Add StateIO paper badge in README --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 9267a294..7e5ba4ef 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ [![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) +[![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. From de0d546d7c759974bf7c1880dc61b287c2a16e05 Mon Sep 17 00:00:00 2001 From: Wesley Ingwersen Date: Fri, 31 Mar 2023 13:24:32 -0400 Subject: [PATCH 02/11] Update README.md add reference to paper in text --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 7e5ba4ef..b2f0bb55 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ 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 State IO 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. From f821328b7db1a1d9e999b97eebe71f64f302f283 Mon Sep 17 00:00:00 2001 From: Wesley Ingwersen Date: Fri, 31 Mar 2023 13:24:58 -0400 Subject: [PATCH 03/11] fix space --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b2f0bb55..7af5e99d 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ 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 State IO models is described in a [paper in International Regional Science Review](https://doi.org/10.1177/01600176221145874). +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. From 0a389fdc01f6a53862965b5901bd42d0bff46387 Mon Sep 17 00:00:00 2001 From: Ben Young Date: Tue, 6 Jun 2023 15:09:15 -0400 Subject: [PATCH 04/11] add two region UsewithTrade to model outputs --- R/BuildModel.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R/BuildModel.R b/R/BuildModel.R index 7a7bf688..fdd802fe 100644 --- a/R/BuildModel.R +++ b/R/BuildModel.R @@ -653,6 +653,7 @@ assembleTwoRegionIO <- function(year, iolevel) { ## 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")]) + From b650c04440701235389eb22f13f587b88f105839 Mon Sep 17 00:00:00 2001 From: Ben Young Date: Tue, 6 Jun 2023 15:09:15 -0400 Subject: [PATCH 05/11] add two region UsewithTrade to model outputs --- R/BuildModel.R | 1 + 1 file changed, 1 insertion(+) diff --git a/R/BuildModel.R b/R/BuildModel.R index 7a7bf688..fdd802fe 100644 --- a/R/BuildModel.R +++ b/R/BuildModel.R @@ -653,6 +653,7 @@ assembleTwoRegionIO <- function(year, iolevel) { ## 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")]) + From de7f2371d07c84257f453457ed4c3274af3a91e4 Mon Sep 17 00:00:00 2001 From: Ben Young Date: Mon, 17 Jul 2023 14:56:22 -0400 Subject: [PATCH 06/11] update data commons url --- R/UtilityFunctions.R | 8 ++++---- format_specs/OneRegionData.md | 2 +- format_specs/TwoRegionData.md | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/R/UtilityFunctions.R b/R/UtilityFunctions.R index f69f3790..3a663836 100644 --- a/R/UtilityFunctions.R +++ b/R/UtilityFunctions.R @@ -174,7 +174,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)) { @@ -197,7 +197,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"), @@ -251,7 +251,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) } @@ -296,7 +296,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/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. From 384aa6a10428ffc486bdc8c507925cfd9876db17 Mon Sep 17 00:00:00 2001 From: Ben Young Date: Mon, 7 Aug 2023 11:00:51 -0400 Subject: [PATCH 07/11] fix json file for zenodo --- .zenodo.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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" }, { From 03ac0e2ba0ea6a05506f7310e22f040bfaff3346 Mon Sep 17 00:00:00 2001 From: Ben Young Date: Mon, 7 Aug 2023 11:20:22 -0400 Subject: [PATCH 08/11] update DOI badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7af5e99d..164f07cf 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # 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) From 23264b58c0c94b23180f4c6c4b3d872dddc7774c Mon Sep 17 00:00:00 2001 From: Wesley Ingwersen Date: Wed, 10 Jan 2024 07:31:08 -0500 Subject: [PATCH 09/11] drop 'v' in front of version tag name --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 164f07cf..577db9c9 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ 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@0.2.0") library(stateior) ``` From e1b9b3617821463aa4a8b9547cfd579985d3bee7 Mon Sep 17 00:00:00 2001 From: Ben Young Date: Wed, 10 Jan 2024 21:56:39 -0500 Subject: [PATCH 10/11] sort data commons files by version resolves #32 --- R/UtilityFunctions.R | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/R/UtilityFunctions.R b/R/UtilityFunctions.R index 3a663836..21eb13ad 100644 --- a/R/UtilityFunctions.R +++ b/R/UtilityFunctions.R @@ -213,6 +213,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.")) From 37e1c1cd336728a4534eb526f877885a9b08537f Mon Sep 17 00:00:00 2001 From: Ben Young Date: Wed, 10 Jan 2024 22:00:31 -0500 Subject: [PATCH 11/11] update install instructions --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 577db9c9..fba50d71 100644 --- a/README.md +++ b/README.md @@ -30,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@0.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