6 Loading data
6.1 Overview
The ems_data() function loads and prepares GTAP database files for use in CGE model runs. It handles the three core GTAP data files (dat, par, and set) and is also used to specify any time steps (for temporally dynamic models) and load set mappings for sets that are read into the model (i.e., not constructed from set operations).
ems_data(dat_input, par_input, set_input, time_steps = NULL, ...)| Argument | Type | Description |
|---|---|---|
dat_input |
Character or list | Path to a HAR file containing basedata coefficient data, or a dat list from [GTAP_convert()] |
par_input |
Character or list | Path to a HAR file containing parameter coefficient data, or a par list from [GTAP_convert()] |
set_input |
Character or list | Path to a HAR file containing set elements and attributes, or a set list from [GTAP_convert()] |
time_steps |
Integer vector or NULL |
Time steps for intertemporal models (see Time steps) |
... |
Named arguments | Set mappings for read-in sets (see Loading and specifying sets) |
All three input files (dat_input, par_input, set_input) and model-specific set mappings are required. time_steps is required for intertemporal models.
6.2 Input files
Compatible input files are currently limited to those produced by the Global Trade Analysis Project (GTAP). Although the most recent database releases are proprietary, GTAP has consistently made databases publicly available two versions behind the current release (GTAP 10 as of the current GTAP 12 release).
In order 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 paying GTAP members, the current teems version is capable of handling the “FlexAgg” format for GTAP Databases.
The following command will load data consistent with the standard GTAP model, using broad aggregations for regions, commodities, and endowments. Users will need to specify the location of data ("v7_data/gsdfdat.har" placeholder).
v7_data <- ems_data(dat_input = "v7_data/gsdfdat.har", # basedata coefficients
par_input = "v7_data/gsdfpar.har", # parameter coefficients
set_input = "v7_data/gsdfset.har", # set elements
REG = "big3",
ACTS = "macro_sector",
ENDW = "labor_diff"
)Note that the actual names of HAR data files vary according to the GTAP release.
| Input Type | GTAP v9 | GTAP v10 | GTAP v11 | GTAP v12 |
|---|---|---|---|---|
| dat_input | gddat.har | gsddat.har | gsdfdat.har | gsdfdat.har |
| par_input | gdpar.har | gsdpar.har | gsdfpar.har | gsdfpar.har |
| set_input | gdset.har | gsdset.har | gsdfset.har | gsdfset.har |
6.3 Set mappings
Set mappings aggregate the fine-grained regions, sectors, and endowments in the GTAP database down to the resolution required for a given model run. The set names used in ... depend on the data format — see the Loading and specifying sets chapter for the full list of internal mappings and instructions for supplying custom CSV mappings.
6.4 Time steps
For temporally dynamic models (e.g., GTAP-INT, GTAP-RE), time steps must be provided representing t0 plus actual year steps from t0. Time steps can be inputted in either actual year increments or represented as chronological years. Note that if chronological years are used, t0 must correspond with the reference year of the database being used.
The following uses explicit time steps (steps from t0), equivalent to chronological years c(2014, 2015, 2016, 2017, 2018, 2020, 2022, 2024, 2026, 2028, 2030) given the 2014 reference year of the loaded data.
data <- ems_data(dat_input = "v6_data/gsddat.har",
par_input = "v6_data/gsdpar.har",
set_input = "v6_data/gsdset.har",
time_steps = c(0, 1, 2, 3, 4, 6, 8, 10, 12, 14, 16),
REG = "WB23",
PROD_COMM = "services",
ENDW_COMM = "labor_agg"
)Chronological time steps (note reference year of input data).
data <- ems_data(dat_input = "v7_data/gsdfdat.har",
par_input = "v7_data/gsdfpar.har",
set_input = "v7_data/gsdfset.har",
time_steps = c(2017, 2018, 2020, 2022, 2024, 2026, 2028, 2030),
REG = "R32",
ACTS = "medium",
ENDW = "labor_diff"
)6.5 Converting formats
GTAP databases are available in the classic v6.2 and standard v7.0 formats, corresponding to the classic and standard GTAP models. To use a classic-based model with a newer v7.0 database, or a standard model with an older v6.2 database, use GTAP_convert() to convert the data first. The returned list can be passed directly to ems_data(). Note that set mappings must be specified according to the model to be used, not the original format of the input data.
GTAP 12 v7.0 database converted to v6.2 format for use with a classic GTAP model:
converted <- GTAP_convert(
dat_input = "v7_data/gsdfdat.har",
par_input = "v7_data/gsdfpar.har",
set_input = "v7_data/gsdfset.har",
origin = "GTAPv7",
target = "GTAPv6"
)
v6_data <- ems_data(dat_input = converted$dat,
par_input = converted$par,
set_input = converted$set,
REG = "big3",
PROD_COMM = "macro_sector",
ENDW_COMM = "labor_agg"
)GTAP 10 v6.2 database converted to v7.0 format for use with the standard GTAP model:
converted <- GTAP_convert(
dat_input = "v6_data/gsddat.har",
par_input = "v6_data/gsdpar.har",
set_input = "v6_data/gsdset.har",
origin = "GTAPv6",
target = "GTAPv7"
)
v7_data <- ems_data(dat_input = converted$dat,
par_input = converted$par,
set_input = converted$set,
REG = "AR5",
ACTS = "macro_sector",
ENDW = "labor_agg"
)6.6 Data aggregation
Data is aggregated according to type, with non-parameter coefficients summed by target set mappings and weighted averages calculated for the parameters below. A simple mean is applied to parameters not listed below. If custom parameter values are desired, these can be directly loaded in their final format into the ems_model() function, and no aggregation or modification will take place. In the below notation, hat (ˆ) indicates the new parameter value and asterisk indicates the destination set mapping.
6.6.1 GTAP v6.2 format parameter weight methodology
Headers, descriptions, and index ranges for parameters and associated data within the GTAP v6.2 model. GTAP-INT weights are identical to GTAP v6.2 with the addition of an invariant time set.
| Header | Description | Set Index | |
|---|---|---|---|
| Param. | |||
| \(\sigma_\text{d}\) | ESBD | Armington CES for dom./imp. allocation | \(i \in \text{TRAD\_COMM}\) |
| \(\sigma_\text{m}\) | ESBM | Armington CES for regional allocation of imports | \(i \in \text{TRAD\_COMM}\) |
| \(\sigma_\text{va}\) | ESBV | CES between primary factors in production | \(j \in \text{PROD\_COMM}\) |
| \(\gamma\) | INCP | CDE expansion parameter | \(i \in \text{TRAD\_COMM},\ r \in \text{REG}\) |
| \(\beta\) | SUBP | CDE substitution parameter | \(i \in \text{TRAD\_COMM},\ r \in \text{REG}\) |
| Data | |||
| EVFA | Endowments – Firms purchases at agents’ prices | \(i \in \text{ENDW\_COMM},\ j \in \text{PROD\_COMM},\ r \in \text{REG}\) | |
| VDFA | Inter. – Firms’ dom. purchases at agents’ prices | \(i \in \text{TRAD\_COMM},\ j \in \text{PROD\_COMM},\ r \in \text{REG}\) | |
| VDGA | Inter. – Government dom. purchases at agents’ | \(i \in \text{TRAD\_COMM},\ r \in \text{REG}\) | |
| VDPA | Inter. – Household dom. purchases at agents’ | \(i \in \text{TRAD\_COMM},\ r \in \text{REG}\) | |
| VIFA | Inter. – Firms’ imp. at agents’ prices | \(i \in \text{TRAD\_COMM},\ j \in \text{PROD\_COMM},\ r \in \text{REG}\) | |
| VIGA | Inter. – Government imp. at agents’ prices | \(i \in \text{TRAD\_COMM},\ r \in \text{REG}\) | |
| VIPA | Inter. – Household imp. at agents’ prices | \(i \in \text{TRAD\_COMM},\ r \in \text{REG}\) |
6.6.1.1 Aggregation methods
\[ \hat{\sigma}_{\text{d}_i} = \frac{ \sum_{i}^{i^*} \left( \sigma_{\text{d}_i} \sum_r (vdpa_{i,r} + vdga_{i,r} + vdfa_{i,r} + vipa_{i,r} + viga_{i,r} + vifa_{i,r}) \right) } { \sum_{i,r}^{i^*} (vdpa_{i,r} + vdga_{i,r} + vdfa_{i,r} + vipa_{i,r} + viga_{i,r} + vifa_{i,r}) } \tag{6.1}\]
\[ \hat{\sigma}_{\text{m}_i} = \frac{ \sum_{i}^{i^*} \left( \sigma_{\text{m}_i} \sum_r (vipa_{i,r} + viga_{i,r} + vifa_{i,r}) \right) } { \sum_{i,r}^{i^*} (vipa_{i,r} + viga_{i,r} + vifa_{i,r}) } \tag{6.2}\]
\[ \hat{\sigma}_{\text{va}_j} = \begin{cases} \displaystyle \frac{ \sum_{j}^{j^*} \left( \sigma_{\text{va}_j} \sum_r evfa_{j,r} \right) }{ \sum_{j,r}^{j^*} evfa_{j,r} } & \text{if } j \neq cgds \\ \sigma_{\text{va}_j} & \text{if } j = cgds \end{cases} \tag{6.3}\]
\[ \hat{\gamma}_{i,r} = \frac{ \sum_{i,r}^{i^* r^*} \gamma_{i,r} \sum_{i,r} (vdpa_{i,r} + vipa_{i,r}) }{ \sum_{i,r}^{i^* r^*} (vdpa_{i,r} + vipa_{i,r}) } \tag{6.4}\]
\[ \hat{\beta}_{i,r} = \frac{ \sum_{i,r}^{i^* r^*} \left( \beta_{i,r} \sum_{i,r} (vdpa_{i,r} + vipa_{i,r}) \right) }{ \sum_{i,r}^{i^* r^*} (vdpa_{i,r} + vipa_{i,r}) } \tag{6.5}\]
6.6.2 GTAP v7.0 format parameter weight methodology
Headers, descriptions, and index ranges for parameters and associated data within the GTAP v7 model. GTAP-RE weights are identical to GTAP v7.0 with the addition of an invariant time set.
| Header | Description | Set Index | |
|---|---|---|---|
| Param. | |||
| \(\sigma_\text{d}\) | ESBD | Armington CES for domestic/imported allocation | \(c \in \text{COMM}\) |
| \(\sigma_\text{m}\) | ESBM | Armington CES for regional allocation of imports | \(c \in \text{COMM}\) |
| \(\sigma_\text{va}\) | ESBV | CES between primary factors in production | \(a \in \text{ACTS},\ r \in \text{REG}\) |
| \(\gamma\) | INCP | CDE expansion parameter | \(c \in \text{COMM},\ r \in \text{REG}\) |
| \(\beta\) | SUBP | CDE substitution parameter | \(c \in \text{COMM},\ r \in \text{REG}\) |
| Data | |||
| EVFP | Primary factor purchases at purchasers’ prices | \(e \in \text{ENDW},\ a \in \text{ACTS},\ r \in \text{REG}\) | |
| VDFP | Domestic purchases by firms at purchasers’ prices | \(c \in \text{COMM},\ a \in \text{ACTS},\ r \in \text{REG}\) | |
| VDGP | Domestic purchases by government at purchasers’ prices | \(c \in \text{COMM},\ r \in \text{REG}\) | |
| VDPP | Domestic purchases by households at purchasers’ prices | \(c \in \text{COMM},\ r \in \text{REG}\) | |
| VMFP | Import purchases by firms at purchasers’ prices | \(c \in \text{COMM},\ a \in \text{ACTS},\ r \in \text{REG}\) | |
| VMGP | Import purchases by government at purchasers’ prices | \(c \in \text{COMM},\ r \in \text{REG}\) | |
| VMPP | Import purchases by households at purchasers’ prices | \(c \in \text{COMM},\ r \in \text{REG}\) |
6.6.2.1 Aggregation methods
\[ \hat{\sigma}_{\text{d}_{c}} = \frac{\sum_{c}^{c^{*}}\left(\sigma_{\text{d}_{c}}\sum_{r} (vdpp_{c,r} + vmpp_{c,r} + vdgp_{c,r} + vmgp_{c,r} + vdfp_{c,r} + vmfp_{c,r})\right)} {\sum_{c,r}^{c^{*}} (vdpp_{c,r} + vmpp_{c,r} + vdgp_{c,r} + vmgp_{c,r} + vdfp_{c,r} + vmfp_{c,r})} \tag{6.6}\]
\[ \hat{\sigma}_{\text{m}_{c}} = \frac{\sum_{c}^{c^{*}}\left(\sigma_{\text{m}_{c}}\sum_{r} (vmpp_{c,r} + vmgp_{c,r} + vmfp_{c,r})\right)} {\sum_{c,r}^{c^{*}} (vmpp_{c,r} + vmgp_{c,r} + vmfp_{c,r})} \tag{6.7}\]
\[ \hat{\sigma}_{\text{va}_{a}} = \frac{\sum_{a}^{a^{*}}\left(\sigma_{\text{va}_{a}}\sum_{r} evfp_{a,r}\right)} {\sum_{a,r}^{a^{*}} evfp_{a,r}} \tag{6.8}\]
\[ \hat{\gamma}_{c,r} = \frac{\sum_{c,r}^{c^{*}r^{*}}\gamma_{c,r}\sum_{c,r} (vdpp_{c,r} + vmpp_{c,r})} {\sum_{c,r}^{c^{*}r^{*}} (vdpp_{c,r} + vmpp_{c,r})} \tag{6.9}\]
\[ \hat{\beta}_{c,r} = \frac{\sum_{c,r}^{c^{*}r^{*}}\left(\beta_{c,r}\sum_{c,r} (vdpp_{c,r} + vmpp_{c,r})\right)} {\sum_{c,r}^{c^{*}r^{*}} (vdpp_{c,r} + vmpp_{c,r})} \tag{6.10}\]