# An Open-Source R Package for Building and Using US Environmentally-Extended Input-Output Models
## 1 Introduction
### Overview  
_useeior_ is an R package for building and using USEEIO models. It was created following the R packages design manual [12] and has advantages including, but not limited to, clear help pages for functions, convenient build checks, explicit dependency installation, and, most importantly, ease of sharing. Consolidating USEEIO model construction in _useeior_ not only provided full transparency of data, but also ensured reproducibility of the model. _useeior_ is actively developed and maintained in a public GitHub repository ([[https://github.com/USEPA/useeior](https://github.com/USEPA/useeior)]([https://github.com/USEPA/useeior](https://github.com/USEPA/useeior)), (accessed on 14 March 2022)), with a primary focus on constructing and enabling technical use of USEEIO models. Using GitHub as the project repository not only allows for a built-in method of version control, but also provides automated build and test checks for _useeior_, utilizing the continuous integration and continuous delivery (CI/CD) platform by GitHub Actions [13]. A configured GitHub Actions workflow, defined by R-CMD-check.yaml in the '.github/workflows/' folder, is triggered when an event occurs in the repository, such as a pushed commit or a pull request being opened and updated. In the workflow, a job to execute _R CMD check_ will \"run in sequential order or in parallel inside its own virtual machine _runner_, or inside a container\" [13]. The _R CMD check_ examines if the requirements for successfully building the R package are met, such as code, R dependencies, and documentation, and if the validation on a selection of models is successfully completed [12]. This check is a fundamental and easy-to-use quality assurance (QA) tool for _useeior_, and can be combined with more configured workflows to serve as the QA of _useeior_. _useeior_ builds USEEIO models according to a given model configuration/specification and optional hybridization specification, e.g., disaggregation and aggregation, and returns the primary output, _model_ object. A limited set of model specifications and associated hybridization specifications for EPA-validated models are included in the 'format_specs' folder in the package. The package offers various functions for calculating, validating, visualizing, and writing out models and/or their components. In _useeior_, underlying input-output (IO) tables, economic gross output data, and chain-type price indices (CPI) compiled by BEA are downloaded and pre-saved in native R data formats (rda) in the 'data/' folder, using the _usethis_ package [14], and made available for immediate use; other critical datasets, including sector crosswalk tables that map BEA sectors to the North American Industry Classification System (NAICS) industries, BEA sector code and name correspondence tables, and configuration files for model component attributes are also prepared and saved as.rda files in the 'data/' folder. Functions used to download, format, and save the.rda files are available in the 'data-raw/' folder. Model aggregation and disaggregation specifications, as well as supporting data, are available for optional use in the 'inst/extdata/' folder. Environmental flow data generated by FLOWSA [15], and life cycle impact assessment (LCIA) characterization factors generated by the LCIA formatter [16], can be specified for inclusion in a model and retrieved from the EPA Data Commons. Therefore, to build desired USEEIO models, users do not have to prepare data or LCIA factors; instead, they only need to choose from available models in _useeior_ to allow model building functions to construct the desired EEIO models. For advanced users, _useeior_ can take user-defined model specifications, and the accompanying data and metadata files, then construct EEIO models using the same model building functions. Detailed instructions are found in the Wiki page in the GitHub repository. Once a USEEIO model is successfully built, a set of validation steps can be performed to ensure the model is correctly calculated.