2 Dependencies
This chapter outlines what is needed to run your first CGE model. Ideally all components would be open-source and perhaps one day they will be, but for the moment there are still some minor hurdles to overcome. Before beginning to write model scripts in R with teems, users will need to gain access to a GTAP database and build the teems-solver. GEMPack users can skip the solver step although they will be missing out on a considerable degree of functionality both within the solution process itself and in post-model data availability.
For those skeptical of using R or under the impression that R is only for statistical analysis, we would invite you to investigate speed tests between the R data.table package (widely employed within teems) and comparable packages in Python and Julia. The teems-solver is written in C and uses highly performant Fortran libraries.
2.1 Data
The only data currently teems-compatible is available from the Global Trade Analysis Project (GTAP). Although the most recent databases are proprietary, GTAP has consistently made databases available two versions behind the current release (GTAP 10).
To access the freely available database, users will need to register with GTAP and download the “FlexAgg” format. For GTAP 10 this is accessible under the “GDyn Data Base” entry in the GTAP 10 “Satellite Data and Utilities” section here. For GTAP members that have purchased a database, the current teems version is capable of handling the “FlexAgg” format for GTAP Databases 9 through 12.
2.2 R
R (>= 4.3.0) is required. Download and install the latest release for your platform from CRAN.
RStudio is the recommended IDE for working with teems scripts. It provides a script editor, integrated console, and a file browser that makes it straightforward to open, edit, and run the example scripts generated by ems_example(). The 49th Parallel theme with Fira Code font makes for an aesthetically pleasing coding experience.
2.3 teems-R package
The R package is currently in beta (v0.0.5) and open for testing. It is installed via remotes:
remotes::install_github("teemsphere/teems-R@v0.0.5")2.4 teems-solver
teems calls Docker to solve the constrained optimization problem using low-level C and Fortran routines. The solver build is available here: teems-solver. The latest solver build will always be compatible with the latest R package version.
Two prerequisites:
- Docker — install from docker.com. Linux users must also configure Docker to run without
sudo. - HSL libraries — four sparse linear algebra libraries (MA48, MA51, HSL_MC66, HSL_MP48) must be obtained directly from HSL prior to building. These are available at no cost for academic use.
Two Docker build approaches are available. The expedited build (~5 min) is recommended for most users and uses a pre-built base image containing all open-source dependencies. The full build (~40 min) compiles all dependencies from source.