How to Read Results in a GDX File
This guide explains how to read model results in a GDX file, and save and export them to Excel. Download a PDF version of this guide .
What is a GDX File?
GDX stands for Gams Data eXchange. A
GDX file stores and displays data that are defined in the CGE model. For example, it can store the values of
parameters such as elasticities and tax revenues if these have been defined and
given values in the CGE model. GDX files
are also used to hold data used as model input, such as the SAM GDX file in the UNI-CGE
model. A GDX file can also hold data that result from a successful model
solution. In this course, results are reported in a GDX file named UNI-RESULTS.GDX.
Where is the UNI-CGE Results.GDX File?
The UNI-RESULTS.GDX file will be created every
time you run the model, if you have set GAMS to do so. The first time you run the
model, click on the green arrow and select “Run with GDC Creation,” as shown in
Figure 1.
Figure 1. Set GAMS to create a GDX results file after running the model
After you run the model, the UNI-RESULTS.GDX file will appear on the Project Explorer list. Click on its name to open it. After you open it, the file name will appear on the menu bar (Figure 2). You can leave the file open, and results from subsequent experiments will constantly overwrite it.
Figure 2. UNI-RESULTS.GDX listed on the menu bar
What is in the UNI-RESULTS.GDX File?
The GDX file reports the solution values for selected variables and parameters in the model. Figure 3 presents a snippet of the UNI-RESULTS.GDX file.
Figure 3. Example of the contents of the UNI-RESULTS.GDX file
Clicking on the name of an item in the left-hand column
opens the data for that item in the right-hand section of the screen. In
Figure 3, the modeler had previously created and defined a parameter named
“RES_PCOM_QC” in the UNI-CGE model code. It is a table of RESults for Percentage Changes in Quantities of COMmodities, such as aggregate consumption (QQ). After selecting this parameter for display, the
data on the right are the values for these results.
Export Results from GDX to Excel
The GAMS code in the UNI-CGE model first unloads selected results into the UNI-Results.GDX file, and then exports those results from the GDX file to the Excel file named UNI-results.XLSX (Figure 4). This process uses GAMS’ read-write utility between GAMS and Excel, GDXXRW.
Figure 4. GAMS code in UNI-CGE model exports results to GDX and then to Excel
Because the GDXXRW utility may become unsupported by GAMS in the future, this guide also shows you a direct way to export results from GDX to Excel.
First, while in the GDX file, click on the EXPORT button (shown as the red circle labeled 1 in Figure 5). This will open a dialog box, shown on the right side of Figure 5.
Figure 5. Exporting results from GDX to an Excel file
Second, select the name of the Excel file that you want to export results to, shown in the purple circle labeled 2 in Figure 5. The default name is the same as the GDX file. Instead, you may want to create Excel files that have the names of scenarios, such as “tariff_cut.xlsx.”
Third, click on the Export button, labeled "3".
Key Results in the UNI-RESULTS.GDX File
The UNI-CGE model code includes commands to organize key results
into tables. This makes it easier to
view sets of related data instead of single variables or parameters. Table 1 provides a summary of the tables
defined in the UNI-CGE model and their contents.
Content |
|
Res_QCOM_pc |
% change in commodity quantities (production, consumption, trade) |
Res_PCOM_pc |
% change in commodity prices |
Res_PROD_pc |
% change in production quantity and value added |
Res_SCAL_pc |
% change in scalar values (macro variables) |
RGTAPtab_pc |
% change in real GDP |
FACT_pc |
% change in factor results |
QF_pc |
% change in factor quantities by factor and activity |
WFA_pc |
% change in factor price distortion by factor and activity |
CTAXR_B |
Base commodity tax rates (sales, export and import taxes) |
CTAXR_L |
Updated commodity tax rates (sales, export and import taxes) |
ATAXR_B |
Base activity output tax rates |
ATAXR_L |
Updated activity output tax rates |
YTAXR_B |
Base income tax rate |
YTAXR_L |
Updated income tax rate |
Hint on Working With GDX Files
GDX allows you to rearrange the orientation of tables of data so that you can easily format data to be attractive when exported to Excel. “List view” presents the data in columns. “Table view” presents the same data as a matrix, as shown in Figure 3. You can toggle between list and table views by clicking on the List View/Table View button located above the data (Figure 5).
Figure 5. GDX data presented in table
view
Copyright Cornerstone CGE 2024 CC 4.0 BY-NC-SA