# Replicating Results

All results are replicated by running "largeopeneconomy_run.r". To run the code, the user must have an installation of both R and GAMS. GAMS must also be added to the user's path environment variable so that the executable files are discoverable from the command line. Users must first point the R program to the correct working directory to run properly by modifying line 7 of "largeopeneconomy_run.r" (where the replication files are stored on a user's local machine). As an example if downloading the .zip director to the C:/ drive, line 7 would read:

wd = "C:/loe_jgea_replication_files/"

R can be run either through a GUI (e.g., RStudio, base R) or through the command line. For users that are interested in using the command line: (1)  make sure that R is discoverable through the command line, (2) navigate the command line to the root directory of the replication code (e.g., C:/loe_jgea_replication_files/, if stored directly on the C:/ drive), and (3) type "Rscript C:/loe_jgea_replication_files/largeopeneconomy_run.r".

"largeopeneconomy_run.r" runs the included GTAPinGAMS distribution as well as the SAGE model to replicate the results of the paper. For GAMS users interested in running only the GTAP modeling portion the code base, navigate to "gtapingams/largeopeneconomy/run.gms". The file can be run as is.

Note that the code takes several hours to complete. 

# SAGE Model Description

**S**AGE is an **A**pplied **G**eneral **E**quilibrium (SAGE) model of the U.S. economy.

v2.0.1

SAGE is computable general equilibrium model (CGE) of the United States economy developed for the analysis of environmental regulations and policies. It is an intertemporal model with perfect foresight, resolved at the sub-national level. Each of the regions in the model, has multiple representative households based on income level and multiple representative firms, most of which are focused on the manufacturing and energy sectors that are often impacted by environmental policies. Production technologies are represented with nested CES functions, which may include natural resource inputs. Capital for these firms is represented in a partial putty-clay framework to aid in capturing transition dynamics. A single government agent levies taxes on labor earnings, capital earnings, production, and consumption. The United States is treated as a large open economy using the Armington framework governing both domestic and international trade. The model is solved using the General Algebraic Modeling System (GAMS) and the PATH solver, with wrappers and data functions written in R.

Each directory contains a readme.txt file describing the contents of the directory. For complete documentation of the model, along with instructions for using the model, please see ./documentation/documentation.pdf.

| Directory       | Contents                                                |
|:----------------|:--------------------------------------------------------|
| ./data          | Benchmark data nd parameter files for running the model |
| ./diagnostics   | Code for running model diagnostics                      |
| ./model         | Core SAGE model                                         |
| ./output        | Model output is stored here by default                  |
| ./utilities     | Utilities for running the model and working with output |
| ./gtapingams    | GTAPinGAMS code adapted from Lanz and Rutherford (2016) | 

## Data Availability Disclaimer

The social accounting matrix for SAGE is based on the state-level IMPLAN data set available from www.IMPLAN.com. While the underlying IMPLAN data are proprietary, EPA has permission to share the aggregated social accounting matrix in the publicly available version of SAGE (see .data/default_aggregation.gdx). A licensed version of IMPLAN is required to build or make changes to the SAGE data sets. To build the dataset, first follow the instructions in ./build/data/implan/implan_data_instructions.txt to add the necessary IMPLAN data files into the SAGE directory structure. Then run the main build stream function ./build/build_default_data_sets.R.
