Gekko

Introduction

Gekko is a simulation program for solving and analyzing large-scale economic models. Gekko is timeseries-oriented, being capable of managing and presenting time series in a convenient way.

In the case of the macroeconomic model ADAM, Gekko can be used to produce short term forecasts and to simulate long term scenarios for the Danish economy. Gekko is also used for other large-scale models, including energy models.

This reference begins with a list of changes in Gekko ('New features'), and a general introduction ('Setup', 'Basic concepts', and 'Guided tour'). The list in 'Command overview' divides the Gekko commands into categories, and the last topics ('Filenames', 'Functions', 'Function keys', 'Under the hood', 'Help system' and 'Reading guide') are short summaries of these subjects.

The second part of the reference is a alphabetically ordered description of all commands in Gekko. The description of the Gekko commands is the focus of this reference.

The last part of the reference contains descriptions of some auxiliary tools for ADAM.


New features

New features (in Gekko 1.8)

Introduction

Gekko 1.8 is a so-called stable version, that is, a version where the components are well-tested and hopefully error-free.

Gekko is under continuous development, so the features are augmented on a regular basis in the development versions (versions with an uneven second number, for instance 1.9.x). It is not the intent to provide an exhaustive list of features of Gekko 1.8 relative to the prior stable version (1.6), so below a short list of the most prominent changes for a quick review. (You can find more detailed descriptions here (development versions), or even more detailed here (changelog)).

The changes in 1.8 are relatively minor: in the beginning of 2014 a version 2.0 with many enhancements (and also some syntax changes) will be released, so the development in 2013 has pretty much focused on that future version.

Gekko 1.8

Most important changes/improvements in Gekko 1.8, relative to Gekko 1.6:

·Reading Excel files (READ <xlsx>). Transposed reading is possible too (also for .csv files).

·Reading/converting .prn files (CONVERTPRN).

·Listfiles: you may use LIST mylist = #(listfile myfile). The external listfile has an item on each line.

·PPLOT can be used with <a>, <ap> or <ad> printcodes in order to plot values from both the Work and Base databanks at the same time. Output can be saved in .png or .svg format, too. Point indicators in the graphs may be omitted (OPTION graph lines points).

·HP-filter function for time series, see functions.

·Possibility of fixed parameters in a model file (using for instance #c1, defined elsewhere in the model file).

·A new frequency 'undated' (U) is introduced. This frequency works much like annual, and may for instance start in period 0, followed by 1, 2, 3, etc.

·Zoom level can be set for font sizes in the Gekko main window (see OPTION interface zoom).

·Tables: quite a few tweaks for tables. You may use one-period columns, and put grey vertical borders between designated periods. See also the options under OPTION table html.

Gekko 1.6

Most important changes/improvements in Gekko 1.6, relative to Gekko 1.4:

·Help now files in standard .chm format (separate window), i.e. searchable, printable, etc.

·Suggestions will pop up while writing OPTION commands (see OPTION interface suggestions), for easier navigation of the option 'tree'.

·Much faster simulation (SIM), both Gauss and Newton.

·Faster model loading (MODEL statement), because known models are cached on the hard disk. A known model loads about eight times faster than before.

·Model signatures (hash codes) are introduced. See SIGN command.

·Model blocks are supported (can be used when doing 'Check residuals').

·Forward-looking models (endogenous with leads) can be solved with Fair-Taylor algorithm (many options to control this).

·New .tsdx format version 1.1. This version is binary, and about three times faster to load than version 1.0. Default databank format is now .tsdx instead of .tsd.

·FOR loop improvements. You can now loop over DATEs and VALs, too.

·IF statement improved to allow OR, AND and NOT, and with comparisons ('<', '==', etc.). You can compare STRING, DATEs, or VALs.

·STRING, DATE and VAL statements accept expressions on the right-hand side. You may also refer to individual timeseries observations (with 'variable[period]').

·Recording of user commands. See menu 'Edit' --> 'Command history...'.

·Tables (defined in xml) and menus (defined in html). Tables can be printed as text or html (the latter is default now).

·PRT and MULPRT printcode simplifications and improvements, adding multiple printcodes and/or element-specific printcodes. Formatting codes available too. Transposed printing possible.

·Easy cell copy-pasting via clipboard to spreadsheet: CPLOT and new 'Copy'-button (that copies last PRT/MULPRT or table to the clipboard).

·'Named' databanks possible (OPEN command). Any number of in-memory databanks may be opened and referenced to with colon (':'). A new F2 databank window makes it possible to swap databanks with drag&drop. For safety, after swapping, Gekko enters swap-mode with some limitations on available commands (see UNSWAP).

·'Run status' window, to keep track of currently executing command file(s).

·Bulk closing or updating PPLOT and/or UDVALG windows. See 'Window' menu.

·Transformation of timeseries from higher frequencies to lower frequencies (COLLAPSE)

·Decomposition window (UDVALG) accepts expressions, and is improved.

·TIMEFILTER command for easy hiding of periods when reporting (PRT, tables etc.). Also replaces VPRT.

·Goals/means syntax simplification (UNFIX command).

·Command to trim superfluous variables from a databank (TRIMVARS).

·PIPE can pipe to html and combine with html tables.

·Laspeyres chain index function: LASPCHAIN(). Accepts negative quantities too (subtracted).

·Reading and writing .csv files is possible for easier interface to Excel etc.

·Default databank format is changed from .tsd to .tsdx.

·Equation reordering is switched off as default (OPTION solve gauss reorder).

·Name change of 'isstart.cmd' to 'gekko.ini'.

·DISP can search in labels.

·TELL command.

·MEM command to show scalar variables.


Setup

Setup (and installation)

Installation

For ADAM users, please use the setup facilities supplied by Economic Modelling, Statistics Denmark, in order to install Adam+Gekko (in order to uninstall Adam+Gekko, use the uninstall facilities supplied by Economic Modelling, Statistics Denmark).

In order to install Gekko as a standalone package for economic analysis, go to www.t-t.dk/gekko, and choose 'Software versions' (www.t-t.dk/gekko/versions.html). If you have problems installing, please consult the trouble shooting guide: www.t-t.dk/gekko/problems.html. After installation and starting up Gekko, it might be convenient to create a .bat file to start up the program in the future (see more in the 'Setup and environment' section below).

Uninstallation

Uninstalling Gekko as standalone package can be done from the Windows Control Panel. Start the Control Panel and choose Add/remove programs, then select Gekko and uninstall it.

Setup and environment

Gekko uses the concept of a working folder from which files are read and written. This may be chosen in two ways:

·If Gekko is started up from the 'Programs' menu in Windows, Gekko will open up the last-opened working folder. You may change this by means of 'File' --> 'Set Working Folder...' in the Gekko menu.

·If Gekko is started up from the Windows command prompt (for instance by typing 'gekko' in the Total Commander command line), Gekko will use that particular folder as its starting folder. Typing 'gekko' only works if a gekko.bat file is available, see 'Utilities' --> 'Make .bat file for easy Gekko startup...'. (This gekko.bat file should be put somewhere in your Windows path -- Gekko will try to put it into your Windows folder).

If a file with the name 'gekko.ini' (alternatively: 'isstart.cmd') is present in the working folder, this file will be executed at Gekko startup. Typically this file contains OPTION, MODEL and READ commands setting up the environment for different kinds of analyses. The gekko.ini file will be rerun when issuing a CLEAR statement, so this statement is in effect equivalent to closing and reopening Gekko (in contrast, the 'CLEAR<all>' statement omits loading the gekko.ini file).

For more advanced users, there is the possibility to indicate parameters when calling the gekko.exe file at Gekko startup. See the RUN help file for more on this.


Basic concepts

Introduction

This document describes some of the basic concepts used in Gekko.

Time

Gekko can operate on different frequencies, at the moment annual, quarterly, monthly or undated.

Databanks

Databanks are containers of timeseries. Gekko always starts out with two empty databanks (in memory): 'Work' (Working bank) and 'Base' (Baseline bank). More databanks with different names (so-called 'named' databanks) can be opened (OPEN), but note that Work and Base have special capabilities regarding printing/plotting etc. (It is possible to reassign the names of the databanks (see the F2 window), to use these capabilities on other databanks than Work and Base).

Timeseries

A timeseries can be thougth of as an object residing in a databank. It may have frequency annual, quarterly, monthly, or undated, and it can contain any number of observations. If data has been read for timeseries Y regarding the period 2010-2015, printing out Y for the period 2016 will show a missing value ('M'). When a databank is read (READ), the Work databank is cleared, and all the observations for all the timeseries in the file are put into the Work databank (it is possible to merge databanks if this is preferred). After this reading, the Base databank is also cleared, and all the timeseries are copied from Work to Base. So after reading a databank file with READ, the Work and Base databanks will always be identical. Data can be put into the Base databank by means of MULBK, and OPEN can open up databanks with different names than Work/Base (these databanks are called 'named' databanks, and are read-only).

Analysis

The Base databank is typically used for multiplier analysis (i.e., experiments). Say you read a databank and then perform some experiment. This experiment will only alter timeseries in the Work databank, so after the experiment is finished, you can compare the timeseries in the Work and Base databanks (Gekko has a lot of commands to do such comparisons, for instance MULPRT, UDVALG etc.). If, at some point, you wish to make sure that the Work and Base databanks are identical (for instance after a simulation), you can use the MULBK command without an argument. This command clears the Base databank, and copies the Work databank into it (in memory). You may alternatively read a file directly into the Base databank, if you append a filename after the MULBK statement (but often MULBK without any argument is sufficient). There is a cleanup-command: CLEAR. This command clears the Work and Base databanks, in addition to clearing models, lists, options and other things. The operation provides a clean state of Gekko, as if it had been closed and reopened (if there is a file with the name 'gekko.ini' (alternatively: isstart.cmd) in the working folder, this file will be re-read, so gekko.ini can be used to contain options and other commands (for instance MODEL and READ commands) that the user wishes to "survive" a CLEAR).

Observations

In general, you will have to CREATE a timeseries before you update it's values/observations with the UPD or GENR commands (unless the timeseries starts with the letters 'xx', indicating that it is to be thought of as a temporary variable). However, it should be noted that when a databank is read (READ), after a model has been loaded previously (MODEL), any model variables not present in the databank will be auto-created as timeseries (with all observations set to missing values). Because of this, it may often be convenient to put MODEL statements before READ statements.

Periods

Note that commands involving timeseries can have a local or global time period. For instance, there is a difference between "PRT <2010 2020> var1" and "PRT 2010 2020 var1", because the latter (but not the former) changes the global time period. Please consult the TIME help file if you need more information on this.

Printcodes

The so-called printcodes are used in many places, in order to perform easy transformations (for instance percentage growth rate, or multiplier difference between Work and Base databank values). The printcodes come in two versions: 'long' and 'short'. The 'long' ones are used in the PRT and MULPRT commands (for instance "PRT<abs> var1" to only print the absolute level, and not percentage growth), whereas the 'short' ones can be applied more generally (for instance "PPLOT<p> var1" to graph the growth rate of var1). The most important of the 'long' ones are abs and pch, and the most important of the 'short' ones are d, p, m, q. The functionality of the 'long' and 'short' printcodes overlap: see PRT for more details.

Models

Regarding models, it should also be noted that the list of endogenous variables in a model is simply the set of all the variables at the left-hand side of the equations. This may be changed afterwards by means of the ENDO and EXO commands. Regarding equation syntax, you may consult the latter part of the MODEL help file, if you need more information on this. (Models are cached in binary form on the user's hard disk in order to load faster next time).

Files

Regarding file names, you may use relative paths like '\subfolder\data.txt'. Using relative paths makes it easier to move a system of command files to another location/computer if needed. Special user-paths can also be given by means of the "OPTION folder ..." settings.

Hash sign

The hash sign ('#') is used by both lists (LIST) and scalar variables (STRING, DATE, VAL). (Please be warned that in the longer run, scalar variables will use '%' instead of '#' as indicator).

Scalar vars

Scalar variables can be of the type STRING, DATE or VAL. Scalar variables can be referred to by means of either '#var' or '{var}'. The latter syntax is handy when 'composing' timeseries names. For instance, the variable 'a{i}c{j}e' is equal to 'abcde', if {i} = 'b' and {j} = 'd'. (The alternative is using 'a#i|c#j|e', or the more explicit 'a|#i|c|#j|e', but this way of composing variable names tends to be hard to read). See MEM command to print a list of current scalar variables.

Lists and

wildcards

Generally, lists are separated by blanks, e.g. "LIST mylist = var1 var2 var3;". This is also the case when the list contains expressions: "PRT x/y w/z;". Lags, leads and fixed dates are put inside parentheses, for instance: var1(-1), var1(+1) or var1(2010). Square brackets are used for wildcard-lists, so instead of a standard list (#mylist), you may use for instance [fX*] to refer to all variables in the work databank beginning with 'fX'. Regarding individual observations, GENR only accepts for instance var(2010), whereas a scalar is more flexible, for instance "VAL x = var[#t+1]". This limitation in GENR statements will be corrected, but until then you may use VAL's as a bridge (VAL x = var[#t+1]; GENR y = #x;).

Command files/

batch job

Gekko commands can either be run directly from the Gekko main window, or assembled in a command file (script file) for later execution. Command files can be run with the RUN command. This is also called a batch job (also possible by means of calling gekko.exe with parameters, see more in the RUN help file). You may track the execution of jobs via 'Utilities' --> 'Run status...' in the Gekko menu (or double-click on the traffic light in the lower left corner of Gekko).


Introduktion

Guided tour

Guided tour

Instead of painstakingly reading through a lot of descriptions of commands etc., you might prefer to jump right into simulating a model in Gekko, and analyzing the results. For the purpose of this, a guided tour has been created (the tour will entail some typing though), where each step is explained, but without delving into too many details.

The guide can be seen here:

·Gekko Guided tour (external link)

At a later point, the guide will be imported into this help file. For now, it is only available on the internet.


Command overview

Introduction

Gekko is an open-source simulation system, designed for handling timeseries and simulating large-scale econometric or energy models (see www.t-t.dk/gekko). Below, in this document, the different Gekko commands are listed, grouped together by functionality. Instead of, or rather before, reading through these detailed documents, you may prefer reading some introductory guides:

·Setup

·Basic concepts

·Guided tour

Databanks

In the standard setup, Gekko operates with two databanks; ‘Work’ (working bank) and ‘Base’ (baseline bank). There are the following commands related to databanks:

READ | Reads a databank file into 'Work' and 'Base' databanks
MULBK | Reads a databank file into 'Base' databank
OPEN | Reads a databank file into a specific databank name.
CLOSE | Closes read-only 'named' databanks opened (see OPEN)
WRITE | Writes a databank to .tsd(x) format (or others)
CONVERTPRN | Converts a .prn file to a .csv file.
DIFPRT | Finds differences between Work and Base databanks.
FINDMISSINGDATA | This command finds variables with missing values.
TRIMVARS | Removes non-model variables from Work and Base databanks
UNSWAP | Unswaps databanks that may have been swapped in the F2 window.

Timeseries

Timeseries exist as objects in a databank. Frequency can be annual, quarterly or monthly, missing values are suppoted, and a timeseries can be of any length. Some of the commands compare data from the Base and Work databanks (or you may prefix a variable with ‘@’ to indicate the Base (baseline) version).

TIME | Sets global time
TIMEFILTER | Omits or averages certain periods in output
CREATE | Create a new timeseries
DELETE | Delete an existing timeseries
GENR | Transform a timeseries using mathematical expressions
UPD | Update a timeseries, setting e.g. growth rate etc.
UPDPRT | Prints variables in UPD format
COLLAPSE | Aggregate e.g. quarterly timeseries into annual timeseries etc.
LASPCHAIN() | Laspeyres chain function: see example under functions and LIST.
HPFILTER() | HP-filter function, see under functions.

Lists etc.

Gekko can put timeseries in a list, in order to reuse the list for different purposes (or make the command file easier to read). In addition, scalar variables like strings, dates and values can be used.

LIST | Create and delete lists
DATE | Scalar variable of date type
STRING | Scalar variable of string type
VAL | Scalar variable of value type
MEM | Shows a list of scalar variables and their values

Show data

Gekko can show data in several ways, including printing on the screen, graphs, or showing the data in an Excel sheet. In addition, there is a special table-like decomposition window (UDVALG). The DISP command also functions as an in-built equation browser.

PRT | Prints timeseries or expressions in different ways
MULPRT | Prints multipliers
PPLOT | Show a graph of timeseries (using gnuplot)
WPLOT | Show timeseries data in Excel
CPLOT | Like WPLOT, but copies cells to Windows clipboard
DISP | Prints more info, and starts equation browser
INFO | Displays precedents and their values (for endo variables)
UDVALG | Opens up the decomposition window

Model

A model can be loaded directly from a .frm file. After the model is loaded, a number of commands can be used:

MODEL | Load, parse and compile a model from file.
SIM | Simulates the model (also if there are goals/means)
RES | Performs single-equation static forecast of equations
EFTER | Runs inverted equations (add-factors etc.)
ENDO | Endogenize variables (means)
EXO | Exogenize variables (goals)
UNFIX | Removes ENDO/EXO goals/means.
CHECKOFF | Skip convergence check for chosen variables (Gauss)
ITERSHOW | Show iterations in detail for chosen variable (Gauss)
SIGN | For signing models with signatures.

Command files

Larger problems can be run by means of command files (.cmd or .add files). There are the following commands related to such files:

RUN | Runs a .cmd file
PIPE | Direct output to an external file instead of screen
STAMP | Prints date and time
VERS | Prints Gekko version
PAUSE | Waiting for the user to click [Enter]
RETURN | Forces a return from a particular .cmd file
STOP | Returns from all (nested) .cmd files at once
EXIT | Closes the Gekko application
INI | Runs gekko.ini (or isstart.cmd) from working folder
TELL | Prints text on the screen

Cleanup

The principal cleanup-command is the following

CLEAR | Clearing workspace or databanks etc.
CLOSEALL | Same as CLEAR.
CLS | Clears main window (short for 'clear screen')

Control flow

Gekko supports basic control flow like loops, conditional statements etc. At the moment the possibilities are quite limited, but will be augmented as the software matures.

FOR | For-loop over lists
IF | Conditional statement (IF-ELSE-END).
END | Ends loop or conditional statement

Tables/menus

TABLE | Prints out a predefined table (xml)
MENU | Opens up a menu (html)

Miscellaneous

The following commands did not fall into the above categories, and so are gathered here:

HELP | Access the help system
OPTION | Sets different options
SYS | Access the system shell if needed

From the menu items (‘Utilities’), you can also compare two databanks, check residuals, and compare variables in model/databank/varlist.


Filenames

Introduction

Gekko accepts relative paths, relative to the Gekko working folder. Consider, for instance, that you have a command file 'job.cmd' with the following READ-statement inside the 'job.cmd' file:

READ \banks\data;

Now, Gekko will add the sub-folder \banks to the Gekko working folder path. If the Gekko working folder is "C:\Projects\Model1", the READ statement is translated into:

READ C:\Projects\Model1\banks\data.tsdx;

The extension .tsdx is automatically added if missing in the READ command.

Path’s must use the '\' (backslash) character (frontslash '/' is not allowed), and a relative path name must begin with the '\' character. Valid file names consist of alphanumeric characters or the '_' character. If the file name contains blanks or special characters (for instance the Danish 'æ', 'ø' or 'å'), you may enclose the file name in single quotes ("READ 'last year.tsdx' ;").

At a later point, it may be preferable to add the sub-folder to the path of the executing command file, rather than to the Gekko working folder. Choosing between the two ways of interpreting relative path’s is not completely obvious, however.


Functions

Gekko has a number of in-built functions, listed below.

abs(x) | Returns the absolute value of x (timeseries or VAL).
BANKFILENAME(s) | Return the filename (as a STRING) of the s databank, where s is a STRING. Example: "STRING s1 = bankfilename('work');". May also be used as "STRING s1 = bankfilename('work', 'fullpath');"
BANKTIME(s) | Return the filename (as a STRING) of the s databank, where s is a STRING. Example: "STRING s1 = banktime('work');".
date(x) | Tries to convert the mem-variable x to a DATE type
dif(x) | Absolute time-difference of timeseries x: can also be used on left side of '=' in FRML or GENR.
dlog(x) | Logarithmic time-difference of timeseries x: can also be used on left side of '=' in FRML or GENR.
exist(x) | Returns 1 if timeseries x exists in Work databank, else 0. Returns a VAL.
exp(x) | Returns the exponential value of x (timeseries or VAL).
filteredperiods(d1, d2) | Returns the number of filtered periods between DATE d1 and DATE d2. Returns a VAL.
HPFILTER(x, lambda) | Used in GENR, and returns a HP-filtered version of timeseries x. Lambda is normally 6.25 for annual, 1600 for quarterly, and 129600 for monthly series. An additional argument 0 or 1 may be added (1 if log-transforms are used inside the calculation).
(p, q) = laspchain(#p, #q, t) | Laspeyres chain index. Calculates timeseries p and q (price and quantity) from a list of prices (#p) and a corresponding list of quantities (#q), setting p = 1 in period t. See bottom of LIST help file.
(p, q) = laspfixed(#p, #q, t) | Laspeyres fixed-price index. As laspchain(), but with fixed prices.
log(x) | Returns the natural logarithmic value of x (timeseries or VAL).
pch(x) | Percentage growth in timeseries x: can also be used on left side of '=' in FRML or GENR.
pow(x, y) | Equal to a**b or a^b.
round(x, d) | Rounds a VAL x to d decimal places. Returns a VAL.
string(x) | Tries to convert the mem-variable x to a STRING type
timestart() | Returns global time start (as a DATE)
timeend() | Returns global time end (as a DATE)
val(x) | Tries to convert the mem-variable x to a VAL type


Function keys

Function keys are used for quick access to specific Gekko commands.At the moment, only a few function keys are active.

F1 | Opens up the help system.
F2 | Opens up the databanks window.
Ctrl+Enter | New line in command prompt, without issuing the command.
Mark+Enter | You may mark several lines in the Main window and execute them as one block with [Enter].
Ctrl+M | Main tab.
Ctrl+O | Output tab.

You may double-click the 'traffic light' indicator in the lower right of the interface to open up the 'Run status' window.

The left- and right arrow buttons below the menu are for browsing back and forth when showing DISP (equation browser), or when showing tables by means of menus. The 'home' button navigates back to the start.

The 'Stop current job' button tries to halt an executing job.

The 'Copy last PRT...' button copies the last PRT/MULPRT or table as spreadsheet cells on the clipboard, for subsequent pasting into a spreadsheet (similar to CPLOT). This is convenient for copy-pasting to for instance Excel.


Under the hood

Language, licence etc.

Gekko is written in C#.NET, which together with VB.NET and Java are among the most used programming languages for pc's. Due to C# being object-oriented, development and redesign is flexible and efficient. The software is written for Windows .NET, so in order to run on Mac or Linux, the user has to use virtualization software (see here for more on this). Gekko is open-source (public domain, GNU GPL licence), implying that anybody can use the code for free, but any enhancements must be put into the public domain as well.

Parser, structure etc.

The databanks and timeseries in Gekko are object-oriented internally. There can be any number of databanks, with any number of time series for any given periods (including quarters and months), only constrained by working memory. All values and calculations are double-precision (64-bit) internally, and missing values are handled consistently. The timeseries can contain labels, source etc., and the underlying data structures are dynamically resizing arrays, in order to keep the system fast. Models and command-scripts (command files) are parsed and dynamically translated into C# code by means of ANTLR, providing fast and reliable parsing.

A model can be loaded dynamically without leaving Gekko. This means richer options for using different models at the same time, if needed. It also permits for instance optional fail-safe mode, where the model checks more strictly for illegal values while running (at a small speed penalty). Regarding print/plot type statements (PRT etc.) or variable definitions (GENR), the mathematical expressions are evaulated by means of the same parser that is used for models. This means that anything that can be written in a model equation can also be used for printing. For instance, a GENR statement accepts dlog(), pch() or diff() on both sides of the equation sign etc.

Solvers

At the moment, three algorithms for solving a model are provided.:

·First, standard Gauss-Seidel, where damping is supported via the formula codes. The program solves a model like ADAM quite quickly with the Gauss-Seidel algorithm.

·In addition, a Newton method with line-search is implemented. This method does not depend upon the distinction between left- and right-hand side variables, and so can be used to solve difficult models or goals/means problems. The Newton solver uses a decomposition of the simultaneous block into a feedback set and the rest of the simultaneous block, reducing the dimension of the jacobian matrix considerably. The Newton solver can handle any number of means/goals simply by changing the set of endogenous variables.

·Finally, a Fair-Taylor method is used if the model contains leaded endogenous variables.

Graphics,

tables

Graphics (PPLOT) are done with gnuplot as the underlying engine. Gnuplot is installed together with the rest of the program. Printing and plotting uses the same syntax/options and underlying code. Graphs can be exported to Word via the clipboard, or saved to disk as .emf files. Data tables can be exported directly to Excel, or via the clipboard to any spreadsheet software accepting tab-delimited input.

Syntax

In the long run, it is expected that richer AREMOS-like syntax will be implemented, in order to facilitate further development of the system.


On-linehelp

Help system

Introduction It may be difficult to remember all the commands and the exact syntax for each command. The function key F1 (or typing 'HELP') accesses the Gekko help system. If you cannot remember the exact syntax for a particular command, you can try typing "HELP [commandname]", for instance "HELP upd" (or you may search the help files for particular phrases).

The help system is contained in a file gekko.chm. Opening this file may sometimes pose problems on Windows 7 or 8. Please see this trouble-shooting guide if this is the case.

The help system is also available online here.


Reading guide

Reading guide The subjects in "Gekko command reference" follow a general pattern similar to layout below:
Introduction | A brief description of the command.
Syntax | The general syntax for the command. Many of the commands can use arguments or options. The following conventions are used in the description of the syntax: ·Commands are in capital letters (for instance: PRT). ·Predifined keywords are in capital letters (for instance: ROWS, or ROWS=yesno) ·Elements that are defined elsewhere in the syntax definition are in italics (for instance: period). Many commands accept a period argument. When using the period argument, it can be used locally or globally. In the local form COMMAND <per1 per2> ... ; the given period is used in this particular command step. If a global period argument is given COMMAND per1 per2 ... ; then the period from per1 to per2 becomes the new global time setting.
Example | One or more examples, sometimes based upon variables from the ADAM model. The examples serve to illustrate the typical or common uses of the command.
Note | The notes concerns exceptions to the command and any specific features of the command. These notes may also include comparisons to other commands.
Related commands | A list of commands with similar functions, or other commands typically used together with the specific command


CHECKOFF

Introduction

The command puts variables on an ignore-list, so that they do not influence convergence using Gauss-Seidel iterations.

Syntax

CHECKOFF ;

CHECKOFF variables ;

CHECKOFF ? ;

[empty] | If no variables are stated, i.e. a CHECKOFF without arguments, the list of non-checked variables is cleared.
variables | Variablename(s) or list(s) (wild-cards are allowed)
? | Prints the list of currently ignored variables concerning convergence in Gauss-Seidel method.

Example

CHECKOFF accepts variable names or lists (including wildcards), for instance:

CHECKOFF kbys;

Note that the wildcards look for names in the Work databank. Currrent ignored variables can be seen with

CHECKOFF ?;

There is no CHECKON command. The CHECKOFF command is non-additive (like the ENDO and EXO commands). To eliminate a CHECKOFF-variable, just remove it from the list given to the CHECKOFF command. To clear the CHECKOFF-list, issue a CHECKOFF command with no arguments. An alternative to this is setting "OPTION solve gauss conv ignorevars = no". In that case the list will be ignored.

Note

In order for this command to work, "OPTION solve gauss conv ignorevars" must be set to 'yes' (which is its default value).

CHECKOFF is also the related to the ITERSHOW command. Sometimes a particular variable, or a type of variables, may postpone the convergence of the Gauss-Seidel algorithm. To avoid that, such variables may be put on the CHECKOFF list, and they will be ignored regarding convergence check.

Related

commands

SIM, OPTION, ITERSHOW


CLEAR

Introduction

The CLEAR command is used to reset the workspace, or to clear databanks in memory.

Syntax

CLEAR ;

CLEAR < ALL > ;

[empty] | If no options are set, i.e. a "CLEAR" statement, the workspace will be cleared (models, databanks, lists, scalar variables, options etc.). Any existing gekko.ini file will be run. The gekko.ini file may contain Gekko statements that load a model, read a databank etc.
ALL | If this options is set, i.e. a "CLEAR <all>" statement, the workspace will be cleared (models, databanks, lists, scalar variables, options etc.). Any existing gekko.ini file will not be run.

CLEAR databank ;

databank

'Work' or 'Base' or '*' (the star indicates both 'Work' and 'Base'). Other databanks opened by means of the OPEN command cannot be cleared (they are read-only).

Examples (clearing workspace)

Use this syntax to reset the workspace:

CLEAR;

Clears the workspace (i.e. all Gekko RAM objects), and runs gekko.ini from the working folder if this file exists. You might put the following commands into gekko.ini (this file should be located in your working folder):

gekko.ini file

---------------------------------

CLS;

OPTION folder model \models;

OPTION folder bank \databanks;

OPTION solve method = newton;

MODEL mymodel;

READ mydatabank;

TIME 2012 2050;

---------------------------------

So in the gekko.ini file, put an (optional) a CLS command first, and then OPTION commands. Finally MODEL and READ commands (best in that order), and perhaps a TIME command to set up the time period.

CLEAR <all>;

Does the same thing, but will skip any existing gekko.ini file.

Examples (clearing databanks)

To clear the Work databank, use this syntax:

CLEAR work;

Alternatively

CLEAR base;

clears the base (baseline) databank. To clear both Work and Base databanks at the same time, use '*' as bankname:

CLEAR *;

Note however that a "CLEAR" statement (without arguments) also clears Work and Base databanks (and models, lists, scalar variables etc.), so if you intend to restart with a clear state of the workspace, use "CLEAR".

Note

CLEAR (without arguments) and CLOSEALL are synonymous. The latter will be phased out in the longer run, so please use CLEAR onwards.

CLEAR cannot clear databanks opened with the OPEN command.

Related

commands

CLOSEALL, DELETE


CLOSE

Introduction

The CLOSE command is used to close databanks in memory.

Syntax

CLOSE databank ;

databank

The databank to be closed. A star ('*') indicates all open databanks opened by means of the OPEN command.

Example

Use this syntax to close a databank:

CLOSE mybank;

Closes databank 'mybank' (that has been opened by means of "OPEN mybank").

CLOSE *;

Closes all databanks opened by means of the OPEN command. Will not close Work and Base databanks.

Note

CLOSE cannot close Work or Base databanks. See the closely related OPEN command.

Related

commands

OPEN, CLEAR, DELETE


CLOSEALL

 | CLOSEALL
Introduction | Please see the CLEAR command (without arguments). "CLOSEALL" and "CLEAR" are synonymous, and CLOSEALL will be phased out in the longer run.


CLS

 | CLS
Introduction | CLS clears the output window.
Syntax | CLS ;
Example | The CLEAR statement will not clear the output window (but clears everything else in the workspace), so you may use CLS after your CLEAR statement: CLEAR; CLS;
Related commands | CLEAR, (CLOSEALL)


COLLAPSE

Introduction

COLLAPSE transform higher-frequency timeseries to lower-frequency timeseries, for instance converting quarterly data to annual data.

Syntax

COLLAPSE lowfreq = highfreq method;

lowfreq | Lower frequency timeseries. Frequency can be indicated with suffix .a, .q or .m.
highfreq | Higher-frequencey timeseries. Frequency can be indicated with suffix .a, .q or .m.
method | (Optional). Choose between: total | average | first | last

Example

Use this to convert frequency:

COLLAPSE fY.a = fY.q;

Since the method is 'total' as default, this will create the annual timeseries fY where each annual observation is the sum of the corresponding quarters.

COLLAPSE fY.a = fY.q first;

With option 'first', the first quarter of each year would be used instead of summing the quarters.

Related

commands

GENR, UPD, CREATE


CONVERTPRN

Introduction

CONVERTPRN converts a .prn file into a corresponding .csv file. The .csv file can be read with READ<csv> or READ<csv cols>, depending upon orientation. In the longer run, a direct READ<prn> will be added, but for now the intermediate conversion step is necessary.

Syntax

CONVERTPRN filename ;

filename

The filename of the .prn file to be read into the Work databank. The filename may include a local or global path.

Example

Convert the mydata.prn to a corresponding mydata.csv file:

CONVERTPRN mydata;

Extension .prn is added automatically if not provided, and a corresponding mydata.csv file is produced. NOTE that any pre-existing mydata.csv file will be overwritten! The resulting .csv file will always be put into the same folder as the .prn file. Next, the .csv file may be read into Gekko like this:

READ <csv cols merge> mydata;

Extension .csv is added automatically in the above READ statement. The 'cols' option tells Gekko that the timeseries are stored in columns (which is normal for .prn files, but less normal for .csv files). The 'merge' option tells Gekko to merge with pre-existing data in the Work databank.

Typical .prn files have a data layout similar to this:

     "date"     "x1"     "x2"

      2012    1064.02    77.46

      2013    1097.59    88.69

      2014    1212.54    56.12

where "date" indicates that the first column is dates. The format may also (less normal) be used transposed:

      "name"     2012     2013     2014

      "x1"    1064.02  1097.59  1212.54

      "x2"      77.46    88.69    56.12

In general, Gekko ignores any "date" or "name" indicator (or anything else in the first cell of data), so the resulting .csv file carries no information on whether the timeseries are stored as rows or columns.

You may omit the quotation marks ("), but please do not use names or dates containing blanks (or put quotation marks next to each other like "x1""x2". Also please do not add superfluous space inside names (like " x1"). Gekko uses the white-space in the .prn file to divide the items into clumps/tokens.

Related

commands

READ


CPLOT

Introduction

CPLOT has the same syntax as WPLOT, so please see this command.

Instead of sending the result to Excel as WPLOT does, CPLOT sends the result to the clipboard. Thus, the cells can be pasted into any spreadsheet (or other applications) accepting tab-delimited cells from the clipboard.

Formatting of the cells is lost in comparison with WPLOT, but otherwise the cells are the same. The loss of formatting may even be considered a benefit in some cases, for instance when pasting cells into different locations in the same spreadsheet.

The functionality is very similar to the 'Copy' button in the Gekko user interface. This button copies the last PRT/MULPRT or table to the clipboard (as tab-delimited cells).

Note

The decimal separator used when copying to the clipboard can be changed by means of the option shown below. (This option will also apply to the 'Copy' button).

Related

options

OPTION interface excel decimalseparator = [comma|period].

Related

commands

WPLOT


CREATE

Introduction

This command creates a new variable in the work databank. The variable contains no data, but can given data afterwards using for instance UPD or GENR commands.

Syntax

CREATE variable ;

CREATE ? ;

variable | Variablename(s) or list(s) (wild-cards is allowed)
? | Prints a list of all created variables

Example

You may want to compute real house prices given as the price of single family houses (phk) with consumer prices (pcp). Since the real price is not a model variable, it needs to be created first

CREATE realphk;

GENR realphk = phk/pcp;

If the variable is just temporary, and you do not wish to create it first, you may prefix a variable with ‘xx’ in order for GENR or UPD to auto-create it

GENR xxrealphk = phk/pcp;

This way, the variable does not have to be created first. Later if you are in doubt about what you called real house prices, write

CREATE ?;

Note

Gekko warns if you try to create the same variable name multiple times. Created variables are saved when you save the work bank (WRITE). The DELETE command deletes created variables.

Related

options

OPTION calc ignoremissingvars = no; [yes|no]

Related

commands

GENR, UPD, DELETE


DATE

Introduction

The DATE command is used to assign a date value to a scalar variable of date type.

Syntax

DATE name = date ;

DATE name = expression ;

name | A scalar variable (do not prefix with '#')
date | Dates can be years, quarters or months, for instance '2010', '2011q2' or '2012m11'.
expression | You may use expressions on the right-hand side. Gekko will try to convert to DATE if possible.

A DATE variable 'per1' can later on be referenced to by means of '#per1' or '{per1}'. For dates, the former variant is typically preferable.

Example

You may use simple additions/subtractions in the option field, when referring to these dates. For instance

PRT <#per1-2 #per1+1> fY;

You may wish to use dates to control the flow of your system of command files, centralizing the assignment of dates in one place.

DATE per1 = 2012;

DATE per2 = 2040;

READ lang11;

UPD <#per1 #per1> JDfVmo + 1000;

SIM <#per1 #per2>;

MULPRT <#per1-1 #per2> fY;

Conversions are possible:

STRING s1 = '2010';

VAL v1 = 2015;

DATE d1 = #s1;

DATE d2 = #v1;

TIME #d1 #d2;

The conversion will fail if not possible (for instance the string '201o' or val 2015.4). If you need to explicitely convert to a date (for instance inside an expression), you may use the DATE() function.

CREATE data;

FOR date d = 2010 to 2015;

 UPD <#d #d> data = val(#d)-2000;

END;

Here, an explicit conversion from the #d variable is done. The result is this:

                data

 2010        10.0000

 2011        11.0000

 2012        12.0000

Note

Dates are scalar variables, and in this respect similar to strings and values (see STRING and VAL).

Related

commands

STRING, VAL, FOR, IF, TIME


DELETE

Introduction

DELETE is used to remove variables from the work databank, for instance CREATE’d variables.

Syntax

DELETE variable ;

DELETE < ALL > ;

variable | Name of the variable(s) to be deleted. Lists and wildcards may be used.
ALL | All created variables are erased.

Example

After defining and using real price of houses and real wages for workers, they can be deleted later as this example shows:

CREATE realphk;

GENR realphk = phk/pcp;

CREATE reallna;

GENR reallna = lna/pcp;

CREATE huse;

GENR huse = reallna/realphk;

DELETE realphk; // the variable realphk deleted after use

DELETE <all>;   // remaining CREATE'ed variables deleted

Note

The older "DELETE all" (same as "DELETE<all>") may still be used for some time, but will become obsolete.

Related

commands

CREATE, GENR, UPD


DIFPRT

Introduction

DIFPRT compares variables in the work and baseline databanks (for another way of doing bank comparisons, see also the menu item 'Utilities' --> 'Compare two databanks …'). DIFPRT is very similar to NDIFPRT, the difference is that DIFPRT also shows percentage differences.

Syntax

DIFPRT < period > period variables FILE=filename ;

period | (Optional). For instance "2010 2020" or "2010q1 2020q4". If inside the <> field, the period is local to the current statement, if outside the period will be changed globally. If no period is given, global time will be used.
variables | A list of variables (wildcards may be used). If no variables are given, the whole databank is compared
filename | The filename of the file that the output is written to.

Example

Compare all variables for the given period.

DIFPRT <2010 2020>;

Do the same, but put output into a file.

DIFPRT <2010 2020> file=compare.txt;

Only compare the list of endogenous variables, and put the result into the file compare.txt.

DIFPRT <2010 2020> #endo file=compare.txt;

Note

Criteria regarding the comparison are given in the two option values

OPTION databank compare tabs = 1.0;

OPTION databank compare trel = 0.0001;

The first option is the absolute criterion, and the second one is the relative criterion. The two must be met at the same time, in order to be considered "different". With the given values, this means that the absolute difference must be > 1, and the percentage difference must be > 0.01%. DIFPRT prints the difference and the percentage difference for the different variables. The NDIFPRT command has the same functionality, but with more compact output.

Related

options

OPTION databank compare tabs = 1.0;

OPTION databank compare trel = 0.0001;

Related

commands

NDIFPRT, MULPRT


DISP

Introduction

The command is used to print a variable, showing precedents and dependents if a model is loaded, and including a label (explanation) if a variable list is contained in the model file (.frm file) or as an external varlist.dat file.

If a model is loaded, the DISP command starts the equation browser. This means that linked variables can be clicked, and that you may browse forwards and backwards by means of the arrow buttons in the user interface. The 'home' button will browse back to the first DISP that started the equation browser.

Syntax

DISP < period > period variable ;

DISP 'search' ;

period | (Optional). For instance "2010 2020" or "2010q1 2020q4". If inside the <> field, the period is local to the current statement, if outside the period will be changed globally. If no period is given, global time will be used.
variable | Variables or lists (wildcards may be used).
'search' | A string in single quotes to search for in all labels.

Example

DISP the volume of GDP and private consumption for the (local) period 2000-2010

DISP <2000 2010> fY fCp;

If a model is loaded, you will be able to see which variables the given variable affect (dependents). You will also see the equation (if the variable is endogenous), and hence the variable’s precedents. These variables are clickable, so the DISP command functions as an entrance to the equation browser.

If a variable list is put after a 'VARLIST$' in the model file (or is located in an external varlist.dat file), you will note that the variables have labels when DISP’ed. Labels can be searched in this way:

DISP 'import';

This will list all variables with a label containing this search string.

Per default, only 3 lines of data is written when DISP'ing a variable. However, you can click the link ('show') to see any hidden periods. This limitation is intended for easier use of DISP as an equation browser.

Note

You can use a TIMEFILTER to omit periods for a more readable output. (If a TIMEFILTER is set, the 'print disp maxlines = 3' option is overruled, so that all non-filtered periods are shown even if there are more than 3 of these).

(The DISPLAY command from older Gekko versions is something completely different (superseded by TELL)).

Related

options

OPTION print disp maxlines = 3;

Related

commands

PRT, MULPRT, INFO, PPLOT, UDVALG


EFTER

Introduction

The EFTER command calculates three kinds of variables

(a) those designated with a formula beginning with ‘Y’,

(b) all auto-generated variables of J- and Z-type, and

(c) all table variables (variables defined after the AFTER$ statement in a model file).

Since Y-type variables are typically also J- and Z-variables, one can think of the EFTER command as a way to compute all reversed J- and Z-variables independently of the SIM command (the SIM command computes these after simulation), in addition to computing table variables.

See the MODEL command for more on J- and Z-variables.

Syntax

EFTER < period > period ;

period

(Optional). For instance "2010 2020" or "2010q1 2020q4". If inside the <> field, the period is local to the current statement, if outside the period will be changed globally. If no period is given, global time will be used.

Example

Read a historical databank and calculate add factors and table variables for a period.

MODEL mymodel;

READ mydata;

EFTER 2000 2010;

RES 2000 2010;

NDIFPRT;

Non-zero values indicates possible inconsistencies in data or model

Note

On a well-specified model, reading a historical databank, and issuing an EFTER statement on the historical period should ideally make it possible to simulate on the historical period and replicate the endogenous variables.

Related

commands

SIM, RES, MODEL, NDIFPRT


END

Introduction

An END statement concludes a FOR (loop) or IF (condition) statement. Gekko will fail if the END statement is missing.

To execute a loop in the command window, it is often convenient to use Ctrl+Enter for newlines, and then execute the lines as a block by means of marking all the relevant lines and hitting [Enter]. In that case, the lines are executes in the same way as using a command file.

Related

commands

FOR, IF


ENDO

Introduction

ENDO is used to endogenize exogenous variables. This is used in goal-search, in order to attain some goals via some means.

Syntax

ENDO ;

ENDO variable ;

ENDO ? ;

[empty] | ENDO without an argument clears the list of ENDO variables.
variable | Name of the variable(s) to be endogenized (separated by blanks, lists may be used)
? | Shows the number of ENDO variables.

Example

ENDO is used in order to solve goals/means problems. When simulating, you must have the same number of endogenized and exogenized variables. When issuing a SIM afterwards, Gekko will use the Newton algorithm to solve the particular goals-means problem.

You may try this (provided that a model and databank are loaded):

EXO fY;        //the goal variable (GDP)

ENDO tg;       //the means variable (VAT rate)

UPD fy % 2;    //sets the growth rate of GDP

SIM;           //will find the VAT rate that gives 2% GDP growth rate

Afterwards, you may remove the goals/means:

UNFIX;         //clears ENDO/EXO lists (like ENDO; EXO;)

After this, the solving is back to normal (i.e. Gauss-Seidel), but the VAT rate is still set so that the 2% GDP growth rate is attained if a SIM is issued after the UNFIX. If some other exogenous variable is changed now, fY (GDP) will change. This would not be the case before the UNFIX. So in this sense UNFIX unfixes the original endogenous variables.

Note

The ENDO list is non-cumulative, so all endogenized variables should be present in the same ENDO statement

Note that when ENDO and EXO are active, there is a target icon at the bottom right in the user interface, stating the number of goals and means set.

Related

commands

EXO, SIM, UNFIX


EXIT

 | EXIT
Introduction | The command EXIT terminates the application (without any warning, so use it carefully). It is often used in order to run Gekko sessions from batch (.bat) files. From the user interface, you may exit by means of 'File' --> 'Exit', or Alt+F4.
Syntax | EXIT ;
Related commands | STOP, RETURN


EXO

Introduction

EXO is used to exogenize endogenous variables. This is used in goal-search, in order to attain some goals via some means.

Syntax

EXO ;

EXO variable ;

EXO ? ;

[empty] | EXO without an argument clears the list of EXO variables.
variable | Name of the variable(s) to be exogenized (separated by blanks, lists may be used)
? | Shows the number of EXO variables.

Example

See the examples regarding the ENDO command.

Note

The EXO list is non-cumulative, so all exogenized variables should be present in the same EXO statement

Note that when ENDO and EXO are active, there is a target icon at the bottom right in the user interface, stating the number of goals and means set.

Related

commands

ENDO, SIM, UNFIX


FINDMISSINGDATA

Introduction

This command returns variables with missing values in the Work databank.

Syntax

FINDMISSINGDATA < period > period variables ;

period | (Optional). For instance "2010 2020" or "2010q1 2020q4". If inside the <> field, the period is local to the current statement, if outside the period will be changed globally. If no period is given, global time will be used.
variables | List of variable(s) to check.

If no list of variables is given, all variables in the Work databank will be investigated

Example

For instance, the command

FINDMISSINGDATA <2008 2010>;

looks for all variables with any missing values in the period 2008-2010. You may restrict it like this:

FINDMISSINGDATA <2008 2010> #vars;

where the list #vars contains the relevant variables you want to check. Gekko outputs a number of lists from the investigation: for instance the list #missingdata contains all variables with missing data in the Work databank, whereas the lists #missingdata_all, #missingdata_endo etc. are subsets of that list, and correspond to the Gekko-defined lists #all, #endo etc. (i.e., all model variables, all endogenous model variables, etc.).

You may use wild-card lists if preferable:

FINDMISSINGDATA <2008 2010> [fX*] [fYf*];

This will check all variables starting with 'fX' or 'fYf'.

If a period is not given, the global time setting is used.

Note

The command is convenient when developing new models or changing existing models.

Related

commands

DIFPRT, NDIFPRT, see also 'Utilities' --> 'Compare two databanks'.


FOR

Introduction

The FOR command initiates a loop over lists, DATE's or VAL's.

Syntax

FOR s = list ;

statements... ;

END ;

s | The loop variable s (of STRING type) that can be referenced to as '#s' or {s}.
list | Any list of items (see LIST command). It could be a list of strings (without quotes, and not delimited by commas), and the list may include lists (#mylist) or wildcards (e.g. [fX*]).
Note that you may also use the more explicit syntax "FOR STRING s = list;". Note also that you may use the syntax "FOR(s = list)" if preferable.

FOR DATE d = date1 TO date2 BY step ;

statements... ;

END ;

d | The loop variable d (of DATE type) that can be referenced to as '#d' or {d}.
date1 | Start date
date2 | End date
step | An optional stepsize (default step: 1). Must be integer, and may be negative. Omit "BY step" if not needed.

FOR VAL v = val1 TO val2 BY step ;

statements... ;

END ;

v | The loop variable v (of VAL type) that can be referenced to as '#v' or {v}.
val1 | Start value. Can be any floating point number.
val2 | End value. Can be any floating point number.
step | An optional stepsize (default step: 1). Can be any floating point number, and may be negative. Omit "BY step" if not needed.

Examples

(lists)

You may wish to use the ADAM sector codes to print out production values easily:

FOR i = nf nz qz o;

 PRT <2010 2015> fX{i};   //or: fX#i

END;

Lists can be nested. You may use a pre-defined list after the '=' in the for statement ("FOR i = #mylist;"), or a wild-card list ("FOR i = [fX*];"), or combinations of these. Note also that you may use 'fX#i' instead of 'fX{i}' when referring to the loop variable. Nested loop:

FOR i = a b c;

 FOR j = x y z;

   PRT var{i}o{j};  //or: var#i|o#j

 END;

END;

Note that curly brackets are used here to refer to '#i' and '#j', since 'var{i}o{j}' is a little easier to read than 'var#i|o#j' (Note the use of the delimiter ('|') here: if not used, Gekko will complain that the scalar variable '#io' could not be found). The loop prints the variables varaox, varaoy, varaoz, varbox, varboy, etc.

Examples (DATEs)

To compute the largest number of the variable fX{i}, fpr the sectors i = a, b, nf, qf (for the period #d1 to #d2):

LIST vars = a b nf qf;

VAL max = 0;

DATE dmax = 0;

STRING imax = '';

FOR i = #vars;

 FOR DATE d = #d1 to #d2;

   IF (fx{i}[#d] > #max)

     VAL max = fx#i[#d];

     DATE dmax = #d;

     STRING imax = #i;

   END;

 END;

END;

After this loop, the string #imax will contain the sector name with the highest number, the date #dmax will contain the period, and the value #max will contain the max number. It is assumed that the values are all positive, so that dmax can safely start out with value 0.

Note that for scalar variables '#x' and '{x}' are synonymous. The latter is often practical (that is: more readable) when composing variable names out of substrings like 'fx{i}' ('fx#i' would have been equivalent).

Date loops over for instance quarters will require that the frequency is changed (OPTION freq = q;).

Examples

(VALs)

The VAL loops are very similar to DATE loops

FOR VAL v = 10 to 0 by -2.5;

 TELL '#v';

END;

This will print out the numbers 10, 7.5, 5, 2.5 and 0.

FOR (VAL v = 10 to 0 by -2.5)

 TELL '#v';

END;

Equivalent, using parentheses (the semicolon in the first line may be omitted in this case). This is just to avoid an error if the user assumes the same syntax as the IF command (which has mandatory parentheses).

Note

You may sometimes need to use an explicit type conversion from one scalar variable type to another. In that case, use the functions STRING(), DATE(), or VAL().

Note that regarding individual observations, GENR only accepts for instance var(2010), whereas a scalar is more flexible, for instance "VAL x = var[#t+1]". This limitation in GENR statements will be corrected, but until then you may use VAL's as a bridge (VAL x = var[#t+1]; GENR y = #x;).

Related

commands

END, STRING, DATE, VAL, IF


GENR

Introduction

The command is used to transform timeseries in the Work databank via mathematical expressions. You can think of a GENR statement as performing the same task as a FRML statement in a model. Anything that can be written in a FRML statement in a model file (.frm file) is also legal in a GENR statement (So in principle, you can run an entire model file directly as GENR statements).

Please note that a GENR statement should always end with a ';'.

In order to generate a variable, it must exist in the Work bank. Either it must have been read into the Work bank via the READ command, or it must have been CREATE’d. An exception to this rule is if the new variable starts with ‘xx’. In that case, you do not need to create the variable first. This convention is handy for intermediate/temporary variables.

Syntax

GENR < period > period frmlcode variable = expression ;

period | (Optional). For instance "2010 2020" or "2010q1 2020q4". If inside the <> field, the period is local to the current statement, if outside the period will be changed globally. If no period is given, global time will be used.
frmlcode | Optional formula code may be used to indicate auto-generated D-, J- and Z-variables. This is typically not used for GENR statements, unless they are copy-pasted from a model file (.frm file).
variable | can be a variable from the work databank, or an expression on a variable: log(variable), dlog(variable), dif(variable) or pch(variable)
expression | can be any mathematical expression that is also valid in a model FRML statement. See below regarding legal syntax for expressions

The GENR statement should always end with a ';'.

In general, normal mathematical expressions are allowed. Regarding variables, lags/leads are written with parentheses as variable(-n) or variable(+n), and references to a fixed period as variable(period). Broken (non-integer) lags/leads may be used. For instance, variable(-0.3) = 0.7*variable + 0.3*variable(-1). You may also use scalar variables of VAL type.

Example

Determination of real house price (not an existing variable):

CREATE realphk;

GENR realphk = phk/pcp;

Private consumption Cp4 increased by 100 mill. kr. in 2005-prices for the year 2011-2013, by using the add-factor JCp4:

READ lang11;

TIME 2011 2020;

VAL factor = 1.1;

GENR <2011 2013> JCp4 = JCp4 + 100*pcp4v;

GENR Dlog(tpe) = Dlog(pcp(-0.5));

GENR xxindex = #factor * pcp/pcp(2005);

The first GENR above only sets local time, so the following GENRs will use the period 2011 2020 (global time). If the time period in the first GENR had been without the brackets (i.e. "GENR 2011 2013 …"), the following GENRs would have used the same period (2011 2013). In the last GENR, the variable 'xxindex' is auto-created, since it starts with 'xx'.

If the prefix '@' is added to a variable name, it takes the value from the Baseline databank, eg:

GENR JfIh = JfIh + (fIh-@fIh);

You may also use variables from en OPEN databank, for instance (assuming that the extra databank has been opened by means of "OPEN oldbank"):

TIME 2010 2020;

CREATE oldfy;

GENR oldfy = oldbank:fy;

The variable 'oldfy' will now reside in the Work databank, and will be identical to the variable 'fy' from the databank 'oldbank' (for the period 2010-2020).

Since GENR uses the same syntex as FRML, you may also include formula codes to indicate D-, J- and Z-variables. Typically you would not use a formula code in a GENR, except if you want to run some FRML statements from a particula model as GENR statemens in a command file.

GENR _GJR pch(phk) = 0.5 * pch(pcp);

In such a command, the variable phk will be set to half the percentage growth rate of the variable pcp. But because of the _GJR formula code, the variable JRphk is silently added to the equation. So phk will be affected by JRphk, and Gekko will complain if that variable is missing.

Note

If any of the right-hand side variables are not found, the command will exit with an error. If some of the variables have missing values (shown as 'M' when printing), the left-hand side will become missing as well (for the periods affected). Make sure the expression is followed by a ';' sign.

You may use 'FRML' instead of 'GENR'. Since 'FRML' can be used as a synonym for 'GENR', equations from a model file may be run right away as GENR statements. The same underlying parser is used for both GENR-statements and model equations, but beware that equations in a model run quite a lot faster than GENR statements.

A '$' may be used as an alternative to ending the statement with ';', but '$' will be phased out at some point so please avoid it.

Note that regarding individual observations, GENR only accepts for instance var(2010), whereas a scalar is more flexible, for instance "VAL x = var[#t+1]". This limitation in GENR statements will be corrected, but until then you may use VAL's as a bridge (VAL x = var[#t+1]; GENR y = #x;).

Related

options

OPTION calc ignoremissingvars = no; [yes|no]

OPTION freq = a; [a|q|m]

Related

commands

CREATE, UPD, PRT, VAL


HDG

Introduction

HDG (heading) will put the heading into a databank file. This only works for .tsdx files, since .tsd files do not allow metadata like headings etc.

Syntax

HDG heading ;

heading

A text string without quotes.

Example

Putting a heading on a databank can be useful:

OPTION databank file format = tsdx ;

HDG Bank for multiplier analysis, simulated 2010-2050 ;

WRITE mulbank ;

READ mulbank ;

When reading the .tsdx databank, the following info will be printed on the screen:

Info     : Bank for multiplier analysis, simulated 2010-2050

Date     : 26-10-2011 11:13:31

Databank files in .tsdx format can contain meta-information like headings and date and time when written.

Note

Related

commands

WRITE, READ


HELP

Introduction

The HELP command (or F1) provides access to Gekko help system. Through the HELP command it is possible to get quick help on a command and its syntax etc.

The help system opens up in a separate window and is of the type "Compiled HTML Help" (stored in a .chm file). The help system is browsable/searchable. In Windows 7 and 8, there are restrictions on .chm files. For instance, they cannot be opened from a network drive. Per default Gekko copies the .chm file to a temporary folder on the user's hard disk, in order to avoid this problem.

Syntax

HELP command ;

[empty] | If no argument is given, the help file will open in a general overview section.
command | (Optional). The command on which help is needed. If the command does not exist, the help system will indicate that the file is missing.

Example

If you are in doubt about the syntax for a particular UPD command, you may look directly for this topic in the help file:

HELP upd;

If you cannot remember that the name of the relevant command is UPD (for instance), you may write

HELP;

in order to get the overview of commands grouped by function. Alternatively, just type F1 or use 'Help' --> 'Gekko help file' in the Gekko menu.

Related

options

OPTION folder help = [empty];

OPTION interface help copylocal = [yes|no];

Related

commands

OPTION


IF

Introduction

The IF command is used for conditional execution of different blocks of statements. The IF statement works with STRINGs, DATEs or VALs (or single timeseries observations like fY[2010]).

You may sometimes need to explicitly convert the variables in order to compare them (by means of the functions STRING(), DATE() or VAL()).

Syntax

IF ( expression )

statements1... ;

ELSE

statements2... ;

END ;

expression | A logical expression involving STRINGs, DATEs or VALs (or single timeseries observations like fY[2010]), in addition to the logical operators AND, OR, NOT, '<', '<=', '==', '>=', '>', '<>'. Please note that equivalence uses '==' (and not '='). You may additionally use the same operators that can be used on the right-hand side of a STRING, DATE or VAL statement, for instance '+' or '*'.
statements1 | Gekko commands to be executed if expression is true.
statements2 | (Optional). Gekko commands to be executed if expression is false.

Example

See more examples involving IF in loops in the FOR help file.

A very simple example using the STRING scalar variable.

STRING write = 'yes'

IF (#write == 'yes')      //note the use of '==', using '=' here will fail

 TELL 'Yes chosen';

ELSE

 TELL 'No chosen';

END;

To choose between more choices (and test validity of #write), you may use:

STRING write = 'yes'

IF (#write == 'yes')

 TELL 'Yes chosen';

ELSE IF (#write == 'no')

 TELL 'No chosen';

ELSE IF (#write == 'maybe')

 TELL 'Maybe chosen';

ELSE

 TELL 'ERROR: The scalar variable should be yes, no or maybe';

END; END; END;

This is a little awkward with the three ending ENDs (a 'real' ELSEIF statement will be provided later on to provide easier syntax for several cases).

VAL v = 2000;

STRING s = '2000';

DATE d = 2000;

IF (#v == val(#s) AND #v == val(#d) AND date(#s) == #d )

 TELL 'Ok';

ELSE

 TELL 'Not ok';

END;

This will print 'Ok'. Note that you have to explicitly convert the variables to be able to compare them, otherwise you will get an error. In this case, the conversion functions VAL() and DATE() are used. The conversions may seem obvious and superfluous here, but consider this example:

STRING s = '100';

STRING s1 = '33';

VAL v = 133;

IF (#v == #s + #s1)   //Will give type mismatch error

 TELL 'Ok';

END;

This gives an error, because Gekko does not know how to add #s and #s1. Either they can be converted to VALs first, and then added (100 + 33 = 133), or they can be added as strings ('100' + '33' = '10033') and then converted to VAL (10033). In the first case, the expression would be true, and in the second case it would be false. This is not a contrived example: such errors could easily crop up and introduce hard-to-find bugs and ambiguities. So to avoid ambiguities regarding the type of #-variables when performing logical operations, adding with '+' etc., you have to either use this:

IF (#v == val(#s + #s1))        //will be false

or this:

IF (#v == val(#s) + val(#s1))   //will be true

To access individual observations from a timeseries in the Work databank, use the variable[period] syntax:

TIME 2010 2012;

CREATE data; UPD data = 1 2 3;

DATE d = 2011; VAL v = 2;

IF(data[#d] == #v) TELL 'Ok'; END;

This will print 'Ok'.

Note

Note the use of two equal signs ('==') in IF-command, and '<>' for logically different.

There is also an exist(x) function that returns 0 or 1 depending upon whether the timerseries x exists in the Work databank.

Related

commands

FOR, END, STRING, DATE, VAL


INFO

Introduction

The INFO command can be used to print out right-hand side variables for a given endogenous variable. It can only be used for a one-period time period. It is called automatically if failsafe mode solving is set ("OPTION solve failsafe yes") and the simulation fails.

Syntax

INFO < period > period variables ;

period | (Optional). For instance "2010 2020" or "2010q1 2020q4". If inside the <> field, the period is local to the current statement, if outside the period will be changed globally. If no period is given, global time will be used.
variables | Variable(s) is a list of variables (the whole databank if no variables are given)

Example

To show information regarding the variable fY:

INFO <2010 2012> fY;

Note

INFO will at some point probably be replaced by a special version of the more convenient UDVALG command.

Related

commands

UDVALG, DISP, PRT


INI

 | INI
Introduction | The INI command runs any gekko.ini file (alternatively isstart.cmd), if this file is present in the working folder. See more info on gekko.ini files in the CLEAR help file.
Syntax | INI ;
Note | The CLEAR (or alternatively CLOSEALL) command is in reality a CLEAR<all> command followed by an INI command. If no gekko.ini file is present, CLEAR and CLEAR<all> are equivalent.
Related commands | CLEAR


ITERSHOW

Introduction

The command ITERSHOW returns details of Gauss iterations.

Syntax

ITERSHOW < period > period variables ;

period | (Optional). For instance "2010 2020" or "2010q1 2020q4". If inside the <> field, the period is local to the current statement, if outside the period will be changed globally. If no period is given, global time will be used.
variables | Variable(s) or a list

Example

Use this syntax to show iterations for the variable Enl for the year 2010:

ITERSHOW <2010 2010> Enl;

Details

The command produces output containing (for each iteration) the value of the endogenous variable before and after simulating the Gauss-Seidel loop, and differences, different criteria etc.

The output shows the iteration number, values before and after the iteration. The next column "Hist. var" is the historical variance/variability in the data, obtained by means of looking at lagged historical values of the endogenous variables.

The next column is the difference between the values before and after the iteration, and "Relative1" is this difference divided by the historical variance. This is the criterion Gekko uses for relative convergence per default.

The last column is the difference divided by the value before the iteration. "Relative2" is the criterion used in PCIM. So "Relative1" corresponds to setting "OPTION solve gauss conv = conv1" (default), and "Relative2" corresponds to setting "OPTION solve gauss conv = conv2".

It is often the case that "Relative1" is larger than "Relative2", so using this criterion is stricter and would demand more iterations given the same relative criterion (0.0001 for instance). Sometimes the inverse is true, however, especially when the "Before" value is close to zero, whereas the historical variability is large. In that case, the PCIM-like criterion ("Relative2") would be stricter. But often this will just postpone the solution, in case the variable just happens to be have a solution close to zero in that particular year (but without being close to zero in general). Examples of this could be balances and flows, for instance the balance of payments, net investments, revaluation ("omvurderinger") etc. Close-to-zero solutions for such variables are different in kind from variables with levels generally close to zero (in ADAM, for example interest rates). Looking at historical variability as done in Gekko is actually a means to try distinguishing such classes of variables from each other regarding convergence. If, for instance, the balance of payments can change by an amount of around 20000 (million DKK) from year to year, and the true solution in a particular year just happens to be 1 million DKK, we are not interested in obtaining an extreme precision (i.e., many digits after the decimal point) regarding that particular value. If the variable normally can change by an amount of 20000 from year to year, a solution of 2 is nothing to worry about, even if the true solution is 1. Whereas if the true solution regarding an interest rate is 0.04, an alternative solution of 0.08 is worrying

Note

In order for this command to work, "OPTION solve gauss dump" must first be set to 'yes', and a simulation performed. Beware that setting this option consumes a lot of RAM when simulating, and also slows simulations down. In case of a RAM error, try to limit narrow the time period.

Related

commands

SIM


LIST

Introduction

The command LIST is used to define a list containing variables, to delete a list, or to show current lists ('LIST ?').

Syntax

LIST ? ;

LIST listname = elements ;

LIST listname = #(LISTFILE listfile);

LIST - #listname ;

LIST [wildcard] ;

? | 'LIST ?' will show current lists. Lists related to models (#endo, #exo, etc.) can be seen if clicking the link provided in the output.
= | This is used to assign elements to a list.
- | This is used to remove a particular list (note that the name must start with '#'). This syntax will probably be changed at some point.
[wildcard] | This will just match the wildcard, but will not assign the found elements to any list. For instance "LIST [fX*]" to see the number of variables in the Work databank beginning with 'fX'.
listname | The name of the list (without any '#')
elements | Names of the variables/strings that the list should contain (lists may also appear on the right-hand side), separated by blanks. The individual names can be any digits or letters (and may even start with a '-'). So items like '01' or '-5a' are legal. The special element 'null' indicates creation of an empty list ("LIST empty = null").
listfile | You may use an external listfile instead of indicating the elements in the LIST command. The listfile contains the elements, with each element on its own line (with no commas or other delimiters). If no extension is provided, .lst is added as extension. As of version 1.8, listfiles may only be used in the LIST command, and not inserted into other commands (this will be fixed).

You may use wildcards or lists on the right-hand side of "LIST = ...", for instance "LIST [fY*]" (matching all variables in the Work databank starting with "fY").

Example

The command is very useful to perform repetivite tasks on the same set of variables: for instance updating their values, followed by printing them out etc.

You want to see the effect on private consumption and wage of a 1% rise in price of export market (pee{j}) and home market (pm{j} in for the year 2011-2015.

READ lang11;

LIST pm = pm01 pm2 pm3r pm59 pm7b pm7y pms pmt;

LIST pe =  pee2 pee59 peet peesq;

UPD #pm 2011 2015 * 1.01;

UPD #pe 2011 2015 * 1.01;

SIM <2011 2015>;

MULPRT pcp lna;

Wild-cards (getting all variables beginning with 'fX' or matching "p?nx" where the "?" is a single character):

LIST mylist = [fX*][p?nz];

PRT #mylist;

PRT [fX*][p?nz];

The last to statements produce the same output.

If you need to see defined lists, use

LIST ?;

If the list #pm is not needed anymore it can be deleted like this (remember the '#'):

LIST - #pm;

You may see the variables starting with for instance "fY" like this (without assigning the result to a list):

LIST [fY*];

If the right-hand side contains more elements that may fit on one line, you must use the '&' character to indicate that the line continues:

LIST letters = a b c a b c a b c a b c a b c a b c a b c a b c a b c a b c &

              c e f c e f c e f c e f c e f c e f c e f c e f c e f c e f &

              x y z;

In the future, when ';' becomes mandatory to conclude a Gekko statement, the use of '&' will be avoided. But for now, they are necessary for long lists.

Lists can appear on the right-hand side:

LIST sectors1 =  fXne fXnf fXng ;

LIST sectors2 = fXnq #sectors1;

Adding elements to a list can be done like this:

LIST alphabet =  null;

LIST alphabet = #alphabet a;

LIST alphabet = #alphabet b;

LIST alphabet = #alphabet c;

...

Or compose the list via loops:

LIST items = null;

FOR VAL i = 1 to 3;

 FOR s = a b c;

   STRING temp = 'p' + string(#i) + #s + 's';

   LIST items = #items #temp;

 END;

END;

This will result in items = p1as, p1bs, p1cs, p2as, p2bs, p2cs, p3as, p3bs, p3cs. Here, the 'p' can be thought of as a prefix, and the 's' as a suffix (the string() conversion in the STRING statement above is not strictly necessary).

Using a listfile 'animals.lst' like this:

------------ animals.lst ------

dog

cat

mouse

fish

------------------------------

you can use it in the following way:

LIST animals = #(listfile animals);

Listfiles should not contain blank lines. Listfiles can only be used in the LIST command, not elsewhere (this will be fixed). Like normal lists, listfiles may contain elements beginning with '-' or '#', for instance:

------------ items.lst -------

x1

-x2

#mylist

x3

------------------------------

Using "LIST items = #(listfile items)", the list #mylist will be in-substituted (just as a "LIST items = x1 -x2 #mylist x3" statement).

Note

If there is not enough room for all variables in one line, add the character '&' to join lines (see the #letters-example above).

The lists #all (all variables), #endo (all endogenous variables), and #exo (all exogenous variables) and some more are defined beforehand, if a model is loaded by the MODEL command. See "LIST ?".

You can use minus ('-') before a list item. This can for instance be used in the Laspeyres chain index function LASPCHAIN(), to indicate a variable that is to be deducted. For instance:

LIST quantities = x1 x2 -x3 x4;

LIST prices = p1 p2 p3 p4;

Then the function

GENR (p, x) = LASPCHAIN(#prices, #quantities, 2010);

will create aggregate p and x series, where element 'x3' is to be deducted from the aggregation (and the price p is set to 1 in 2010). There is also a LASPFIXED() function with the same syntax, using fixed prices as weights.

You may also use the older syntax "LIST #mylist a b c" instead of "LIST mylist = a b c", but the older syntax will be deprecated in the long run.

Related

commands

UPD, PRT


MEM

Introduction

Prints a list of all scalar variables (STRING, VAL, DATE).

Syntax

MEM;

Example

Consider this example:

STRING s1 = 'cat';

STRING s2 = 'dog';

VAL v = 123.45;

DATE d1 = 2010;

DATE d2 = 2011q3;

MEM;

This will produce an overview similar to this:

5 scalar variable(s) found

---------------------------------------

 Name         Type         Value

---------------------------------------

 d1           Date         2010

 d2           Date         2011q3

 s1           String       cat

 s2           String       dog

 v            Val          123.45

---------------------------------------

Note

You may alternatively print a VAL-variable v with "PRT #v". This will show the same value for each observation in the global time settings.

Related

commands

STRING, DATE, VAL


MENU

Introduction

MENU is not a command, but the 'Menu' tab will open up a .html menu file when clicked (regarding the .html file, see 'Related options' below). Menus can for instance be used to organize tables in hierarchies. The easiest way to start up the menu system is to click on the 'Menu' tab. Another possibility is via 'Window' --> 'Restart Menu' (in the Gekko user interface).

Menu's are browsable, i.e., you may use the backwards and forwards arrows. The 'Home' button will point the menu to the starting .html file.

Details

The html file will be shown in the 'Menu' tab in the same way as the html file would be shown in an internet browser. The only real difference is that links work in a slightly different way. If the link is to a file with extension .tab, Gekko will show that particular table (as text in the 'Main' tab, or as html in the 'Menu' tab, depending upon the setting 'OPTION table type...').

For instance, the html may contain the following HTML code:

<a href="s43.tab">Production</a>

The <a> tag indicates a link, with link text "Production". The linked file is s43.tab. Since this is a .tab file, Gekko shows this particular table when the link is clicked.

You may design the HTML pages in any way you like, for instance it can be convenient to style menus by means of a common stylesheet (CSS), so that their design can be controlled centrally. Gekko will show just about all legal HTML code you may come up with, including images etc.: the engine showing the HTML in the 'Menu' tab is in reality the same engine that is used for showing pages in Internet Explorer.

The HTML files can be made by means of any HTML editor, for a free and quite robust editor, you may for instance try the free Kompozer (based upon the Firefox HTML engine).

There is an automatic menu conversion tool from the older PCIM menus to the new HTML format. See the menu: 'Utilities' --> 'Converters' --> 'PCIM converters' --> 'Convert PCIM menus...'.

Example file

The HTML code below shows a menu ('OVERVIEW') with five items. The two first items link to two different submenus (menu1/menu2.html), whereas the two following links link to two different tables (s1/s2.tab). The last item gives the opportunity to browse a level up to a parent menu (main.html).

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<link rel="stylesheet" href="styles.css" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>OVERVIEW</title>
</head>
<body>
<big><b>OVERVIEW</b></big><br>
<ul>
<li><a href="menu1.html">SUPPLY BALANCE</a></li>
<li><a href="menu2.html">IMPORTANT KEY FIGURES ETC.</a></li>
<li><a href="s1.tab">Production <img src="table.png"><font color="gray"> S1 </font></a></li>
<li><a href="s2.tab">Productivity <img src="table.png"><font color="gray"> S2 </font></a></li>
<li><a href="main.html">***MAIN MENU*** Back</a></li>
</ul>
</body>
</html>

The HTML file uses a stylesheet (styles.css) which can be common the all the HTML files in the menu system. In addition, a small table icon is used (table.png), to indicate that the item points to a table.

The stylesheet styles.css could be something like this:

body {
color: #000000;
font-family: Verdana;
font-size: 10pt;
font-style: normal;
font-variant: normal;
background-color: white;
}
a {text-decoration: none;}
img {border-style: none;}

This sets colors, font, size etc., and indicates that HTML links (<a>) should have no underline, and HTML images (<img>) no border.

Note

In the longer run, it is the intention to use the system to open up or access other kinds of Gekko files, for instance models, databanks or command files.

A menu system may be organized in folders and sub-folders, if preferred. In that case, call the html file in the subfolder with <a href="subfolder/menu1.html"> for instance. To navigate to a parent folder, use '..', for instance <a href="../menu1.html">. These are standard html conventions regarding relative paths.

Anything can be put into the html file, but Gekko will not open up Internet links in the Menu tab. If an external Internet link is present (for instance http://www.t-t.dk/gekko), Gekko will open that link with the default web browser.

Related

options

OPTION menu startfile = menu.html;

OPTION folder menu = ...;

Related

commands

TABLE


MODEL

Introduction

The MODEL command is used to load model files (i.e., files with extension .frm, containing model equations). See at the bottom of this help file regarding equation syntax etc.

Please put a MODEL statement before READ statements: in that way all model variables not found in the databank will be auto-created when issuing the READ statement.

Syntax

MODEL filename ;

MODEL * ;

filename | The filename may include a local or global path.
* | If the filename is set to '*', you will be asked to choose the file in Windows Explorer.

Example

If the model file name is 'adam2.frm', you may load the file as follows:

MODEL adam2;

Note that extension '.frm' is automatically added if it is missing.

MODEL othermodels\adam3;

This will look for adam3.frm in the subfolder 'othermodels', relative the the Gekko working folder. When a model is loaded, it is first parsed. During this phase, you will get errors if parentheses are missing etc. Gekko will also warn against dublets (for instance two equations with the same left-hand side variable).

The MODEL statement also orders the equations, and compiles the model. The ordering splits the model into three parts: the prologue (pre-model), the simultaneous part, and the epilogue (post-model). So Gekko will automatically detect any pre- and post-model and will use this information in order to speed up simulations (hence, PCIM’s 'AFTER$' statement is ingnored if it is present in a model). The simultaneous part of the model is sub-divided into two parts: the feedback variables, and the simultaneous recursive variables. This information is used to speed up the Newton algorithm, by reducing the dimensionality of the simulteaneous equations.

After ordering, Gekko emits some files containing lists of exogenous, endogenous, and DJZ-type variables (that is, add-factors and variables used for exogenization). It also emits a file with ordering information. These files are assembled into a .zip-file with the name '[model]__info.zip', where [model] is the name of the model.

Model files (.frm files) consist of equations. A model may contain thousands of equations - there is no limit on this number other than available RAM. The equations have the following syntax (cf. also the GENR help file):

FRML frmlcode variable = expression ;

frmlcode | May be used to indicate auto-generated D-, J- and Z-variables.
variable | A variable or an expression on a variable: log(var), dlog(var), dif(var) or pch(var)
expression | Any mathematical expression
You may use '$' instead of ';' at the end of the equation, but ';' is encouraged since '$' may be deprecated at some point.

An example to illustrate, we will consider a particularly simple equation:

FRML _GJDD Dif(y) = Dif(x) $

Ignoring for a moment the formula code, we first note that the equation uses the Dif() function, given as Dif(x) = x - x(-1). Hence, we get this equation:

FRML   y  =  y(-1) + x - x(-1) $

Next comes the formula code ('_GJDD'). This means that an add factor (JD) will be added, with the name JDy. So our equation is augmented into

FRML   y  =  y(-1) + x - x(-1) + JDy $

Last, exogenization dummies are added, too. This is done in order to ease exogenization of the equation, if needed. In general, such variables are add in the following way. Augmented with these, the equation becomes:

FRML   y  =  (1-Dy) * (y(-1) + x - x(-1) + JDy) + Dy * Zy $

As you can see, two variables are added, Dy and Zy. If Dy = 0, the two variables have no effect, but if Dy = 1, the equation reduces to y = Zy. I.e., the equations is given by the exogenous Z-variable Zy (or in other words, the variable y will always be set to this value, corresponding to exogenizing it). This is the equation used internally in Gekko. In addition to this equation, Gekko adds two more “reverted” equations regarding JRy1 and Zy1. These equations are not part of the "real" model, but are calculated after each simulation:

Reverted1: JDy = y - (y(-1) + x - x(-1)) $

Reverted2: Zy = y $

If Dy = 0, it is easy to see that JDy will not change its value (together with the above FRML, the first reverted equation reduces to JDy = JDy). But if Dy = 1, JDy will get the value that corresponds to what Zy might have been set to (JDy = Zy - (y(-1) + x - x(-1))). This way, you may set Dy = 1, and Zy to some chosen value. When you simulate, y will assume that value. Later on, you may reset Dy = 0 and simulate. You will notice that y still assumes the chosen value. So these exogenization dummies can be used to change the levels of endogenous variables, but keeping them endogenous if a multiplier is run on top of that.

The same functionality is often used for log-linear equations. Such an equation would look like:

FRML _GJRD Dlog(y) = Dlog(x) $

The add-factor (J-variable) is now relative (code ‘JR’), and the resulting equations become more complicated, but the basic idea is the same. See also the closely related GENR command.

You may use parameter values instead of numerical values, for instance:

VAL c = 0.758812;

FRML Y = #c*X1 + (1-#c)*X2 $

The parameter value must be located in the model file, either before or after the FRML statement(s) using it.

Note

You may use broken lags, for instance x(-0.3). This is translated into 0.7*x + 0.3*x(-1). Leads (broken or unbroken) are allowed, too. For exponents, please use either 'a^b' or 'a**b' ('pow(a,b)' is also possible).

You may now put meta-information into the model file (.frm). As of now, Info, Date, and Signature fields are supported. Example (to be put in the top of the model (.frm) file):

// Info: Model used for forecasting 2012-2030

// Date: 7-11-2012 15:37:00

// Signature: fp88RzyZfJNaoTi3I4X3Ww

Gekko will complain if this format deviates, for instance the Info field is to be written with capital 'I', with no blank before the colon, and one blank after the colon. This rigorousness regarding form is to make it easy to spot the information in different .frm files. The Info and Date fields will be displayed when loading the model (MODEL command), and the Signature field is used for verifying that .frm files have not been changed relative to an 'official' version. The signature for a particular .frm file can be obtained with the SIGN command.

Related

options

OPTION folder model = [empty];

Related

commands

SIM, RES, EFTER, GENR, READ


MULBK

Introduction

The command MULBK (with a file name argument) reads the databank file into the Base (baseline) databank. After this, you may use for instance "MULPRT x" to print the difference between the variable x in the Work and Base databanks (or PPLOT<m>, WPLOT<m> or CPLOT<m> to graph the difference, or show the difference in a spreadsheet).

If used without an argument, the command copies the Work databank into the Base databank. After this, all variables in the two banks are identical, and all MULPRTs will show 0 differences.

Syntax

MULBK ;

MULBK < filetype COLS > filename ;

MULBK < filetype COLS > * ;

[empty] | If 'MULBK' is used without arguments, the Work databank is copied into the Base databank.
filetype | (Optional). Can be 'tsd', 'tsdx', 'pcim', 'csv', 'xls', 'xlsx'. The default file format is 'tsdx'.
filename | The filename of the databank to be read into the Base databank. The filename may include a local or global path.
COLS | (Optional). For .csv or Excel files, this indicates whether the timeseries are running downwards in columns.
* | If the filename is set to '*', you will be asked to choose the file in Windows Explorer

Example

Effects on GDP (fY) due to increases in government purchases (JDfVmo) can be analyzed as follows:

MODEL adam;

READ histdata;

TIME 2010 2050;

SIM;

WRITE grund;  //See the next example for a terse version of this

MULBK grund;

UPD <2010 2010> JDfVmo + 1000;

SIM;

MULPRT fY;

The first SIM is the reference, or baseline scenario. Note: If this simulation is already stored in the databank 'histdata', the first SIM, WRITE and MULBK statements may be omitted, since the READ command creates the Base databank as an exact copy of the Work databank after reading (cf. READ).

Instead of storing a temporary databank on your hard disk ('grund.tsdx' in the above example), and reading it from file into your Base databank (in memory), you may use the MULBK command without argument in this way:

MODEL adam;

READ histdata;

TIME 2010 2050;

SIM;

MULBK;

UPD <2010 2010> JDfVmo + 1000;

SIM;

MULPRT fY;

Here, the MULBK statement replaces "WRITE grund" and "MULBK grund". Without a filename argument, data is not read from a file, but instead copied from the Work bank (in memory). So you may think of "MULBK" (without a filename) as copying the Work databank into the Base databank (in memory). This syntax is more compact, you avoid the temporary .tsdx databank, you don’t lose precision while writing and reading from the .tsdx file, and it runs a little faster, too.

The difference between two files dataNew.tsdx and dataOld.tsdx can be analyzed in this way:

READ dataNew;

MULBK dataOld;

TIME 1980 2050;

MULPRT fY;

PPLOT fY @fY;

The files may alternatively be of type .tsd, .pcim, or .csv: for instance MULBK<tsd>dataOld will read dataOld.tsd. Note that in this example the READ statement precedes the MULBK statement. The order must be like this, since the READ statement always creates the Base databank as an exact copy of the Work databank after reading.

You may alternatively compare the two databanks more thoroughly by choosing ‘Utilities’ --> ‘Compare two databanks…’ in the Gekko menu items. An other alternative is the DIFPRT and NDIFPRT commands.

Note

The READ command always creates the Base databank as an exact copy of the Work databank after reading.

The Base databank is used in multiplier analysis, for instance the MULPRT command etc. Prefixing a variable with '@' indicates that the variable should be taken from the Base databank (as in the ‘PPLOT fY @fY’ statement shown above).

When comparing Work and Base databanks, the so-called print codes are often convenient. See the PRT help file, but as an example you may use "MULPRT fY", "PRT<m>fY", or "PPLOT<m>fY", "WPLOT<m>fY".

See also the UDVALG window regarding comparisons.

Instead of reading into the Base databank, you may use the OPEN command. This opens up the bank as a named bank that can be referenced with colon (for instance OPEN dataExtra; PRT dataExtra:fY").

Related

options

OPTION databank file copylocal = yes;

OPTION databank file format = tsdx; [tsd|tsdx]

OPTION folder bank = [empty];

OPTION folder bank1 = [empty];

OPTION folder bank2 = [empty];

Related

commands

READ, OPEN, MODEL, MULPRT, RES, SIM, UDVALG, CONVERTPRN


MULPRT

Examples

Introduction

The MULPRT command prints multipliers of variables, lists or expressions. A multiplier is the difference between values in the Work and Base databanks.

Regarding syntax and possibilities, please see the PRT command. Regading syntax and possibilities, the key difference between the two print commands is that the print-codes are different:

·Short print-codes like d, p, m, q etc. cannot be used in the MULPRT command

·The long print-codes are a little different

·There is the additional print-code v for 'verbose' output with many details (code v cannot be used in the PRT command).

Syntax

MULPRT < period printcodes decimals width ROWS FILTER=filter > period elements HEADING='text' FILE=filename ;

where:
period | per1 per2
printcodes | printcode printcode ...
printcode | LEV, ABS, PCH, GDIF, V (note: V overrides any other printcodes)
decimals | DEC=number | NDEC=number | PDEC=number
width | WIDTH=number | NWIDTH=number | PWIDTH=number
elements | element element ...
element | variable 'label' < printcodes decimals width >
details:
period | (Optional). For instance "2010 2020" or "2010q1 2020q4". If inside the <> field, the period is local to the current statement, if outside the period will be changed globally. If no period is given, global time will be used.
printcodes | (See tables in examples section). Long printcodes: lev, abs, pch or gdif. These can be switched off by means of prefix no (for instance nopch), or added to existing default printcodes by means of underscore (for instance _lev). Default printcodes are abs and pch (absolute and percentage multiplier is printed). Finally, you may use the v printcode to get verbose (detailed) output. Also see "OPTION print mulprt ...".
element | The variable can be a variable name, a list (for instance #mylist), or an expression (for instance gdp/pgdp). Labels are put in single quotes (will be ignored for lists). Printcodes here will override other printcodes (globals ones, or those set on the MULPRT statement), so element-printcodes are local to the particular element.
DEC= | Sets number of decimals, will apply to all kinds of numbers.
NDEC= | Sets number of decimals for non-percentage numbers. See also "OPTION print fields ndec...".
PDEC= | Sets number of decimals for percentage numbers. See also "OPTION print fields pdec...".
WIDTH= | Sets width, will apply to all kinds of numbers.
NWIDTH= | Sets width for non-percentage numbers. See also "OPTION print fields nwidth...".
PWIDTH= | Sets width for percentage numbers. See also "OPTION print fields pwidth...".
ROWS | If set, the result will be transposed, i.e., with variables running downwards.
FILTER= | A timefilter can be activated or deactivated (see TIMEFILTER command). With <FILTER> or <FILTER=yes>, the current timefilter is used. With <NOFILTER> or <FILTER=no>, any filtering is deactivated. The filter type can also be changed locally, for instance <FILTER=hide> hides the out-filtered periods, whereas <FILTER=avg> averages the out-filtered periods. See "OPTION timefilter...".
HEADING= | A heading in quotes.
FILE= | A filename that the print is put into.

Note: You must specify at least one element.

For instance, "MULPRT <2010 2015> x1 x1/x2 #y;" will print out multiplier differences regarding x1, x1/x2 and the elements in the list #y, for the period 2010-2015. If the period is put outside the option field (< >), the global time period will be changed to 2010-2015.

Long printcodes for MULPRT

lev | Absolute level: x
abs | Absolute multiplier: x-@x(-1)
pch | Relative multiplier: (x/@ -1)*100
gdif | Multiplier in growth rate: (x/x(-1) -1)*100 - (@x/@x(-1) -1)*100
v | Prints verbose output (very detailed, overrides other printcodes)

Note: For MULPRT the so-called 'short' printcodes are not available (see PRT).

As default, MULPRT always prints out corresponding to "MULPRT <abs pch>", i.e., printing out the absolute level and the growth rate. These default options can be altered in "OPTION print mulprt ..." (see 'Related options' below). For instance, to only print the absolute multiplier of a variable, use MULPRT<abs>, to only print the relative multiplier, use MULPRT<pch>. You can alternatively switch options off with a preceding 'no', for instance MULPRT<nopch> (same as MULPRT<abs>) etc. In addition, you can use the 'glue' character '_' to add options to existing options. For instance, MULPRT<_lev> will correspond to MULPRT<lev abs pch>, because 'lev' is added to the default options ('abs' and 'pch'). You may put the codes after individual elements, for instance "MULPRT var1<pch> var2<abs>", to have var1 displayed as pch and var2 displayed as abs. Codes put on an element override more general codes put directly after MULPRT, so "MULPRT<pch> var1 var2<abs>" yields the same result.

The so-called 'short' print-codes (d, p, m, q etc.) can only be used with the PRT command.

In addition to the above transformations, the print can be formatted regarding the width of each data column, and the number of decimals. Please see the PRT help file regarding the syntax and capabilities.

The output can be transposed by means of the ROWS keyword, for instance "MULPRT<rows> gdp pgdp". This is handy for printing a long list of timeseries, or for copy-pasting the cells to a spreadsheet by means of the copy-button in the Gekko interface.

Finally, you can use a timefilter (see TIMEFILTER) in the MULPRT option field. See examples in the PRT help file.

If referencing a variable present in an 'extra' databank opened by means of the OPEN command, beware that "MULPRT extrabank:variable" will print the difference between extrabank:variable and Base:variable, that is, Gekko looks for the same variable in the baseline databank. Hence, "MULPRT variable" and "MULPRT extrabank:variable" yields the same result if the variable in 'extrabank' has the same values as in the Work databank.

Example

After performing some experiment, you may use "MULPRT fY" to print out the multiplier regarding the variable fY:

                  fY      (E)%

 2011       806.0090      0.06

 2012       917.4147      0.06

 2013       872.7069      0.06

 2014       834.6051      0.06

The '(E)' indicates that fY is endogenous ('(X)' indicates exogenous)).

Regarding width and decimals formatting, or using timefilters, see the examples in the PRT help file.

You may use "MULPRT<v>" ('v' for verbose) to obtain more detailed multiplier output:

                  fY         %       Baseline         %     Difference         %

 2011   1432173.5090      3.82   1431367.5000      3.76       806.0090      0.06

 2012   1464027.0397      2.22   1463109.6250      2.22       917.4147      0.06

 2013   1492288.9569      1.93   1491416.2500      1.93       872.7069      0.06

 2014   1513081.9801      1.39   1512247.3750      1.40       834.6051      0.06

The last two columns correspond to the normal MULPRT statement, whereas the four first columns show levels and growth rates from the Work and Base databanks respectively. Note that the last percentage column is not the difference between the other percentage columns. Such a difference is the growth rate multiplier (MULPRT<gdif> or PRT<mp>). So the 0.06 in the last row above is (834.6051/1512247.3750)*100, not 1.39-1.40.

Note

If a model is loaded (see MODEL), the MULPRT command indicates '(E)' for endogenous, and ('X') for exogenous variables. Missing values are shown with a 'M' instead of numbers. If some variable is missing in the databank, an error message will be issued.

You may change what is printed as default via the "OPTION print mulprt ..." options (see 'Related options' below). For instance you may want to switch off printing of percentage growth permanently: "OPTION print mulprt pch = no".

Related

options

OPTION freq a; [a|q|m]

OPTION print filewidth = 130;

OPTION print width = 100;

OPTION print fields ndec = 4;

OPTION print fields nwidth = 13;

OPTION print fields pdec = 2;

OPTION print fields pwidth = 8;

OPTION print mulprt lev = no;

OPTION print mulprt abs = yes;

OPTION print mulprt pch = yes;

OPTION print mulprt gdif = no;

OPTION print mulprt v = no;

OPTION timefilter type = hide;

OPTION timefilter = no;

Related

commands

PPLOT, WPLOT, CPLOT, PRT, DISP, INFO, UDVALG


NDIFPRT

Introduction

The NDIFPRT command is very simular to DIFPRT command. The difference is that NDIFPRT produces more compact output, showing only absolute differences.

Syntax

NDIFPRT < period > period variables [file = filename];

period | The period for which data is compared
variable | Variable or a list of variables, if no variables are given, the whole databank is compared
filename | The file you want to write the variables to.

Example

Please see the examples regarding the DIFPRT command.

Related

options

OPTION databank compare tabs = 1.0;

OPTION databank compare trel = 0.0001;

Related

commands

DIFPRT, MULBK


OPEN

Introduction

The OPEN command reads timeseries from a databank file into a databank with the same name as the file (minus the extension). A databank opened in the way is called a 'named' databank (in contrast to READ and MULBK which operate on databanks with reserved names ('Work' and 'Base', respectively)). Named databanks are read-only, and are closed with the CLOSE command.

Variables in named (OPEN) databanks are referred to by means of colon (':'), for instance 'adam:fY' if the databank read is adam.tsdx, containing the variable 'fY'. Note that you can get a list of available in-memory databanks (including Work and Base) by means of the F2 key. In this window, you may also reassign databanks, for instance swapping the Work databank with an OPEN databank (after swapping, PPLOT or UDVALG windows may be refreshed by means of clicking their 'Update'-button). When databanks are swapped, Gekko enters 'swap-mode' where only select commands are legal (such as PRT, PPLOT, WPLOT etc.). Unswapping can be done via the F2 window, or the UNSWAP command. (After unswapping, there are no restrictions on which commands can be used).

The order in which databanks are opened is not of any importance (unlike in for instance the software package AREMOS). A variable 'fY' is always taken from the Work databank (and if it is missing, Gekko will not look for it elsewhere). Likewise, '@fY' is always fY taken from the Base databanks, and 'adam:fY' is always fY taken from the in-memory databank 'adam'.

Syntax

OPEN < filetype COLS > filename AS aliasname ;

filetype | (Optional). Can be 'tsd', 'tsdx', 'pcim', 'csv', 'xls', 'xlsx'. The default file format is 'tsdx'.
filename | The file name may include a path. If the filename is set to ‘*’, you will be asked to choose the file in Windows Explorer
COLS | (Optional). For .csv or Excel files, this indicates whether the timeseries are running downwards in columns.
aliasname | (Optional). The name that is used when referencing the databank. Default is the filename minus extension.

Example

Opening a .tsdx file called adam21072012.tsdx is done with

OPEN adam21072012;

or by writing

OPEN *;

and then selecting the databank. Afterwards, you may reference variables in the databank by means of for instance:

PRT fY @fY adam21072012:fY;

This will print out the 'fY' variable from Work, Base, and 'adam21072012' databanks. You may use an AS alias to shorten the databank name:

OPEN adam21072012 AS adam;

PRT fY @fY adam:fY;

Try pressing F2 to open up the databanks window. This window provides an overview regarding the different open databanks (including Work and Base). You may drag and drop databanks to reorder this list and for instance alter an OPEN databank into the Work and Base databanks. After reordering (that is: reassigning databank names), you may click the "Update" button on any graph (PPLOT) or decomposition table (UDVALG) and see the result of reassigning the databanks (or use 'Window' --> 'Update' in the Gekko menu to update several windows at once).

Note

When reading, extension '.tsdx' is automatically added if it is missing. Global time settings does not affect the OPEN command, so all the data in the .tsdx file is read into the databank regardless of how the timeperiod is set in Gekko.

See the READ command for more information on databank formats.

Related

options

OPTION databank file copylocal = yes;

OPTION databank file format = tsd; [tsd|tsdx]

OPTION folder bank = [empty];

OPTION folder bank1 = [empty];

OPTION folder bank2 = [empty];

Related

commands

READ, WRITE, MULBK, CONVERTPRN


OPTION

Introduction

The command sets various global option values, in a hierarcical tree of possibilities. ‘OPTION ?’ gives an overview regarding different options and their current values. Below, the different options are described (with their default values indicated).

Note that Gekko provides suggestions (a small popup-window) for the OPTION command (see "OPTION interface suggestions = option"), to aid the user navigate the option tree.

Syntax

OPTION optiontype = value;

optiontype | One or more space-delimited options
value | Boolean (e.g.: yes|no) Integer (e.g.: 200) Floating point number (e.g.: 0.45) String (eg.: newton)

Note: the '=' may be omitted: "OPTION freq q" and "OPTION freq = q" are identical.

Below the full list of options are provided, with their default values.

Options

OPTION calc ignoremissingvars = no; [yes|no]

It is normally not allowed to put data into a variable that does not exist beforehand (unless the variable name starts with the characters 'xx'). The CREATE command is used for such variable creation. but if the option is set to 'yes', the variable will be auto-created when data is put into it. For instance, the command "UPD myvar = 25;" or "GENR myvar = 25;" will auto-create the variable 'myvar' if it does not exist already in the Work databank.

OPTION databank compare tabs = 1.0;

OPTION databank compare trel = 0.0001;

These options set limits regarding the DIFPRT and NDIFPRT commands (comparing the Work and Base databanks).

OPTION databank file copylocal = yes;

If 'yes', when reading (READ) or opening (OPEN) a databank, the file will first be copied into a temporary file on the users hard drive. This will in many instances speed up reading/opening files on network drives.

OPTION databank file format = tsdx; [tsd|tsdx]

You may choose between 'tsd' or 'tsdx'. The .tsdx format provides higher precision, meta-information etc. See the READ/OPEN commands.

OPTION databank file tsdx compress = yes;

OPTION databank file tsdx version = 1.1; [1.0|1.1]

Some options regarding the .tsdx format, applying only to writing databanks (WRITE). Normally there is no need to change the .tsdx version, and compression provides small databank files. Without compression there is some speed gain while writing and reading, but in most cases the speed gain does not outweigh having to deal with much larger databank files.

OPTION folder = yes; [yes|no]

If yes, Gekko will look for files in predefined folders (is switched on per default).

OPTION folder add = [empty];

While looking for add files (ADD command), Gekko will first look for .add files in the working folder, and then in the 'add' folders. Please note that ADD and .add files are going to be phased out in the longer run (RUN and .cmd will be used).

OPTION folder bank = [empty];

OPTION folder bank1 = [empty];

OPTION folder bank2 = [empty];

While reading or opening databanks (READ/OPEN), Gekko will first look for databanks in the working folder, and then in the 'bank', 'bank1' and 'bank2' folders (in that order). If the folder contains blanks, single quotes should be used (for instance "OPTION folder bank = 'c:\my banks' "). Relative paths may be used: "OPTION folder bank = \databanks". In that case, Gekko will look for a sub-folder 'databanks' in the working folder. If 'bank' is set, databanks are written to that folder (WRITE).

OPTION folder cmd = [empty];

OPTION folder cmd1 = [empty];

OPTION folder cmd2 = [empty];

While looking for command files (see RUN), Gekko will first look for .cmd files in the working folder, and then in the 'cmd', 'cmd1' and 'cmd2' folders (in that order).

OPTION folder help = [empty];

Folder where Gekko looks for the help system (gekko.chm file). Normally this file is located where Gekko is installed (and comes bundled with the installer files).

OPTION folder menu = [empty];

Folder where Gekko looks for menu files (.html files).

OPTION folder model = [empty];

Folder where Gekko looks for model files (.frm files).

OPTION folder pipe = [empty];

Folder where Gekko pipes out text output files (see the PIPE command). If no folder is indicated, piped files will end up in the working folder.

OPTION folder table = [empty];

OPTION folder table1 = [empty];

OPTION folder table2 = [empty];

Folders where Gekko looks for table files (.tab files). Gekko will first look in 'table', then 'table1', and last 'table2' folders.

OPTION folder working = [empty];

This changes the Gekko working folder. (For advanced users: note that you can also use the parameter '-folder' with the gekko.exe file, for instance: "gekko.exe -folder:c:\mygekkofiles").

OPTION freq = a; [a|q|m|u]

Sets frequency of timeseries to 'a' (annual), 'q' (quarterly), 'm' (monthly), or 'u' (undated).

OPTION graph lines points = yes; [yes|no]

Whether or not the PPLOT graph has individual points indicated with markers.

OPTION interface csv decimalseparator = period; [period|comma]

Used with READ<csv> and WRITE <csv> local option, where the databank is written as a csv (comma separated) file. The decimal separator in the .csv file will correspond to the indicated setting.

OPTION interface debug = dialog; [dialog|none]

Choose between 'dialog' or 'none'. If 'dialog', the user may rerun a file on syntax errors, or skip lines on runtime errors.

OPTION interface excel decimalseparator = period; [period|comma]

The option is used in three places: (1) in the CPLOT command, (2) regarding the 'Copy'-button on the user interface (copying cells from the last print to the clipboard), and (3) regarding copy-pasting cells from the UDVALG window. The setting is not relevant for WPLOT which does not use the clipboard. (The option will likely change name to "OPTION interface clipboard decimalseparator..." at some point).

OPTION interface excel language = danish; [danish|english]

If set to 'danish', CPLOT, WPLOT and the 'Copy' button will use the Excel code "ikke.tilgængelig()" instead of "na()" to indicate missing values. Also, if set to 'danish', WRITE<csv> will use '#NAVN?' for missing values (alternatively, it uses '#NAME?').

OPTION interface excel modernlook = yes; [yes|no]

Turns on modern looking blue colors in WPLOT.

OPTION interface help copylocal = yes;

If this option is active, Gekko will copy the file gekko.chm into a local folder on the user's hard disk, before it is opened (for instance with F1, or the HELP command). In Windows 7 and 8, problems will arise when trying to open up a .chm files from a network drive, so keeping the option active should eliminate such problems.

OPTION interface sound = no; [yes|no]

If active, Gekko will play a sound when a command file finishes (or has an error). See also "OPTION interface sound type" and "OPTION interface sound wait" for more options regarding sounds.

OPTION interface sound type = bowl; [bowl|ding|notify|ring]

The sound type, choose between 'bowl', 'ding', 'notify' or 'ring'.

OPTION interface sound wait = 60;

The minimum duration of the job (in seconds), before for Gekko plays a sound. Used to avoid too much noise regarding fast-executing jobs.

OPTION interface suggestions = option; [none|option]

If set to 'option', small popup with suggestions will appear when entering options.

OPTION interface zoom = 100;

The zoom level (default = 100%) regarding font sizes in the user interface (the three tabs in the main window). May be increased on high-res monitors, or for educational purposes (projector).

OPTION menu startfile = menu.html;

The filename for the html menu file shown in the 'Menu' tab (see MENU).

OPTION model cache = yes; [yes|no]

Whether or not a model cache is used.

OPTION model cache max = 20;

The maximum number of compiled models kept in RAM (cached), during a Gekko session. Reduce the number if you for instance are doing a lot of ENDO/EXO simulations and run into memory issues.

OPTION print disp maxlines = 3;

The number of lines of data shown per default in the DISP command.

OPTION print fields ndec = 4;

OPTION print fields nwidth = 13;

OPTION print fields pdec = 2;

OPTION print fields pwidth = 8;

These options set the default decimals and width of number fields when printing with PRT or MULPRT. The first two sets decimals and width for for non-percent fields, and the two last for percent fields.

OPTION print filewidth = 130;

File width (characters) when printing into a file

OPTION print mulprt abs = yes; [yes|no]

OPTION print mulprt gdif = no; [yes|no]

OPTION print mulprt lev = no; [yes|no]

OPTION print mulprt pch = yes; [yes|no]

OPTION print mulprt v = no; [yes|no]

These options set the default way of printing with the MULPRT command. Per default, 'abs' and 'pch' are chosen, so MULPRT shows absolute multiplier difference ('abs'), and relative difference ('pch'). These can be overridden via the option fields in the MULPRT command.

OPTION print prt abs = yes; [yes|no]

OPTION print prt dif = no; [yes|no]

OPTION print prt gdif = no; [yes|no]

OPTION print prt pch = yes; [yes|no]

These options set the default way of printing with the PRT command. Per default, 'abs' and 'pch' are chosen, so PRT shows the absolute level ('abs'), and the growth rate ('pch'). These can be overridden via the option fields in the PRT command.

OPTION print showpch = yes; [yes|no]

If set, percentage growth (or percentage difference) is shown for normal prints like "PRT fY" or "MULPRT fY".

OPTION print width = 100;

Width (characters) when printing to screen

OPTION solve data createvars = yes; [yes|no]

If yes, when a databank is read by means of the READ command, all model variables not present in the file are auto-created (and filled with missing values).

OPTION solve data ignoremissing = no; [yes|no]

If 'yes', if a variable has a missing value when Gekko tries to simulate (SIM), the number zero will be used instead. Warning: this may get the model to simulate, but the result may not be correct.

OPTION solve data init = yes; [yes|no]

If yes, when simulating lagged values are used as starting values for endogenous variables (this is default and typically most robust). If no, the current period values are used as starting values for endogenous variables.

OPTION solve data init growth = yes; [yes|no]

OPTION solve data init growth min = -0.02;

OPTION solve data init growth max = 0.06;

If set 'yes', Gekko will look at the historical growth rate of endogenous variables, in order to come up with good initial values. With the sub-options 'min' and 'max', you may indicate a range. Per default, the range is set to -2% up to 6%, meaning that only historical growth rates within that range will be used to initialize endogenous variables. The 'growth' option typically speeds up SIM convergence, provided resonable min/max limits are used.

OPTION solve failsafe = no; [yes|no]

If yes, the Gauss algorithm will stop at the exact time when any equation produces a missing value. The option only applies to the Gauss algorithm, and slows it down a bit. When the option is on, variables from the above-mentioned problematic equation will be printed out on screen automatically (using the INFO command).

OPTION solve forward fair conv = conv1; [conv1|conv2]

Set Fair-Taylor convergence type to 'conv1' (default) or 'conv2'. This corresponds to the criteria used in the "OPTION solve gauss conv ..." options.

OPTION solve forward fair conv1 abs = 0.001;

OPTION solve forward fair conv1 rel = 0.001;

Relative criterion for the (default) 'conv1'-type convergence check, and absolute criterion for the (default) 'conv1'-type convergence check. Note that the criteria are less strict than the corresponding Gauss criteria. This is probably necessary regarding Fair-Taylor convergence.

OPTION solve forward fair conv2 tabs = 1.0;

OPTION solve forward fair conv2 trel = 0.001;

Relative criterion for the PCIM-like 'conv2'-type convergence check, and absolute criterion for the PCIM-like 'conv2'-type convergence check. Note that the criteria are less strict than the corresponding Gauss criteria. This is probably necessary regarding Fair-Taylor convergence.

OPTION solve forward fair damp = 0.5;

Damping used regarding leaded endogenous variables in the Fair-Taylor algorithm.The smaller the factor is, the harder the damping. Setting the factor to 1.0 means no damping at all, whereas setting it to 0.0 means the equations cannot progress.

OPTION solve forward fair itermax = 200;

OPTION solve forward fair itermin = 0;

The maximum and minimum number of iterations done in the Fair-Taylor algorithm.

OPTION solve forward method = fair; [fair|none]

The method used regarding leaded endogenous variables. If set to 'fair', the Fair-Taylor algorithm is used. If set to 'none', no forward-looking method is used. In that case, the leaded endogenous variables are just taken exogenously as their databank values.

OPTION solve forward terminal = const; [const|growth|none]

This sets terminal conditions regarding leaded endogenous variables. If the simulation period ends in 2100, y(+1) in that period will be set to the value y is solved for in 2100 (and not the databank value for y in 2101). With 'growth', y(+1) in 2100 will use the growth rate instead of the level for the solved y in 2100. If the option is set to 'none', y(+1) in 2100 will be taken as the databank value of y in 2101 (this is often not a good choice).

OPTION solve gauss conv = conv1;

Set Gauss convergence type to 'conv1' (default) or 'conv2'. Read more about convergence criteria in the help file related to the command ITERSHOW.

OPTION solve gauss conv1 abs = 0.0001;

OPTION solve gauss conv1 rel = 0.0001;

Relative criterion for the (default) 'conv1'-type convergence check, and absolute criterion for the (default) 'conv1'-type convergence check.

OPTION solve gauss conv2 tabs = 1.0;

OPTION solve gauss conv2 trel = 0.0001;

Relative criterion for the PCIM-like 'conv2'-type convergence check, and absolute criterion for the PCIM-like 'conv2'-type convergence check.

OPTION solve gauss conv ignorevars = yes; [yes|no]

If active, variables indicated by means of the CHECKOFF command will be ignored regarding convergence check.

OPTION solve gauss damp = 0.5;

In the Gauss algorithm, this damps any equations with damping set with the given factor. The smaller the factor is, the harder the damping. Setting the factor to 1.0 means no damping at all, whereas setting it to 0.0 means the equations cannot progress. The damped equations have a “Z” in their formula codes.

OPTION solve gauss dump = no; [yes|no]

This option activates recording of Gauss iterations, for later inspection by means of the ITERSHOW command. Beware that the option may use a lot of RAM, and that it slows down simulations considerably.

OPTION solve gauss itermax = 200;

OPTION solve gauss itermin = 10;

The maximum and minimum number of iterations done in the Gauss algorithm.

OPTION solve gauss reorder = no; [yes|no]

When active, this option reorders equations in the simultaneous block of the model. This should normally reduce the number of required Gauss iterations for solving the model, but it may sometimes induce starting value problems (therefore the option is set to 'no' as default). The option should be issued before a MODEL statement to take effect.

OPTION solve method = gauss; [gauss|newton]

Choose between ‘gauss’ or ‘newton’

OPTION solve newton backtrack = yes; [yes|no]

If yes, the Newton algorithm tries to backtrack if an iteration step seems too large.

OPTION solve newton invert = lu; [lu|iter]

The algorithm used to invert the Jacobian matrix.

OPTION solve newton itermax = 200;

The maximum number of iterations done in the Newton algorithm, before exiting.

OPTION solve newton updatefreq = 15;

This options indicates how often the Newton algorithm should update the Jacobi matrix, when doing fast steps.

OPTION solve print details = no; [yes|no]

If yes, the Newton algorithm will produce quite a lot of extra information regarding the iterations.

OPTION solve print iter = no; [yes|no]

If yes, the individual periods are printed out while simulating. Set to 'no' as default.

OPTION solve static = no; [yes|no]

If yes, all lagged endogenous values are taken as their databank values (i.e. not their simulated values).

OPTION solve undo = no; [yes|no]

This option is obsolete, since Gekko always stores undo information that can be activated if the simulation fails. Just keep the option as 'no' for the time being.

OPTION table html datawidth = 5.5;

For html tables, this is the minimum width of data columns, in so-called 'em' units (in CSS: "width: 5.5em"). The 'em' units are independent of font size.

OPTION table html firstcolwidth = 5.5;

For html tables, this is the minimum width of the first column, in so-called 'em' units (in CSS: "width: 5.5em"). The 'em' units are independent of font size.

OPTION table html font = Arial;

OPTION table html fontsize = 72;

You may choose the font and fontsize for html tables. The fontsize is in percent, so 72 corresponds to 72% (in CSS: "font-size: 72%").

OPTION table html secondcolwidth = 5.5;

For html tables, this is the minimum width of the second column (sometimes containing variable names), in so-called 'em' units (in CSS: "width: 5.5em"). The 'em' units are independent of font size.

OPTION table html specialminus = no; [yes|no]

If yes, a non-breaking hyphen is insert instead of the normal minus character. This may avoid some breaking of numbers, but that hyphen is not good for copy-pasting to Excel via right-clicking the table.

OPTION table ignoremissingvars = yes; [yes|no]

If 'yes', missing variables will be shown as 'N' (for non-existing) in tables. (Missing values for existing variables are always shown as 'M').

OPTION table type = html; [txt|html]

If set to 'txt', tables will be shown in text format in the Main tab. If set to 'html', .html format will be used (shown in the Menu tab). There are some options to control the html layout: see 'OPTION table html ...'.

OPTION timefilter = no; [yes|no]

Switches the timerfilter on or off (provided a timerfilter has been defined). See TIMEFILTER.

OPTION timefilter type = hide; [hide|avg]

If set to 'hide', applying a timefilter will just hide the out-filtered periods (i.e., they are not shown). If 'avg' is used instead, the non-shown periods will be aggregated into the shown periods (as averages). See TIMEFILTER.

Note

As stated above, you may omit the '=' in option commands, but it may be a good idea to keep it in programs for readability.

Setting 'OPTION interface suggestions = option' will help the user navigate the option tree.


PAUSE

Introduction

PAUSE is for breaking the command flow, and the command will wait for the user to press [Enter];

Syntax

PAUSE 'text';

'text'

(Optional). Text string to be displayed when a command flow is paused (please remember single quotes).

Example

The command may contain text inside single quotes:

PAUSE 'This is the first part of the scenario';

Related

commands

RETURN, STOP, EXIT


PIPE

Introduction

Redirects output to a file (or back to the screen). Directing to a .html file is supported.

Syntax

PIPE < HTML APPEND > filename ;

PIPE CON;

HTML | If this option is used, Gekko will insert the text into the <body> of a html file (if appending), or create a html file from scratch to write into. Note that Gekko appends text to the .html file without any prior formatting. So for instance to append a line to a .html file, you have to include the html tags (for instance: TELL '<p>Hello</p>').
APPEND | If this option is used, the output will be appended to a file
filename | The file that the output is written to
CON | Indicates that the output is again directed to the screen.

Any pre-existing file with the same name will be overwritten, unless option APPEND is used. If "PIPE CON" is used, the output is re-directed to the screen (CON as in 'console').

Example

You may want to keep a print of some variables in an output file:

READ adambank;

PIPE ex.out;

PRT fy ul;

PIPE con;

The file ex.out now contains the variable print. If you instead use "PIPE <append> ex.out", the ex.out file will be appended to.

PIPE <html> out.html;

TELL '<p>This is the first line</p>';

TELL '<p>This is the second line</p>';

PIPE con;

Note

When piping, any error messages are also piped to the file. You may consult the 'traffic lights' in the lower right corner of the Gekko window, in order to see if an error occurred and the program aborted (in that case, the light will be red - a running program is shown as yellow).

Related

options

OPTION folder pipe = [empty];


PPLOT

Introduction

In Gekko you can create plots of variables with the PPLOT command. PPLOT has similar syntax to PRT, and the same syntax as as WPLOT and CPLOT.

PPLOT can create an .emf, .png or .svg file silently, if the FILE= option is used.

Syntax

PPLOT <period printcode > period variables HEADING=heading FILE=filename ;

period | (Optional). For instance "2010 2020" or "2010q1 2020q4". If inside the <> field, the period is local to the current statement, if outside the period will be changed globally. If no period is given, global time will be used.
printcode | (Optional). 'Short' printcode: N, D, P, DP, M, Q, MP, B, BD, BP, BDP, A, AD, AP
variables | Name of the variable(s) printed. Several variables can be printed at once using, var1 var2 .... You may also use lists or expressions.
HEADING= | (Optional). Heading in single quotes.
FILE= | (Optional). The resulting file (.emf format, enhanced metafile). Such a file can be imported into many Windows programs such as Word and others. You may use a filename with explicit extension .png or .svg instead, and PPLOT will produce the file in that format.

You may use a 'printcode' to indicate which kind of data transformation you would like on your variables (the '@' indicates values from the Base databank):

'Short' printcodes for PPLOT

d | Absolute time difference: x-x(-1)
p | Growth rate: (x/x(-1) -1)*100
m | Absolute multiplier: x-@x
q | Relative multiplier: (x/@x-1)*100
mp | Growth rate multiplier: (x/x(-1) -1)*100 - (@x/@x(-1) -1)*100
bd | Absolute time difference in Base: @x-@x(-1)
bp | Growth rate in Base: (@x/@x(-1)-1)*100
a | Shows values in both Work and Base databanks ('a' for 'all'). Note: only works for PPLOT.
ad | As above, showing absolute time differences. Note: only works for PPLOT.
ap | As above, showing growth rates. Note: only works for PPLOT.

These codes are the same as the ones used in the PRT, WPLOT and CPLOT commands. So-called 'long' printcodes like abs, pch etc. cannot be used.

Example

The command

PPLOT <p> x1 x2;

Plots percentage growth of the timeseries x1 and x2 from the Work databank in a graph window. You may use

PPLOT <a> x1;

to obtain a simultaneous plot of the x1 values in both Work and Base databanks (use <ad> for differences, and <ap> for growth rates). This plot is similar to PPLOT x1 @x1.

FOR i = fY fX fE;

 PPLOT #i file=graph_#i;

END;

This creates three graphs that are put in three different .emf files.

Note

PPLOT produces a graph by means of the open-source program gnuplot as an underlying engine. You do not need to install anything in order to use PPLOT (the Gekko installation files contain gnuplot).

In the graph window, you may change the so-called print-codes by clicking on the radio buttons (or multiplier checkbox). This way, you can quickly change to for instance percentage growth rate etc. You may copy-paste the graph to e.g. a word-processor like Word by clicking the ‘Copy’ button. There are also options to save the graph as a .emf file.

You may close the PPLOT graph window by pressing the 'Esc' button.

You may update the PPLOT window with new data via the 'Update graph' button. This is convenient for instance after a new simulation, after reading a new databank, or after reordering databanks (see the F2 window). You may update all PPLOT windows at all (see menu 'Window' --> 'Update').

The <a>, <ad>, and <ap> options will be available for PRT, WPLOT, CPLOT, etc. at a later point.

Related

options

OPTION graph lines points = yes; [yes|no].

Related

commands

WPLOT, PRT


PRT

Examples

Introduction

The PRT command prints variables, lists or expressions. The output can be transformed and formatted in different ways: transformations are done with so-called printcodes (for instance 'pch' for percent change). Formatting includes transposing the result ('rows' option), setting width, decimals etc. The MULPRT command is very similar to PRT, but prints out multiplier differences (i.e., compares data in the Work and Base databanks). You may use the more detailed DISP command, if you need more specific information regarding a variable (data period, label, etc. -- DISP also allows for equation browsing, if a model is loaded).

Anything legal as right-hand side in a GENR statement (or in a FRML statement in a model) may be used as an expression in the PRT command, including lags (e.g., gdp(-1)), functions like dlog() or pch() etc. In addition, PRT statements may also contain scalar variables of VAL type, or references to fixed periods in parentheses (e.g., 'gdp(2010)').

If you have opened extra databanks by means of the OPEN command, you can use a colon (':') to indicate that data is to be taken from that particular databank (bank:variable). An '@' before a variable indicates the Base databank (Hence, '@x' and 'base:x' are equivalent).

Syntax

PRT < period printcodes decimals width ROWS FILTER=filter > period elements HEADING='text' FILE=filename ;

where:
period | per1 per2
printcodes | printcode printcode ...
printcode | 'Long': ABS, DIF, PCH, GDIF, or 'short': N, D, P, DP, M, Q, MP, B, BD, BP, BDP
decimals | DEC=number | NDEC=number | PDEC=number
width | WIDTH=number | NWIDTH=number | PWIDTH=number
elements | element element ...
element | variable 'label' < printcodes decimals width >
details:
period | (Optional). For instance "2010 2020" or "2010q1 2020q4". If inside the <> field, the period is local to the current statement, if outside the period will be changed globally. If no period is given, global time will be used.
printcodes | (See tables in examples section). Long printcodes: abs, dif, pch or gdif. These can be switched off by means of prefix no (for instance nopch), or added to existing default printcodes by means of underscore (for instance _dif). Default printcodes are abs and pch (absolute level and percentage growth is printed). Short printcodes: d, p and dp for time-transformations, and m, q and mp for multiplier-transformations. Prefix the time-transformations with b for baseline values. See "OPTION print prt ...".
element | The variable can be a variable name, a list (for instance #mylist), or an expression (for instance gdp/pgdp). Labels are put in single quotes (will be ignored for lists). Printcodes here will override other printcodes (globals ones, or those set on the PRT statement), so element-printcodes are local to the particular element.
DEC= | Sets number of decimals, will apply to all kinds of numbers.
NDEC= | Sets number of decimals for non-percentage numbers. See also "OPTION print fields ndec...".
PDEC= | Sets number of decimals for percentage numbers. See also "OPTION print fields pdec...".
WIDTH= | Sets width, will apply to all kinds of numbers.
NWIDTH= | Sets width for non-percentage numbers. See also "OPTION print fields nwidth...".
PWIDTH= | Sets width for percentage numbers. See also "OPTION print fields pwidth...".
ROWS | If set, the result will be transposed, i.e., with variables running downwards. Corresponds to TRANSPOSE=yes for WPLOT and CPLOT.
FILTER= | A timefilter can be activated or deactivated (see TIMEFILTER command). With <FILTER> or <FILTER=yes>, the current timefilter is used. With <NOFILTER> or <FILTER=no>, any filtering is deactivated. The filter type can also be changed locally, for instance <FILTER=hide> hides the out-filtered periods, whereas <FILTER=avg> averages the out-filtered periods. See "OPTION timefilter...".
HEADING= | A heading in quotes.
FILE= | A filename that the print is put into.

Note: You must specify at least one element.

Printcodes

There are two kinds of print-codes available. The easiest to remember are the 'long' ones: namely abs, dif, pch and gdif:

'Long' printcodes for PRT

abs | Absolute level: x
dif | Absolute time change: x-x(-1)
pch | Growth rate: (x/x(-1) -1)*100
gdif | Change in growth rate: (x/x(-1) -1)*100 - (x(-1)/x(-2) -1)*100

As default, PRT always prints out corresponding to "PRT<abs pch>", i.e., printing out the absolute level and the growth rate. These default options can be altered in "OPTION print prt ..." (see 'Related options' below). For instance, to only print the level of a variable, use PRT<abs>, to only print the growth rate, use PRT<pch>, and to print absolute time change, use PRT<dif>. You can alternatively switch off options with prefix no, for instance PRT<nopch> (same as PRT<abs>) etc. In addition, you can use the 'glue' prefix '_' to add options to existing options. For instance, PRT<_dif> corresponds to PRT<abs dif pch>, because dif is added to the default printcodes (abs and pch). You may put the codes after individual elements, for instance "PRT var1<pch> var2<dif>", to have var1 displayed as pch and var2 displayed as dif. Codes put on an element override more general codes put directly after PRT, so "PRT<pch> var1 var2<dif>" yields the same result.

As a supplement to these 'long' print-codes, there are some more advanced (and shorter) print-codes of type d, p, m, q etc. These are perhaps less mnemotechnic, but more concise (the '@' below indicates values taken from the Base databank):

'Short' printcodes for PRT

n | Absolute level: x. No use of print-code is equivalent.
d | Absolute time change: x-x(-1)
p | Growth rate: (x/x(-1) -1)*100
dp | Change in growth rate: (x/x(-1) -1)*100 - (x(-1)/x(-2) -1)*100
m | Absolute multiplier: x-@x
q | Relative multiplier: (x/@x-1)*100
mp | Multiplier in growth rate: (x/x(-1) -1)*100 - (@x/@x(-1) -1)*100
b | Absolute level in Base: @x. Code 'bn' is equivalent.
bd | Absolute time change i Base: x-x(-1)
bp | Growth rate in Base: (@x/@x(-1) -1)*100
bdp | Change in growth rate in Base: (@x/@x(-1) -1)*100 - (@x(-1)/@x(-2) -1)*100

There is the following logic to the above codes. The important codes to remember are d for absolute time change, p for percent time change, m for absolute multiplier, and q for relative multiplier. Then the combination dp is easily read as time change in growth rate, and mp as multiplier difference in growth rate. This covers the first and second sections of the above table. The third section is just the first section with prefix b (for Base databank), and shows that same transformations as in the first section, just for the Base databank values instead of the Work databank values. Of course, you can always write "PRT<p>@gdp" instead of "PRT<bp>gdp", but for longer expressions and lists, the prefix b comes in handy.

Formatting,

filters etc.

In addition to the above transformations, the print can be formatted regarding the width of each data column, and the number of decimals. Width and decimals can be set in the PRT option field, or in element option fields. In the PRT option field, you may indicate the width and number of decimals like this: "PRT<width=10 dec=3>", or you may set absolute and percentage fields individually: PRT<nwidth=10 ndec=0 pwidth=6 pdec=1>". This will yield absolute fields 10 characters wide with no decimals, and percentage fields 6 characters wide with 1 decimal. The width and decimals formatting can also be applied individually on each element, for instance "PRT gdp<n dec=0> pgdp<p dec=1>", printing 'gdp' in levels with no decimals, and 'pgdp' as growth rate with 1 decimal.

The output can be transposed by means of the 'rows' keyword, for instance "PRT<rows>gdp pgdp". This is handy for printing a long list of timeseries, or for copy-pasting the cells to a spreadsheet by means of the copy-button in the Gekko interface.

Finally, you can use a timefilter (see TIMEFILTER) in the PRT option field. This is convenient for suppressing individual observations when printing long time periods. First, you need to select the filtered periods, and then you can use for instance PRT<filter> or PRT<nofilter>. More advanced use is "PRT<filter=avg>" in which case the out-filtered periods are aggregated into the shown periods (rather than simply skipped). See examples below.

Examples

You may wish to examine the evolution of the house prices (phk) and the real house price phk/pcp for the period 2010-2015:

READ lang11;  //some databank is read

PRT <2010 2012> phk phk/pcp;

This gives the following result, with both absolute levels and percentage growth:

                phk         %        phk/pcp         %

 2010         1.5872      2.44         1.3262     -0.09

 2011         1.6180      1.94         1.3255     -0.05

 2012         1.6497      1.95         1.3276      0.16

If a model is loaded, and phk is a model variable, the first '%' would become '(E)%', because (E) or (X) are used to indicate endogenous or exogenous variables. Using print code pch inside the option brackets would provide you with the growth rates alone (the short printcode p has the same effect):

PRT <pch> phk phk/pcp;

The print can alternatively be transposed with the <rows> option like this:

PRT <2010 2012 pch rows> phk phk/pcp;

gives:

[%]          2010      2011      2012

phk          2.44      1.94      1.95

phk/pcp     -0.09     -0.05      0.16

You may mix variables, lists, expressions and print-codes as you wish (just separate the elements with at least one blank):

LIST mylist =  fXnz fXnf;

PRT <dif>  fX  fXnf(-1)*fXnz/fXnz(-1) fX/fX(2005) #mylist;

This prints out absolute time-differences in these variables/lists/expressions:

                            fXnf(-1)*

 [dif]             fX  fXnz/fXnz(-1)    fX/fX(2005)           fXnz           fXnf

 2010      38965.7500     13938.9973         0.0161     15563.5000     -1786.7031

 2011      53169.7500     -2840.6205         0.0219     12894.9375     -2218.8516

 2012      46760.2500     -8318.5268         0.0193     -8378.4375       683.4219

Multiple printcodes can be used in one option field, as this example shows:

PRT <n p b bp m q> fy;

This corresponds to a hand-made version of the MULPRT<v> statement, printing levels/growth in Work and Base in addition to the multiplier differences (absolute and relative). As you see, this PRT statement contains multiplier differences (codes m and q), so by means of using short printcodes you are free to mix multiplier values into the print.

Formatting can be applied in the following way:

PRT <nwidth=10 ndec=0 pwidth=6 pdec=1> fy;

This prints out the absolute levels and percentage growth rates (this way of printing is default, see "OPTION print prt..."), with width 10 and no decimals for the levels, and width 6 and 1 decimal for the growth rates. You may use formatting on each element, for instance:

PRT fy fx fm<ndec=0 pdec=1>;

In that case, only the last variable ('fm') has a different number of decimals. Fixed years can be indicated in brackets (for instance '(2005)' means that 2005-values are taken). Different databanks may be indicated:

PRT fy @fy old:fy;

This prints out the variable 'fy' from the Work databank, 'fy' from the Base databank (@-indicator), and 'fy' from a databank with the name 'old'. The latter is opened by means of the OPEN command (note that you can use F2 to see the list of open databanks).

Wild-card lists (inside brackets []) may be used instead of regular lists:

PRT [fX*]

This will print out all variables starting with 'fX' in the Work databank (use '?' as a single-character wild-card). You must use brackets to indicate wild-cards (in order to distinguish between e.g. the wildcard "[fY*2]" and the mathematical expression "fY*2").

You may insert labels or a heading into the PRT statement, the former only for non-list items.

PRT fy 'GDP'  ul 'Unemployment' heading = 'Scenario A';

To filter out periods, first define a TIMEFILTER. For instance:

TIMEFILTER 2003, 2005:2008, 2010:2015 by 2;

This way, the periods 2004, 2009, 2011 and 2013 will be hidden, whereas all other periods are shown. Note that TIMEFILTER defines the periods positively, i.e. the periods that are to be included when printing. If you print now, these four periods will just be skipped. To temporarily disable the filter in the print, use "PRT<nofilter>". To have the skipped periods aggregated into the shown periods, use "PRT<filter=avg>". For instance:

PRT<2003 2015 filter=avg>fY;

gives the following:

                       fY       [%]

 2003        1314180.0000      0.38

 2004-2005   1360794.5000      2.37

 2006        1423985.0000      3.39

 2007        1446530.0000      1.58

 2008        1430309.0000     -1.12

 2009-2010   1367633.0000     -1.79

 2011-2012   1447238.5625      2.99

 2013-2014   1501831.8125      1.67

 2015        1534174.6250      1.45

For e.g. 2004-2005, the average for these two periods is shown. For the absolute level (the 'fY' column), a simple average is used, whereas for the percentage column ('[%]'), a more complicated averaging of growth rates is performed, in order to yield a consistent average growth rate for these two periods.

Looping over lists in combination with PRT is pretty straightforward. You may write:

FOR i=yf x;

 FOR j=nf nz;

   PRT f{i}{j};

 END;

END;

This will print the variables fyfnf, fyfnz, fxnf, fxnz. If you are using Gekko interactively, you can obtain non-executing linebreaks by means of Ctrl+Enter, and you execute the block of commands by means of marking the block before pressing [Enter]. Alternatively, and better, RUN the commands from a command file. Note that you may use "PRT f#i#j" instead of "PRT f{i}{j}", but for indices such as these, using {} is more readable.

Note

If a model is loaded (see MODEL), the PRT command indicates '(E)' for endogenous, and '(X)' for exogenous variables. Missing values are shown with a 'M' instead of numbers. If some variable is missing in the databank (or the databank does not exist), an error message will be issued.

Note that "PRT <m> mybank:x" prints out the difference mybank:x - Base:x (and "PRT <b> mybank:x" prints out Base:x). So when printing a multiplier involving a named (OPEN) databank, Gekko will look for the same variable in the Baseline databank, in order to compute the multiplier.

You may use scalar variables of STRING type to compose the variable names, or scalar variables of VAL type (the particular value will be used for each period).

You may change what is printed as default via the "OPTION print prt ..." options (see 'Related options' below). For instance you may want to switch off printing of percentage growth permanently: "OPTION print prt pch = no".

You may use P, PRI or PRINT instead of PRT. You may use 'diff' instead of the 'dif' printcode.

TIMEFILTER and PRT<filter=avg> should be used instead of the older (obsolete) TIMESPAN and VPRT commands.

Related

options

Relevant options regarding the PRT statement:

OPTION freq a; [a|q|m]

OPTION print filewidth = 130;

OPTION print width = 100;

OPTION print fields ndec = 4;

OPTION print fields nwidth = 13;

OPTION print fields pdec = 2;

OPTION print fields pwidth = 8;

OPTION print prt abs = yes;

OPTION print prt dif = no;

OPTION print prt pch = yes;

OPTION print prt gdif = no;

OPTION timefilter type = hide;

OPTION timefilter = no;

Related

commands

MULPRT, PPLOT, WPLOT, CPLOT, DISP, INFO, UDVALG


READ

Introduction

The command READ reads timeseries from a .tsdx file (or other formats) into the Work databank. A .tsdx file is a Gekko-specific binary databank format.

READ reads data into the work databank. Before reading, the Work databank is cleared, so after reading, the Work databank will correspond to the file (this behavior may be altered by means of the <merge> option). After reading (optionally merging) data from the file into the Work databank, the Base databank is always made as an exact copy of the Work databank.

It should be noted that if a model has been loaded, the READ command will auto-create any model variables not present in the .tsdx file (and fill these variables with missing values). Because of this, in command files it may often be convenient to put the MODEL statement before the READ statement.

Syntax

READ < filetype COLS MERGE > filename ;

READ < filetype COLS MERGE > * ;

filetype | (Optional). Can be 'tsd', 'tsdx', 'pcim', 'csv', 'xls', 'xlsx'. The default file format is 'tsdx'.
filename | The filename of the databank to be read into the Work databank. The filename may include a local or global path.
COLS | (Optional). For .csv or Excel files, this indicates whether the timeseries are running downwards in columns.
MERGE | (Optional). If MERGE is set, the data is merged into the existing Work databank.
* | If the filename is set to '*', you will be asked to choose the file in Windows Explorer

Example

Reading a .tsdx file called adam.tsdx is done with

READ adam;

or by writing

READ *;

and then selecting the databank.

READ <merge> adam;

merges adam.tsdx with any pre-existing data in the Work databank.

READ otherbanks\adam3;

This will look for adam3.tsdx in the subfolder 'otherbanks', relative the the Gekko working folder.

Reading from csv or Excel is only implemented for 'well-formed' spreadsheets. That is, with data starting in the first column and first row, and with either timeseries running outwards (normal for .csv files) or downwards (less normal). For Excel workbooks, only the first sheet is read. You may use READ<csv cols> or READ<xls cols>, if the timeseries are running downwards.

Note

You may change the file type to .tsd (used by e.g. AREMOS), by means of

OPTION databank file format = tsd;

Or simply use

READ <tsd> adam;

in order to read adam.tsd.

To convert a .tsd file into a .tsdx file, just read it with "READ<tsd>", and WRITE it (provided that the default file format is set to 'tsdx'). Please note that a .tsd file operates with 8 significant digits (or less), so there will typically be a loss of precision compared to a .tsdx file (which is in double-precision).

When reading, extension .tsdx is automatically added if it is missing. Global time settings do not affect the READ command, so all the data in the .tsdx file is read into the Work databank regardless of how the timeperiod is set in Gekko. (If useful, a period-truncated databank can be written with the WRITE statement).

The .tsdx records are read on an individual basis, so different records (i.e. timeseries) can have any length and period (and frequency). Annual, quarterly and monthly data may co-exist in the same .tsdx file, and the same timeseries name may be used for different frequencies.

Gekko databanks consist of objects (timeseries), having individual time and frequency settings. The only limit on the number of timeseries, and the number of observations inside the timeseries is available RAM. Timeseries names may have any length. Please use alphanumeric characters or '_' for timeseries names, and please do not begin the name with a number (for instance ‘2010dummy’ or the like).

The tsdx format comes in the following versions:

tsdx versions

1.0 | A .tsdx file version 1.0 is two zipped files: 'databank.tsd' with the data, and 'DatabankInfo.xml' with meta-information. Unlike standard AREMOS .tsd files, the .tsd file inside the .tsdx file version 1.0 has 15 significant digits. So there is no loss of precision in the 1.0 format. Gekko still reads the 1.0 format, but will write .tsdx files in the newer binary format (version 1.1).
1.1 | A .tsdx file in version 1.1 is two zipped files: 'databank.bin' with the data, and 'DatabankInfo.xml' with meta-information. Version 1.1. uses a binary format that loads about 3 times faster than older 1.0 format. Older Gekko versions prior to Gekko 1.5.8 cannot read a .tsdx databank version 1.1 (unless "OPTION databank file tsdx version = 1.0" is set before writing from the newer Gekko version). The file databank.bin is a so-called protobuf-file (see https://developers.google.com/protocol-buffers), that is, in a sense a binary and much faster version of XML. So the design of databank.bin is not Gekko-specific or home-cooked, and could be read by other software if needed (there are many tools available for reading and writing protobuffers).

The option 'copylocal' below copies the targeted file to a temporary file on the user's local harddisk before reading. This copying is typically very fast, and afterwards reading the temporary file is faster and more reliable, if the targeted file is located on a network drive. In general, this is a recommended option that alleviates some potential network problems.

Related

options

OPTION databank file copylocal = yes;

OPTION databank file format = tsdx; [tsd|tsdx]

OPTION databank file tsdx version = 1.1; [1.0|1.1]

OPTION folder bank = [empty];

OPTION folder bank1 = [empty];

OPTION folder bank2 = [empty];

OPTION solve data createvars = yes; [yes|no]

Related

commands

WRITE, MULBK, OPEN, CONVERTPRN


RES

Introduction

The RES command (residual check) performs a one-step-ahead static single-equation simulation of the entire model, i.e. the result of one equation does not affect other equations, nor does results of previous periods affect following periods.

The difference between actual historical figures and a static single equation solutions are the equation residuals. Residuals is used to measure how well the model equations forecasts historically.

The RES command is widely used for testing historical data against the model, or for testing a model against a historical databank.

Gekko offers functionality to print results to files for subsequent inspection. See the menu item 'Utilities' --> 'Check residuals…' (output is grouped according to formula codes and/or model sections, and can be ordered).

Syntax

RES < period > period ;

period

(Optional). For instance "2010 2020" or "2010q1 2020q4". If inside the <> field, the period is local to the current statement, if outside the period will be changed globally. If no period is given, global time will be used.

Example

Print the solution, actual figures and residuals of all endogenous variables in the databank hit1211 in 2008-2010:

MODEL dec09;

READ hit1211;

RES 2008 2010;

MULPRT #endo;

A one step ahead solution of all the equations in the model can be done by:

MODEL dec09;

READ hit1211;

TIME 2008 2010;

SIM <2010 2010>;

SIM <2009 2009>;

SIM <2008 2008>;

MULPRT #endo;

or easier using the 'solve static' option:

MODEL dec09;

READ hit1211;

TIME 2008 2010;

OPTION solve static = yes;

SIM;

MULPRT #endo;

In the above simulations, effects spread from one equation to another (but not from one period to the next).

Note

After a RES, you may use 'Utilities' --> 'Check residuals…' from the Gekko menu.

Related

commands

SIM, EFTER


RETURN

 | RETURN
Introduction | RETURN returns from a command file (i.e., does not execute the remainder of the file). It will return to any 'mother' command file calling that particular 'child' command file (or to the command prompt if there are no 'mother' command files). If you wish to return from all command files at once, use the STOP command instead.
Syntax | RETURN ;
Note | If you wish to comment out a section of the command file, you may use '()' or '//' to comment out a single line, or '/*' followed by '*/' to comment out an arbitrary section (for instance spanning multiple lines).
Related commands | STOP, EXIT


RUN

Introduction

The RUN command runs a script file with Gekko commands (also called a command file).

Syntax

RUN filename ;

filename

A path must be specified if the file is not located in the working folder. If the filename is given without extension, '.cmd' is added as extension.

Example

You may run the command file scenario.cmd like this:

RUN scenario;

Or, if located in the sub-folder 'scenarios':

RUN scenarios\scenario1;

This will run scenario1.cmd in the subfolder 'scenarios' (relative to the working folder).

The extension .cmd is added automatically if not provided. Other extensions may be used, just indicate:

RUN gekko.ini;

will run the gekko.ini file.

gekko.exe

parameters

This is for more advanced users, but you may start up gekko.exe with parameters. Gekko accepts commands as arguments, so for instance Gekko can be started up like this (execute this from the system shell where gekko.exe is located, or from the .bat file starting up Gekko):

gekko.exe -folder:c:\adam\2010 -noini RUN scenario;

With the first parameter '-folder:' you can indicate the starting folder when starting up gekko.exe this way. Please avoid blanks after the '-folder:', and if the path contains a blank, enclose the path in quotes ("c:\my folder\adam"). With the '-noini' parameter you can indicate that you do not wish any gekko.ini (or isstart.cmd) files run when starting up Gekko. After this, you may write Gekko statements separated by semicolons (';'). So above, we are starting up Gekko in the 'C:\adam\2010' folder, without running a possible ini file, and executing the statement "RUN scenario" (that is, running the file scenario.cmd in the working folder). You may stop Gekko after running scenario.cmd by issuing an EXIT statement, for instance:

gekko.exe -folder:c:\adam\2010 -noini RUN scenario; EXIT;

Or alternatively end scenario.cmd with an EXIT statement. This way, the session can run completely without user intervention.

Note

In older Gekko versions, command files could be started up in an alternative ways. The 'RUN' statement could be omitted, so the line "scenario" would be equivalent to "RUN scenario". This way of calling command files is discouraged, because it makes reading the command files more difficult (is 'scenario' an in-built Gekko command or a command file?). An addition, older Gekko versions had an ADD statement that would run command files in much the same way as RUN ("ADD scenario" would look for the command file scenario.add, however).

Related

options

OPTION folder cmd = [empty];

OPTION folder cmd1 = [empty];

OPTION folder cmd2 = [empty];

OPTION folder working = [empty];

OPTION interface debug = dialog; [dialog|none]

OPTION interface sound = no; [yes|no]

OPTION interface sound type = bowl; [bowl|ding|notify|ring]

OPTION interface sound wait = 60;

Related

commands

RETURN, STOP


SIGN

Introduction

This command prints out information regarding the model signature in the model file (.frm), and the 'true' hash code corresponding to the model file (and whether they are identical). You can use the SIGN command to obtain the hash code for signing a new (or changed) model. (If the model is unsigned, click the link 'more' to obtain a comment line with signature that can be copy-pasted into the .frm file.)

The hashcode is a kind of check-sum or fingerprint regarding .frm files. The signatures are technically so-called MD5 hashes, and can be put into .frm file as commentaries (for example: "// Signature: fp88RzyZfJNaoTi3I4X3Ww"). This string of 22 characters and digits (note: the hash code is case-sensitive!) identifies a specific model file, so altering the model file will result in a different hash code. The motivation behind the signatures is two-fold: (a) To be able to make sure that an official model version (e.g., a specific ADAM .frm file) has not accidently been changed, and (b) The signatures are used to identify models for caching (faster loading). When calculating the signature (hash code), empty lines and comment lines are ignored (except for comments containing model block identifiers '###'), so you may insert empty lines or comments any way you like in the .frm file and preserve the signature (any variable list after the VARLIST$ tag will be ignored in the hashcode, too). But changing the equations (FRML) in any way will result in a new hash code. The hash code is technically 128 bits, and this means that the probability of two different model files having the same hash code is 2^(-128) = 2.9E-39 (that is, effectively zero).

Syntax

SIGN ;

Example

To obtain a signature for a (unsigned) model loaded with the MODEL command, type:

SIGN;

You will get an output similar to this:

No signature was found in model file (more)

- Signature in model file      : [not found]

- True model file hash code    : fp88RzyZfJNaoTi3I4X3Ww

Try clicking the 'more' link to obtain a line similar to this:

// Signature: fp88RzyZfJNaoTi3I4X3Ww

This line can be copy-pasted into the .frm file (typically at the top), and the model is signed. After this, you will be told that the model signature is OK when loading the (unaltered) model with the MODEL command.

Note

You may put other meta-information into the model file (.frm). As of now, Info, Date, and Signature fields are supported. For instance:

// Info: Model used for forecasting 2012-2030

// Date: 7-11-2012 15:37:00

// Signature: fp88RzyZfJNaoTi3I4X3Ww

Gekko will complain if this format deviates, for instance the Info field is to be written with capital 'I', with no blank before the colon, and one blank after the colon. This rigorousness regarding form is to make it easy to spot the information in different .frm files. The Info and Date fields will be displayed when loading the model (MODEL command).

Related

commands

MODEL


SIM

Introduction

SIM solves the model dynamically, i.e. lagged endogenous variables use simulated values. The simulated values are placed in the Work bank, thereby overwriting previous values of the endogenous variables. The default solving method is Gauss-Seidel.

You may solve goals/means by indicating these with the ENDO/EXO commands. The Newton method is used in that case. When goals are removed later on (UNFIX command), the solve method reverts to Gauss-Seidel.

SIM may also solve a model with leaded endogenous variables. The Fair-Taylor method is used in that case.

Syntax

SIM < period > period ;

period

(Optional). For instance "2010 2020" or "2010q1 2020q4". If inside the <> field, the period is local to the current statement, if outside the period will be changed globally. If no period is given, global time will be used.

Example

To increase all exogenious prices by 1% in 2011-2020, and see the effects on private consumption (pcp) and wages (lna):

READ <pcim> lang11;

LIST + #pm pm01 pm2 pm3r pm59 pm7b pm7y pms pmt;

LIST + #pe pee2 pee59 peet peesq;

TIME 2011 2020;

UPD <2011 2020> #pm * 1.01;

UPD <2011 2020> #pe * 1.01;

SIM;

MULPRT pcp lna;

The result shows the difference between the values running (Work bank) and values in the baseline bank (lang11) for the variables pcp and lna.

If you need to solve goals/means, you can use the ENDO and EXO commands to change status of exogenous and endogenous variables, and perform a SIM afterwards. In that case, the solve method will be automatically changed to the Newton algorithm (and changed back if the goals/means are removed).

There are many options regarding SIM: please see under OPTION (in the "OPTION solve ..." section). Or type "OPTION solve ?".

Note

A single-equation static simulation can be performed with the RES command (for instance to check historical residuals).

If you want to change to the Newton algorithm manually, you can use 'OPTION solve method = newton'. It typically runs a bit slower, but is generally much more robust (and precise)

Static simulation (one period does not affect the next period) can be obtained by setting "OPTION static = yes".

Related

options

OPTION solve data ignoremissing = no; [yes|no]

OPTION solve data init = yes; [yes|no]

OPTION solve data init growth = yes; [yes|no]

OPTION solve data init growth min = -0.02;

OPTION solve data init growth max = 0.06;

OPTION solve failsafe = no; [yes|no]

OPTION solve forward fair conv = conv1; [conv1|conv2]

OPTION solve forward fair conv1 rel = 0.0001;

OPTION solve forward fair conv1 abs = 0.0001;

OPTION solve forward fair conv2 trel = 0.0001;

OPTION solve forward fair conv2 tabs = 1.0;

OPTION solve forward fair damp = 0.5;

OPTION solve forward method = fair; [fair|none]

OPTION solve forward terminal = const; [const|growth|none]

OPTION solve forward fair itermax = 200;

OPTION solve forward fair itermin = 10;

OPTION solve gauss conv = conv1;

OPTION solve gauss conv1 rel = 0.0001;

OPTION solve gauss conv1 abs = 0.0001;

OPTION solve gauss conv2 trel = 0.0001;

OPTION solve gauss conv2 tabs = 1.0;

OPTION solve gauss conv ignorevars = yes; [yes|no]

OPTION solve gauss damp = 0.5;

OPTION solve gauss dump = no; [yes|no]

OPTION solve gauss itermax = 200;

OPTION solve gauss itermin = 10;

OPTION solve gauss reorder = yes; [yes|no]

OPTION solve method = gauss; [gauss|newton]

OPTION solve newton backtrack = yes; [yes|no]

OPTION solve newton invert = lu; [lu|iter]

OPTION solve newton itermax = 200;

OPTION solve newton updatefreq = 15;

OPTION solve print details = no; [yes|no]

OPTION solve print iter = no; [yes|no]

OPTION solve static = no; [yes|no]

Related

commands

MODEL, RES, EFTER, EXO, ENDO


STAMP

 | STAMP
Introduction | The command prints out current date and time.
Syntax | STAMP ;


STOP

 | STOP
Introduction | The command returns from all command files immediately, returning to the command prompt. This command can be used for debugging, if the user wishes to run a system of command files up to a specific point, and examine the results up to that specific point.
Syntax | STOP ;
Example | The similar RETURN command does not return from all command files. The EXIT command effectively issues a 'STOP', and then afterwards closes the Gekko application.
Related commands | RETURN, EXIT


STRING

Introduction

The STRING command is used to assign strings (enclosed in single quotes) to a scalar variable of string type. A variable 's1' can later on be referenced to by means of '#s1' or '{s1}'.

Strings are scalar variables, and in this respect similar to dates and values (see DATE and VAL). Use MEM to show all scalar variables.

String manipulation capabilities are limited at present, but will be augmented later on.

Syntax

STRING name = 'text' ;

STRING name = expression ;

name | The name of the scalar variable
'text' | Text string enclosed in single quotes.
expression | You may use expressions involving

STRING name = 'text' ;

STRING name = expression ;

name | A scalar variable (do not prefix with '#')
'text' | Text string enclosed in single quotes.
expression | You may use expressions on the right-hand side. Gekko will try to convert to STRING if possible. Else try the STRING() function to convert an expression to a string.

A STRING variable 's1' can later on be referenced to by means of '#s1' or '{s1}'. When using the string to build a variable name, the latter variant is often preferable, e.g. fX{s1} = fXnz, if s1 = 'nz'. Alternatively, fX#i would be equivalent.

Example

For instance, you may wish to use strings to control file names.

STRING path = 'c:\folder011' ;

STRING bank = 'prognosis' ;

READ #path\#bank ;        () or: READ {path}\{bank};

Conversions between scalar variables are possible:

STRING s1 = 'Value in ';

DATE d1 = 2010;

STRING s2 = ' is: ';

VAL v1 = 123.45;

STRING s3 = #s1 + #d1 + #s2 + #v1;

TELL '#s3';

This will print "Value in 2010 is: 123.45".

Strings are often used in loops, to loop over variables, see FOR.

Related

commands

DATE, VAL


SYS

Introduction

The SYS command provides access to the system shell (in Windows sometimes called the DOS prompt). Gekko will wait until the SYS command finishes before it continues.

Syntax

SYS 'commands' ;

commands

Windows cmd-prompt commands (in single quotes)

Example

The SYS command can be used for file managing:

SYS 'copy file1.txt file2.txt';

or for more complex tasks or jobs

SYS 'Start /wait baremos this_and_that.cmd';

Note

Note the use of single quotes.

scalar variables will be in-substituted in a SYS-command.


TABLE

TABLE (XML-type)

Introduction

The TABLE command is used to call tables (.tab files) designed in a special XML format. This format is designed for ease of use regarding most types of tables with the time dimension running horizontally, and different variables running downwards. Table output can be either text or html. The latter is default since it often provides more readable output.

When a table (text or html) has been printed, you may use the 'Copy' button to copy the cells to the clipboard, for successive pasting into e.g. a spreadsheet like Excel. Copying the table this way includes the full precision of all numbers, but formatting will be lost.

For html tables, you may right-click the table and obtain some general possibilities like exporting to Excel (this may lose precision though), showing the source code of the html table, or printing the table.

Tables can also be called from menus (see MENU).

Note that you may use scalar-variables (for instance STRINGs) inside the xml elements.

Syntax

TABLE < period printcode HTML WINDOW=main > tablename ;

period | (Optional). Time period.
printcode | (Optional). Can be 'm' for multiplier or 'b' for 'Base' databank. The 'm' code works as if two tables were subtracted, one made with no code ('Work'), and one made with 'b' code ('Base'). No other codes are possible at the moment (printcode 'n' can also be used, but is the same as using no printcode).
HTML | (Optional). If 'html' is indicated, the table will be printed in HTML format, instead of in text format. It will be shown in the 'Menu' tab (unless the WINDOW=main option is active).
WINDOW= | (Optional). If "WINDOW=main" is indicated, output will be put into the main window, even if the table is of 'html' type. In that case, html codes will be printed on the screen. This can be used together with PIPE<html>, in order to insert a .html table into a .html file. You may use TELL to insert other .html lines into the .html file.
tablename | Name of the table to be printed (extension .tab can be omitted)

The Gekko table system can be used in two ways: either via a simple XML syntax to describe the appearance of the tables, or via a more matrix-like syntax where the tables' elements are assigned one by one (like filling in a matrix). For most tables with time running horizontally and variables vertically, the XML syntax is much easier to use.

Table printed: 30-04-2012 14:53:30
----------------------------------------------------------------------------------------
| Table 1. Supply balance, Million DKK, current prices |
--------------------+-------------------------------------------------------------------
| | 2005 2006 2007 2008 2009 2010 |
--------------------+-------------------------------------------------------------------
| GDP Y | 1554520 1605530 1676300 1734800 1796410 1849360 |
| Imports M | 674748 716544 748044 771898 802542 806695 |
| Total (Y+M) Yst | 2229270 2322080 2424340 2506700 2598950 2656050 |

--------------------+-------------------------------------------------------------------

In this table (shown in text format), there is a column with descriptions ('GDP' etc.), followed by a column with variable names ('Y' etc.). The table can easily be constructed by means of XML syntax. The XML tables use syntax that resemble the way tables are made in HTML syntax, specifically the use of the "colspan" attribute to merge cells horizontally. Data-columns (for instance the period 2005-10 above) are conceptually treated as a single (expandable) column, and formatting can be set on many levels.

To start out with a concrete example, the above table was constructed by means of the following code:

<?xml version="1.0" encoding="Windows-1252"?>
<gekkotable>
<tableversion>1.0</tableversion>

<table varformat="f9.0">
<cols>
<colborder/>
<col txtalign="left"></col>
<col txtalign="right"/>
<colborder/>
<col type="expand" txtalign="center"/>
<colborder/>
</cols>
<rows>
<rowborder/>
<row>
<txt colspan="3">Table 1. Supply balance, Million DKK, current prices</txt>
</row>
<rowborder/>
<row>
<txt/>
<txt/>
<date/>
</row>
<rowborder/>
<row>
<txt>GDP</txt>
<txt>$</txt>
<var>Y</var>
</row>
<row>
<txt>Imports</txt>
<txt>$</txt>
<var>M</var>
</row>
<row>
<txt>Samlet tilgang (Y+M)</txt>
<txt>$</txt>
<var>Yst</var>
</row>
<rowborder/>
</rows>
</table>

</gekkotable>

Inside the <table> tag (where the real defining of the table begins), the columns are first defined inside the <cols> tag. You may visualize the above table as the following 3-column table:

========== | ====== | ========

COL1 | COL2 | COL3

========== | ====== | ========

| |
-----------------------------------
| Heading spanning 3 columns.... |
-----------------------+-----------
| | Periods |
-----------------------+-----------
| Description1 var1 | Data |

| Description2 var2 | Data |

| Description2 var3 | Data |
-----------------------+-----------

In the XML defintion above, inside the <cols> tag, the columns are defined. First there is a <colborder>, corresponding to the left table border. Next there is a <col> tag, with default text alignment set to "left", followed by a simular tag with text alignment set to "right". These correspond to the "description" and "variable name" columns in the table. Next, there is a <colborder> to separate descriptions/variable names from the data, followed by a <col> of type "expand". This column is expandable, and expands into as many columns as there are time periods. The <cols> definitions end with a <colborder>, corresponding to the right table border.

Regarding the <rows>, these are given one by one by means of <row> tags. Each <row> expects 3 items, since there are 3 columns defined in the <cols> section. The first item in <rows> is a <rowborder>, however, so these are added analogously to the <colborders> under the <cols> tag. The first <rowborder> corresponds to the top table border, and the next item is a <row> with a <txt> item inside. The <txt> spans all 3 colums, so the vertical border between column 2 and 3 will be hidden in this row. Next, there is a <rowboarder>, and then the date row begins. This row is filled with two empty <txt> items (think of these ase placeholders), and then a <date> tag corresponding to the third column. This puts dates corresponding to the time period into this section of the table. Afterwards, there is a <rowborder>.

Next is variables, and these are given by means of two <txt> tags and one <var> tag. The <txt> tags put text into the description and variable name fields, and the <var> tag identifies the variable (or expression) to print out. So we have these tags regarding the first variable row:

<txt>GDP</txt>
<txt>$</txt>
<var>Y</var>

The '$' is a special code implying that this piece of text is to be taken from the following <var> field. The text could alternatively have been given by means of "<txt>Y</txt>", but this way of doing it would produce a lot of duplicate variable names in the file. To avoid duplication (and reduce the error rate when editing variable names), it is convenient to use the '$'-codes. The two next rows are added in a similar fashion, and finally a <rowborder> tag concludes the table.

It should be noted that there are three different item types: <txt>, <var> and <date>. These are formatted differently, and to format them you may use attributes corresponding to the type, for instance varformat, varalign, or txtalign. Such attributes are inherited, and can be put on different levels of the table, more specifically on the following tags (in that order):

·in <table> (applies to the whole table).

·in <col> (applies to the specific column>.

·in <rowformat> (applies to all following rows, until next <rowformat> overrides it).

·in <row> (applies to the specific row)

·or in the element itself (for instance in the <txt> or <var> tags).

For instance, in the example there is the following format given: <table varformat="f9.0">. This applies to the whole table (since there are no other varformats in the table), and it means that variables are to be written with a width of 9 characters, and without any decimals. Lower level formats override higher levels, so for instance a specific row might be formatted differently. For instance <row varformat="f9.2"> could be used if that particular row were a percent change, where two decimals might be the most desirable format.

Regarding borders, parts of these can be hidden in different ways. The easiest way is to use column spanning, as in the example above. Since the table heading ("Table 1. Supply balance") spans three columns, the inner vertical border after the second column is not shown. To remove all vertical borders for a particular row (or successive rows), you may use the tag <colborderhide> inside the <rows> tag. This will remove all vertical borders for the following rows, until a <colbordershow> is set. To remove only specific borders, you may use <colboderhide>inner<colborderhide>, or <colboderhide>outer<colborderhide> (this hides inner or outer borders). You may also indicate the borders to remove by means of a comma-separated list of integers: <colboderhide>1,2<colborderhide>. This will hide the first and second vertical borders.

List of different tags and attributes

In general, the tags (for instance <txt>) can be thought of as contaning data, whereas the attributes (for instance txtalign="left") can be thought of as containing formatting. So the tags, or more precisely the elements inside the tags (for instance the element 'GDP' in <txt>GDP</txt>) can be thought of as the content of the table, whereas the attributes describe how the content is formatted/shown.

Tags:

·<col>: defines a column: set attribute type="expand" for data columns. You may define a special kind of column showing only one (indicated) period.

·<colborder>: defines a vertical border separating columns

·<colborderhide>: hides vertical borders, content can be "inner", "outer", or list of integers

·<colbordershow>: shows vertical borders (if some of them have been hidden)

·<cols>: inside this tag, columns are defined one by one, including their type, and any borders separating them

·<row>: indicates a new row, content is defined inside the <row>

·<rowborder>: indicates a horizontal border

·<rowformat>: sets format that is to apply to all rows until next <rowformat>

·<rows>: inside this tag, rows are defined one by one, including horizontal borders etc.

·<subcolborder>: is used to show (grey) borders between columns inside a time period. This tag is set inside a <col> tag. Example: <subcolborder period="#per1"/> or <subcolborder period="2030"/>.

Attributes:

·colspan (example: colspan="2"), used inside a <row> tag to span/merge columns. Similar to the way cells are merged horizontally in HTML tables. Note that code like <text colspan="3">AAA</txt> <txt>BBB</txt> would make 'BBB' appear in the fourth column, so the <text colspan="3"> tag really represents three <txt> tags.

·datealign (left/middle/right): used inside <table>, <col>, <rowformat>, <row>, or <date>. Horizontal alignment of dates in a <date> tag.

·period (example period="#target_year"). Used inside a <col> tag to indicate that only that particular period is to be shown, regardless of other time settings. Handy for a column with special kinds of indicators etc. The attribute is also used inside <subcolborder>, to indicate the period after which a gray line is to be inserted. Example: <col period="#target_year" txtalign="center" varformat="f8.3"/>.

·txtalign (left/middle/right): used inside <table>, <col>, <rowformat>, <row>, or <txt>. Horizontal alignment of text in a <txt> tag.

·type (example: type="span"): used inside a <col> tag to indicate that it is expandable (for instance data columns). Only columns of "expand" type are allowed to auto-expand into more columns, corresponding to the number of time periods the table is called with.

·vardisplay (example: vardisplay="p"): used inside <table>, <col>, <rowformat>, <row>, or <var>. Sets display mode regarding <var> tag. These should be given as Gekko print codes, for instance "p" for percent growth rate, "q" for multiplier percentage difference, "n" for levels etc (cf. the PRT/PPLOT/WPLOT commands).

·varformat (example: varformat="f12.2"): used inside <table>, <col>, <rowformat>, <row>, or <var>. Sets the print format for <var> tags. For instance, "f12.2" means floating point, width = 12 characters, and 2 decimals. Integers (no decimals) can be set as for instance "f12.0".

·varscale (example: varscale="0.001"): used inside <table>, <col>, <rowformat>, <row>, or <var>. All data in the given context is scaled/multiplied by the value given.

Editing the table

It is recommended to use a specific XML editor for editing the tables. They can be edited in a simple text editor like Notepad, but this entails some potential problems. There will be no check that the XML syntax is correct, e.g. that a tag like <row> is always closed by means of a </row> tag. Also, the XML syntax represents some characters in a special way: notably the '<' , '>', and '&' characters (these should be written '&lt;', '&gt;', and '&amp;'). The mentioned characters may easily show up in descriptive text such as "Table 1. R&D for size > 100 employees". The free and light-weight Microsoft XML Notepad 2007 can be recommended: (if used choose 'View' --> 'Expand All' to unfold all XML nodes). But obviously, there is a plethora of excellent XML editors. If the file is not in valid XML syntax, Gekko will complain that the file is invalid and abort.

Internally, when executing a XML table, the XML is translated into "normal" Gekko code (heavily using table objects) which is then executed in the same way as a normal command file.

Example

Call the table table1.tab, for the annual period 2012-2016:

TABLE <2012 2016> table1;

To have it printed in HTML instead, and as multiplier differences ('m'), use:

TABLE <2012 2016 m html> table1;

Note

In order to copy-paste a html table to Excel, the most reliable way is to use the copy-button in the Gekko user interface. There is an option to paste decimal separators as commas instead of periods (OPTION interface excel decimalseparator). Alternatively, you may right-click the html-table and paste from that menu, but that way you will lose non-shown decimals in the table cells.

In html tables, if you hover over a number, a label will appear with full decimals.

You can use a TIMEFILTER to omit periods for a more readable table.

There is an automatic table conversion tool from the older PCIM table format to the new XML format. See the menu: 'Utilities' --> 'Converters' --> 'PCIM converters' --> 'Convert PCIM tables...'.

If a variable is missing, the data will be shown as 'N' (this is in contrast to missing values for existing variables which are indicated by 'M').

Gekko will look for the table in first the working folder, and then in the folders denoted with "OPTION folder table", "OPTION folder table1" and "OPTION folder table2" (in that order). If the table is called from a .html menu, the URL path of the table call will be included too (after "OPTION folder table2"). So if preferred for menu systems, you may put your table (.tab) files next to your menu (.html) files.

The functions BANKFILENAME() and BANKTIME() may be used to decorate a table with filename/date of the underlying databank.

Related

options

OPTION folder table = [empty];

OPTION folder table1 = [empty];

OPTION folder table2 = [empty];

OPTION table ignoremissingvars = yes; [yes|no]

OPTION table html font = Arial;

OPTION table html fontsize = 72;

OPTION table html datawidth = 5.5;

OPTION table html firstcolwidth = 5.5;

OPTION table html secondcolwidth = 5.5;

OPTION table html specialminus = no; [yes|no]

OPTION table type = html; [txt|html]

Related

commands

MENU


TELL

Introduction

The TELL command prints a text string in the output window.

Syntax

TELL < NOCR > 'text' ;

'text' | The text to print (remember single quotes).
NOCR | (Optional). Indicates the no newline is inserted.

Example

The TELL command can be used to print informative messages:

TELL 'First line';

TELL 'Second line';

Use <nocr> if you need to join text:

TELL <nocr> 'The ';

TELL <nocr> 'fox is ';

TELL 'red.';

scalar variables will be in-substituted in a TELL-command.

STRING s = 'Data';

DATE d = 2010;

VAL v = 123.45;

TELL '#s #d #v';

Note

Note the use of single quotes. Note that "TELL #s" does not work: you have to use "TELL '#s'".

TELL replaces the older DISPLAY command (not to be confused with the DISP command).


TIME

Introduction

The TIME command sets global time used for subsequent time series operations. The command works for frequencies annual, quarterly or monthly.

Syntax

TIME period ;

period | per1 per2
per1 | Start period, for instance 2010 or 2010q1
per2 | End period, for instance 2012 or 2012q4

Example

If you only want to consider the year 2010, write:

TIME 2010 2010 ;

If you want to use the period 1980 to 2010, write:

TIME 1980 2010 ;

Commands like UPD, GENR, PRT etc. use global time if no time period is indicated. In all the relevant commands (i.e. all commands operating on time series), a time period can be set. This period can be either local (in brackets <>, operating on only the particular command line), or global (affecting all subsequent commands). The difference is illustrated below:

TIME 1980 2010;

PRT fY Enl;                        (a)

PRT <2000 2005> fY Enl;        (b) does not alter global time

PRT fY Enl;                        (c)

PRT 2000 2005 fY Enl;        (d) alters global time

PRT fY Enl;                        (e)

The first PRT statement (a) prints out the variables from 1980-2010, using the global time set in the TIME command. The second PRT statement (b) prints out from 2000 to 2005, but does not alter globals time settings. Hence, the third PRT statement (c) prints out from 1980-2010. The fourth PRT statement (d) prints out from 2000 to 2005, and alters global time settings. Hence, in the fifth and final PRT statement (e), the variables are printed out from 2000 to 2005.

One way of understanding the difference between local and global time settings is that this command:

PRT 2000 2005 fY Enl;

is completely equal to these two commands:

PRT <2000 2005> fY Enl;

TIME 2000 2005;

So when you use a time period outside the option brackets, you implicitly issue a TIME statement, too.

In command files, it is often preferable to use local time (i.e. use the ‘<’ and ‘>’ brackets) together with explicit TIME commands, as the programs become easier to understand and less error-prone.

Gekko can operate on annual, quarterly and monthly data, and timeseries of different frequencies can co-exist in a databank (even with the same name). Frequency is altered this way:

OPTION freq q;

This sets the frequency to quarterly. Alternatively use 'a' for annual or 'm' for monthly. If quarterly frequency is chosen, time periods are given as:

TIME 2000q2 2005q4;

That is, from second quarter of 2000 to fourth quarter of 2005. Months work similarly, for instance:

TIME 2000m2 2005m12 ;

This syntax regarding quarters and months can be used whereever it is relevant, for instance in the PRT command:

PRT <2000m2 2005m12> fY Enl;

When the frequency is quarterly or monthly, you can still denote the time period by means of integers (i.e. years). In that case, the full span of the sub-period is assumed: for instance with quarterly frequency set, "PRT <2010 2012>" would be equivalent to "PRT <2010q1 2012q4>".

Note

With annual frequency, if you write a number small enough, Gekko assumes that you intend to add 1900 to the number. So it tranlates ‘95’ into ‘1995’ for instance. Actually, in this way, you may write '125' instead of '2025', although this way of writing is not recommended.

Timeseries may be converted from one frequency to another by means of the COLLAPSE command.

The TIMEFILTER command may omit observations when printing etc., but can also be used to average the non-shown periods into the shown periods. This can be practical for timeperiods with many observations.

Related

commands

TIMEFILTER, COLLAPSE, OPTION freq = ...


TIMEFILTER

Introduction

The command TIMEFILTER is used to indicate periods that are to be omitted in output from TABLE, DISP, PRT and MULPRT. The commands PPLOT, WPLOT and CPLOT are not affected by the filter.

Syntax

TIMEFILTER filterperiods ;

filterperiods | periods, periods, ... (note the comma)
periods | singleperiod | periodlist
singleperiod | Single observation
periodlist | singleperiod : singleperiod BY step
step | An optional stepsize (default step: 1). Must be integer >= 1. Omit "BY step" if not needed.

Example

You may define periods like this:

TIMEFILTER 2010:2015, 2020:2030 by 5;

This results in the following:

Chosen periods: 2010, 2011, 2012, 2013, 2014, 2015, 2020, 2025, 2030

Hidden periods: 2016, 2017, 2018, 2019, 2021, 2022, 2023, 2024, 2026, 2027, 2028, 2029

So when you use for instance PRT, you will get all periods from 2010 up to and including 2015, and then the rest of the periods up to 2030 only shown every 5 years (2020, 2025 and 2030). A normal print will look like this:

 PRT fY;

                fy       [%]

 2010   1379471.0000      1.75

 2011   1431367.5000      3.76

 2012   1463109.6250      2.22

 2013   1491416.2500      1.93

 2014   1512247.3750      1.40

 2015   1534174.6250      1.45

 2020   1649068.8750      1.46

 2025   1773862.6250      1.47

 2030   1908568.7500      1.48

whereas an average-print will look like this:

PRT <filter=avg> fY;

                       fY         %

 2010        1379471.0000      1.75

 2011        1431367.5000      3.76

 2012        1463109.6250      2.22

 2013        1491416.2500      1.93

 2014        1512247.3750      1.40

 2015        1534174.6250      1.45

 2016-2020   1602281.9750      1.45

 2021-2025   1723167.3250      1.47

 2026-2030   1853869.9250      1.47

Here, the skipped periods are averaged into the shown periods. For the absolute level (the 'fY' column), a simple average is used, whereas for the percentage column, a more complicated averaging of growth rates is performed, in order to yield consistent average growth rates for the aggregated periods

The filter is controlled via these general options:

OPTION timefilter type = hide; [hide|avg]

OPTION timefilter = no;

The last options shows whether filtering is to be applied or not, whereas the first options selects the type of filtering. These can be overridden in the PRT command, for instance PRT<filter>, PRT<nofilter>, PRT<filter=hide>, or PRT<filter=avg>, so that different filtering can be performed quite easily in the PRT command, without having to change the globals options.

Note

TIMEFILTER does not alter the TIME period settings. Note that this command only affects print layout (so SIM, UPD, GENR etc. are unaffected by TIMEFILTER settings). When simulating for instance, out-filtered periods would never be skipped: filtering only affects visual reporting.

You may use 'TO' instead of ':' when indicating periods, so "2010:2020 by 2" and "2010 to 2020 by 2" are equvialent (and the latter is more similar to the FOR loop over DATEs). In the future, the colon will be used to choose rows/columns in matrices, so therefore the colon is used in a similar fashion here.

The TIMEFILTER in combination with PRT<filter=avg> replaces the older TIMESPAN and VPRT commands. There is the following correspondence from the old way to the new way:

TIME 1999 2012;

TIMESPAN 1999 1999, 2000 2000, 2001 2005, 2006 2010, 2011 2011, 2012 2012;  //old command

VPRT fy;                                                                    //old command

TIMEFILTER 2000:2010 by 5;                                                  //new command

PRT <filter=avg> fy;                                                        //new command

Related

commands

TIME, PRT


TRIMVARS

 | TRIMVARS
Introduction | The command is used to remove superfluous variables in Work and Base databanks. Often, a databank read from a file may contain variables that do not appear in the model used for simulation. This has no implications in itself, but may be distracting in some cases. For instance, you might have a variable Yd for income. Imagine that the definition of the variable is changed, and hence it's name is changed to Yd2 in both the databank and model. If the old variable Yd still resides in the databank, the user might mistakenly think that Yd is the real variable and use its values. TRIMVARS will delete any such superfluous variable in the Work and Base databanks, so that such accidents cannot occur.
Syntax | TRIMVARS ;
Example | Consider this setup: CLEAR; MODEL adam; READ adambk; TRIMVARS; This way, any superfluous variables are removed from the Work and Base databanks. If afterwards you WRITE the Work databank, this will be the trimmed version.
Note | There is a functionality to help tidying up models, databanks and variable labels. See the Gekko menu 'Utilities' --> 'Compare model/databank/varlist...'. Nothing will be trimmed in any OPEN databanks: these are read-only.
Related commands | READ, WRITE, FINDMISSINGDATA


UDVALG

Introduction

The name 'UDVALG' (a Danish word) will change into 'DECOMP' at some point ('DECOMP' can already be used as synonym).

UDVALG opens a special window with an Excel-like sheet showing the contributions etc. The UDVALG command can decompose in two ways:

·An existing model equation can be decomposed, analyzing how the changes in the left-hand side of the equation can be decomposed into contributions from variables on the right-hand side of the equation. The decomposition is carried out on on the differences between current and lagged values (time decomposition), or on the differences between the Work and Base databanks (multiplier decomposition).

·Alternatively, UDVALG can decompose a user-provided expression. This can be thought of as anything legal in a PRT statement (with some limitations).

In the UDVALG window, regarding the list of variables shown in the first column, endogenous (left-hand side) variables are marked in blue. You may click on these to track an effect further (in that case, a new UDVALG window opens). Cells can be copy-pasted to Excel or other spreadsheets (use Ctrl-A til select all cells). If variable labels are present/loaded, these will be shown when the mouse hovers over variables in the first column.

There is an "Update table" button for updating the table if the underlying data changes. For instance, after a new simulation, after a READ or MULBK statement, or after reassigning databanks via the F2 window (see the OPEN command). You can also update all UDVALG windows at once via the menu 'Window' --> 'Update'.

Syntax

UDVALG < period > period variable ;

UDVALG < period > period expression ;

period | (Optional). For instance "2010 2020" or "2010q1 2020q4". If inside the <> field, the period is local to the current statement, if outside the period will be changed globally. If no period is given, global time will be used.
variable | The name of the endogenous variable to be decomposed.
expression | An expression: anything legal in for instance a PRT statement. There are some limitations, though. You cannot use fixed periods (x(2010)), Base databank indicator (@x), named databanks (mybank:x), or VAL variables (#memvar). These restrictions may be alleviated in the future. The expression should end with a ';', not a '$'.

Details

The UDVALG window consists basically of a selector at the top, a table in the middle, and the equation/expression at the bottom. The selector consists of three parts: time-change selector, multiplier selector, and some auxiliary options at the right.

In the time-change and multiplier selectors, you may choose to either see 'raw' (non-decomposed) or 'decomp' (decomposed) values. The raw values are really just tabelling the relevant variables, optionally transforming them via the printcodes n, d, p, dp for time-changes, or n, m, q, mp for multipliers (see the PRT command for a list of these so-called 'short' printcodes). Raw values seldom sum up, so the first row is seldom equal to the sum of the rest of the rows (this only holds for simple sums in levels).

In contrast, the decomposed values for time-change or multiplier will sum up, so that the first row is equal to the sum of the rest of the rows. In that way, you may get an idea of why the left-hand side (or expression) changes relative to the previous period or relative to the Base databank.

In the auxiliary options at the upper right of the window, you may indicate that you want to see values from the Base databank instead of the Work databank, or that you prefer the decomposition output scaled so that the first line is 100 (%) and the other lines sum up to 100. The number of decimals shown can be changed, and the table can be updated by pressing the 'Update table' button (in case you wish to have changes in the databanks reflected in the table).

The decomposition is done by means of linearizing the equation (for time-changes: in the previous period, and for multiplier changes: for Base databank values) and using this linearization to forecast how much the left-hand side is expected to change due to the changes in the right-hand side (dy = β1 * dx1 + β2 * dx2 + ...). This may be more or less precise, depending upon how non-linear the equation is. If there is an error, that is, the contributions do not add up to 100% of the change in the left-hand side, the contributions are adjusted proportionally so that they sum up anyway.

Regarding decomposition of model equations, there is a further source of potential imprecision too, namely if the databank values of the first row (the dependent variable) do not correspond to the equation. If this is so, for instance for historical data, a further proportional adjustment is applied, so that the contributions sum up. (This problem does not exist regarding decomposition of an expression).

Clicking 'Show errors' allows you to inspect possible decomposition and data errors. If, for instance, you have selected 'Abs. time change' (row) and 'Decomp' (column), you may click both 'Show as shares' and 'Show errors' at the same time. This gives a good idea of any decomposition or data errors. If the decomposition error shows for instance 2.50% for a particular period, this means that only 97.50% of the change in the right hand side (or expression) can be explained by means of the linearization. The smaller the decomposition error is, the more confidence can be put into the decomposed contributions (for linear equations, the decomposition error would be 0 in the absence of rounding errors).

Example

After performing a multiplier analysis, you may want to decompose the fY variable to analyze the main contributors to it's changes:

UDVALG <2010 2020> fY;

Alternatively, you might have printed this expression (some inner part of a usercost variable in ADAM):

PRT (1-tsy_cu)*iwbz+bfinvbnze-(1-bfinvbnze)*rpibpe+0.2*tspzej;

and wondered what induces the changes in that expression in a particular period. This can be analyzed by changing PRT to UDVALG (and for instance clicking the 'Growth rate' and 'Decomp' combination, in the 'Time-change' selector.

UDVALG (1-tsy_cu)*iwbz+bfinvbnze-(1-bfinvbnze)*rpibpe+0.2*tspzej;

Note

DISP has a similar functionality, allowing to trace variables through model equations.

If you need to decompose a long expression spanning several lines, please use '&' to join the different lines. You can then mark the lines and hit [Enter] to execute the lines as one block of code. (Or use a command file).

You can only indicate one variable or expression in the UDVALG command. This is to avoid the command potentially opening up a lot of UDVALG windows at the same time.

The 'decimalseparator' option listed below controls how the cells are copied to the clipboard (for pasting in a spreadsheet), when the user uses copy-paste of cells in the UDVALG window.

OPTION interface excel decimalseparator = period; [period, comma]

Related

commands

READ, MULBK, MULPRT, DISP, INFO


UNFIX

 | UNFIX
Introduction | UNFIX removes any goals/means set with the EXO and ENDO commands.
Syntax | UNFIX ;
Example | See the examples in the ENDO help file.
Note | Note that when ENDO and EXO are active, there is a target icon at the bottom right in the user interface, stating the number of goals and means set. After UNFIX, this icon disappears, since there are no more goals/means set.
Related commands | ENDO, EXO, SIM


UNSWAP

Introduction

After reordering databanks in the F2 window, for instance swapping the Work databank with one of the OPEN (named) databanks, only a limited subset of the Gekko commands will be legal (to avoid confusion).

To (again) be able to READ, WRITE, SIM, etc., use UNSWAP. This sets all alias names for all databanks back to their values before swapping was commenced (can also be done with the 'Unswap'-button in the F2 window).

Syntax

UNSWAP ;

Related

commands

OPEN, READ, MULBK


UPD

Introduction

The command UPD (UPDate) is used to give a variable new values. UPD is convenient for setting values (unless the variable depends upon other variables, in which case GENR should be used). UPD is typically used for updating exogenous variables before simulations.

Syntax

UPD < period> variable period operator values ;

period | (Optional). For instance "2010 2020" or "2010q1 2020q4". If inside the <> field, the period is local to the current statement, if outside the period will be changed globally. If no period is given, global time will be used.
variable | Name of the variable to be updated (you may also use a list to update several variables at the same time).
operator | = sets value: var = value + sets absolute change: var = var + value * sets relative change: var = var * value ^ sets absolute change (dynamically): var = var(-1) + value % sets percent growth rate (dynamically): var/var(-1) - 1 = value/100 # changes growth rate (dynamically): var/var(-1) = var/var(-1) + value/100 $ is used in addition to the other operators, and will preserve the growth rate after the update period
values | ·value value ... ·expression, expression, ... (note: delimited with commas)
value | Floating point number.
expression | Scalar expression: what is legal on the right-hand side of a VAL statement.

If one value is given, this value will be applied to the entire period, else the values are delimited with blanks for numbers and commas for expressions. A missing value can be denoted by a 'M'). In a command file, values can be put on several lines -- in that case please remember to use '&' to connect one line with the next

Note if one value is given, then this value will be applied to the entire period. The values are delimited with blanks (a missing value can be denoted by a ‘M’). In a command file, values can be put on several lines - in that case please remember to use “&” to connect one line with the next.

The following table represents the different choices regarding four of the operators:

Using lagged value:

Type | Operator | Example | Result
Absolute | ^ | UPD var ^ 1000 | x = x(-1) + 1000
Relative | % | UPD var % 3 | x = x(-1)*(1+3/100)

These operators are used to change yearly (if frequency is annual) difference or growth rate.

Using current value:

Type | Operator | Example | Result
Absolute | + | UPD var + 1000 | x = x + 1000
Relative | * | UPD var * 1.03 | x = x*1.03

These operators change the variable relative to what it is already (no lagged variables are used).

Example

Set VAT (tg) to new values:

UPD <2011 2020> tg = 0.23 0.22 0.21 0.20 0.19 &

                    0.18 0.17 0.16 0.15 0.14;

The '&' is appended after the first line above to join the two line (this is actually not strictly necessary regarding the UPD command, but good practice for clarity). Time is set locally here, i.e. the time setting will not affect subsequent commands.

Adding 1000 to the variable JDfvmo can be done with the '+' operator:

UPD <2010 2010> JDfvmo + 1000;

Instead of updating with fixed numbers, you may use scalar variables instead.

VAL f1 = 0.02;

UPD <2010 2012> tg + #f1, 2*#f1, 0.01;

Note the commas separating the items. This augments the variable tg with 0.02 in 2010, 0.04 in 2011, and 0.01 in 2012. Without the commas, a statement like "UPD <2010 2011> xx = #f1 - #f2" would be ambiguous (update both years with the difference, or update 2010 with #f1 and 2011 with -#f2?).

Augment the price of exports by 1% for the years 2010-2012:

LIST pe = pee2 pee59 peet peesq;

UPD #pe 2010 2012 * 1.01;

Note that 1.01 is implicitly used for all three periods (you do not need to write “1.01 1.01 1.01”). Here, a LIST is used. Note that this is different from setting the annual growth rate (see operator '%').

Set VAT (tg) to decrease by 0.01 annually (i.e. 0.24 in 2010, 0.23 in 2011, and 0.22 in 2012, since the VAT rate is 0.25 to begin with).

UPD <2010 2012> tg ^ -0.01;

Make the import price of food (pm01) increase by 2% annually (for the global time period):

UPD pm01 % 2;

If instead you want to augment the already existing growth rate, you may write:

UPD <2010 2012> pm01 # 2;

In that way, 2 percentage-points of growth are added to the growth of pm0. If the growth rate for pm0 is 1.5%, 2.1% and 1.9%, it will hence be changed to 3.5%, 4.1% and 3.9%.

If you add a '$' after the operator, Gekko will keep the same growth rate in the data, after the time period where the variable is changed.

UPD <2007 2007> kssya +$ 0.01;

This way, kssya has 0.01 added in 2007, and in the subsequent years, the old growth rate in kssya is maintained.

The variable to be updated normally exists in the work bank, but if the prefix “xx” is added, it is automatically CREATE'ed:

UPD xxvar = 27;

If convenient, you may also use wild-card lists:

UPD <2010 2010> [J*] = 0;

This sets all variables in the Work databank beginning with 'J' to 0, for the given period. If the period is put outside the option field <>, it should be placed between the variable name and operator:

UPD JDfvmo 2010 2010 + 1000;

After this statement, global time will have been changed to 2010-2010. Using local time (<2010 2010>) is recommended, however, as it makes the command files a bit clearer and less error-prone when UPD statements are moved around in the file.

Note

You may use the '&'-character to join lines, if the UPD command expands several lines in a command file. This is good practice, but not strictly necessary (for UPD, the lines will be joined even if the '&'-characters are missing).

You cannot use '-' directly as an operator: use "UPD JDfvmo + -1000" to decrease a variable, not "UPD JDfvmo - 1000".

Related

options

OPTION calc ignoremissingvars = no; [yes|no]

OPTION freq = a; [a|q|m]

Related

commands

GENR, UPDPRT


UPDPRT

Introduction

UPDPRT is used to print out UPD statements corresponding to databank values.

Syntax

UPDPRT < period > period variable operator ;

period | (Optional). For instance "2010 2020" or "2010q1 2020q4". If inside the <> field, the period is local to the current statement, if outside the period will be changed globally. If no period is given, global time will be used.
variable | Name of the variable(s) printed. Several variables can be printed at once using, var1 var2 .... You may also use lists or expressions.
operator | = or + or * or ^ or %

Example

An example is

UPDPRT <2010 2012> fY +;

This prints out an UPD statement for the 'fY' variable, with '+' operator. All UPD operators except '#' and '$' are supported.

Related

commands

UPD, PRT


VAL

Introduction

The VAL command is used to assign floating point numbers to a scalar variable of value type. A variable 'v1' can later on be referenced to by means of '#v1' or '{v1}'. A value variable can be thought of as a scalar, i.e. a constant floating point number (independent of time period etc.).

Val's are scalar variables, and in this respect similar to dates and strings (see DATE and STRING).

Value variables can be used in expressions, for instance in GENR or UPD, or in PRT/MULPRT/PPLOT/WPLOT/CPLOT statements.

Syntax

VAL name = expression ;

name | The name of the value scalar variable
expression | The value assigned to the value scalar variable

Example

You may use values as a container for fixed floating point numbers for use in your program.

VAL v1 = 1.10;

VAL v2 = 1/(10+#v1);

TELL'#v1 #v2';

PRT #v1 #v2;

GENR tg = #v1 * tg;

UPD <2010 2013> tg + #v2, -#v2, 0.5*#v2, 0.01;

When printing VAL's with the PRT statement, note that these VALs are constant over any time period (they are not to be understood as time series)

You may loop over VALs, see FOR.

Gekko will try to automatically convert a STRINGs or DATEs to VAL in VAL statements. Sometimes an explicit conversion is necessary: in that case you may use the VAL() function.

Note

Related

commands

DATE, STRING, GENR, UPD, FOR, IF


VERS

 | VERS
Introduction | The VERS command prints out the Gekko version used.
Syntax | VERS ;
Related commands | STAMP


WPLOT

Introduction

In Gekko, you can transfer variables to Excel by means of the WPLOT command. WPLOT has the same syntax as PPLOT and CPLOT commands, and similar syntax as the PRT command.

Syntax

WPLOT < period printcode > period HEADING=heading STAMP=yesno variables FILE=filename SHEET=sheetname CELL=cell DATES=yesno LABELS=yesno COLORS=yesno TRANSPOSE=yesno APPEND =yesno ;

period | (Optional). For instance "2010 2020" or "2010q1 2020q4". If inside the <> field, the period is local to the current statement, if outside the period will be changed globally. If no period is given, global time will be used.
printcode | (Optional). 'Short' printcode: N, D, P, DP, M, Q, MP, B, BD, BP, BDP
HEADING= | (Optional). Heading.
STAMP= | (Optional). If 'yes', a time stamp is inserted at the top
variables | Name of the variable(s) printed. Several variables can be printed at once using, var1 var2 .... You may also use lists or expressions.
FILENAME= | (Optional). WPLOT will optionally create an Excel file silently without opening Excel (the filename will be [filename].xls or [filename]xlsx, and is put into the Gekko working folder)
SHEET= | The name of the sheet for your data
CELL= | The cell where data starts, for instance 'c4'
DATES= | [yes|no]: If 'yes', dates are shown (is 'yes' per default)
LABELS= | [yes|no]: If 'yes', labels are shown (is 'yes' per default)
COLORS= | [yes|no]: If 'yes', colors are shown (is 'yes' per default)
TRANSPOSE= | [yes|no]: If 'yes', the table is transposed (is 'no' per default). Corresponds to ROWS option for PRT and MULPRT.
APPEND= | [yes|no]: If 'yes', the table is appended to an existing Excel workbook (is 'no' per default)

You may use a 'printcode' to indicate which kind of data transformation you would like on your variables (the '@' indicates values from the Base databank):

d | Absolute time difference: x-x(-1)
p | Growth rate: (x/x(-1) -1)*100
m | Absolute multiplier: x-@x
q | Relative multiplier: (x/@x-1)*100
mp | Growth rate multiplier: (x/x(-1) -1)*100 - (@x/@x(-1) -1)*100
bd | Absolute time difference in Base: @x-@x(-1)
bp | Growth rate in Base: (@x/@x(-1)-1)*100

Example

An example could be:

WPLOT fY Ul;

Plots the two variables in Excel. Or more advanced:

WPLOT  fY 'GDP' Ul 'Unemployment' FILE = scenarioA;

This produces the file scenarioA.xls (or .xlsx) silently. WPLOT produces a table in Excel, with variables running downwards and periods running rightwards. Missing values are converted to missing values in Excel (#N/A). WPLOT should work regardless of Excel macro settings, decimal separator etc., on Excel 2003 and upwards.

To illustrate the options, consider this example:

WPLOT <m> fM/fY 'Imports' fE/fY 'Exports' FILE=adam.xlsx SHEET=Raw  CELL=d1  DATES=no  LABELS=no

COLORS=no  TRANSPOSE=yes  APPEND=yes;

This will print an absolute multiplier (print-code m) of the two expressions (with labels), to the Excel workbook adam.xlsx (appending to the pre-existing file). The data will be put into the sheet 'Raw', in cell D1, without dates, labels and colors, and with rows and columns transposed.

Note

The WRITE command can also output variables as an Excel workbook. WPLOT, however, has more options to control the workbook.

Excel must be installed on your computer, in order for WPLOT to work. In Excel 2007 and 2010, you can click on a cell inside the table and select 'Insert' and 'Line' (from the 'Charts' ribbon), and a chart will be produced (with the correct legend, labels etc.).

Related

options

OPTION freq a; [a|q|m]

OPTION interface excel modernlook = yes; [yes|no]

OPTION interface excel language = danish; [danish|[empty]]

Related

commands

WRITE, PRT, PPLOT, CPLOT


WRITE

Introduction

The command writes the work bank to a .tsdx file (default, but other formats are possible).

Syntax

WRITE < period format CAPS=yesno > period filename ;

WRITE < period format CAPS=yesno > period variables FILE=filename ;

period

(Optional). Without a timer period indicated, Gekko will write all the data for all observations. When a period is indicated, the written data(bank) is truncated.

format

File format (default: .tsdx file). Choose between CSV, TSD, TSDX, TSP, XLS, XLSX.

·CSV: Only frequencies matching the current frequency setting will be written. If no period is set, Gekko will write all years occurring in the Work databank.

·TSD: With option 'CAPS=yes', all .tsd variable names are written in captions (for use with the AREMOS software package).

·TSDX: Default

·TSP: Gekko will write TSP records (load statements). Works for annual frequencies only.

·XLS or XLSX: Gekko will try to write the data to an Excel workbook. Cf. also the WPLOT command. Only frequencies matching the current frequency setting will be written. If no period is set, global time will be used.

variables

Variables and/or list(s); if none given, the full Work databank is written. Wildcards may be used.

filename

The file you want to write the variables to

Example

Save the simulation of the model for the year 2010 to 2050:

MODEL adam;

READ adambank;

SIM 2010 2050;

WRITE sim50;                () all vars as a .tsd file

WRITE <xls> sim50;        () all vars as an Excel sheet

WRITE <csv> sim50;        () all vars as a .csv file

If you only want subset of the variables (or a subset of the time period), you may write for instance:

WRITE<2040 2050 xls> fy fe fm FILE=sim4050;

If convenient, you may also use wild-card lists:

WRITE [fX*] file=fxfile;

This writes all variables starting with "fX" to the file fxfile.tsdx. Actually "WRITE [*] file=databank" is equivalent to "WRITE databank".

Note

Please use WPLOT if you need to put labels or expressions etc. into an Excel sheet.

If "option folder = yes", and "option folder bank" is set, the WRITE statement tries to write to that particular folder instead of the working folder.

Related

options

OPTION databank file format = tsdx; [tsd|tsdx]

OPTION folder bank = [empty];

OPTION interface csv decimalseparator = period; [period|comma]

Related

commands

READ , WPLOT


BASTA

Introduction

BASTA (calculating product tax rates) is a submodel to ADAM, which calculates changes in rates for product taxes from changes in tax revenues. This provides opportunities to assess the overall impact of changes in tax revenues in ADAM. The command BASTA envokes the submodel Basta in Gekko.

Syntax

BASTA ;

Example

With the help of BASTA, for example, we can calculate the effects of the changes in various tax rates on the overall model. For instance, consider the effect of a 100 million DKK increase in state revenues from gasonline, it can be elucidated as follow. This is done by selecting the sub menu “Update on NR-taxes” and entering the current changes in tax revenue.

Note

BASTA is the successor of BRAS. BRAS is introduced in the working paper "Guide to BRAS", 2 July 1996.

The BASTA routine is not part of Gekko. BASTA is supplied by the Modelling Group at Statistics Denmark.

Related

commands

PSKAT, UADAM, BIV, RASQ, DEMO, EKSEMSAM, EXOALL, ENDOALL


Biv

 | BIV
Introduction | BIV is a subroutine for corporate tax deductions.
Syntax | BIV ;
Example | With the help of BIV we can calculate the effects of the changes in various corporate tax deduction on the overall model.
Note | The BIV routine is not part of Gekko. BIV is supplied by the Modeling Group at Statistics Denmark.
Related commands | BASTA, PSKAT, UADAM, RASQ, DEMO, BIV, EKSEMSAM, EXOALL, ENDOALL


Demo

 | DEMO
Introduction | The DEMO system illustrates the use of Adam. The selection of examples illustrates printing, plotting and multiplier analysis.
Syntax | DEMO;
Example |
Note | Since menu systems are not implemented in the current Gekko version, the selection of examples will only be available for manually use. The DEMO routine is not part of Gekko. DEMO is supplied by the Modeling Group at Statistics Denmark.
Related commands | BASTA, PSKAT, UADAM, BIV, RASQ, EKSEMSAM, EXOALL, ENDOALL


Eksemsam

 | EKSEMSAM
Introduction | A collection of standard experiments for ADAM.
Syntax | EKSEMSAM ;
Example |
Note | Since menu systems are not implemented in Gekko, there is no menus for the collection of examples. These examples can be used manually. The command EKSEMSAM opens to the help file, where the code snippets are present. The EKSEMSAM routine is not part of Gekko. The collection of standard experiments is supplied by the Modeling Group at Statistics Denmark.
Related commands | BASTA, PSKAT, UADAM, BIV, RASQ, DEMO, EXOALL, ENDOALL


Pskat

 | PSKAT
Introduction | PSKAT (Personal income tax) is a submodel to ADAM, which calculates changes in tax rates and deductions in income taxes. This provides opportunities to assess the overall impact of changes in tax revenues in ADAM. The command PSKAT envoke the submodel PSKAT in Gekko.
Syntax | PSKAT ;
Example | With the help of PSKAT, for example, we can calculate the effects of the changes in tax system on the overall model.
Note | PSKAT is the successor of MISKMASK. The PSKAT submodel is not part of Gekko. PSKAT is supplied by the Modelling Group at Statistics Denmark.
Related commands | PSKAT, UADAM, BIV, RASQ, DEMO, EKSEMSAM, EXOALL, ENDOALL


Rasq

 | RASQ
Introduction | The RASQ routine calculate employment figures consistent with the register based employment figures (RAS employment figures).
Syntax | RASQ ;
Example |
Note | The RASQ routine is not part of Gekko. RASQ is supplied by the Modelling Group at Statistics Denmark
Related commands | BASTA, PSKAT, UADAM, DEMO, BIV, EKSEMSAM, EXOALL, ENDOALL


Uadam

 | UADAM
Introduction | UADAM is a submodel to ADAM, which analyses and calculates demographic forecasts.
Syntax | UADAM ;
Example | With the help of UADAM and a demographic forecast from Statistics Denbmmark we can calculate the effects of the ageing on the labor force and the public finances.
Note | The submodel UADAM is not part of Gekko. UADAM is supplied by the Modelling Group at Statistics Denmark.
Related commands | PSKAT, UADAM, RASQ, DEMO, BIV, EKSEMSAM, EXOALL, ENDOALL


ADD

Introduction

The ADD command runs a file with Gekko commands.

Syntax

ADD [path\]file-name;

A path must be specified if the file is not located in the working folder. If the file-name is given without extension, ‘.add’ is added as extension

Example

A script file, papertab.gnr, contains Gekko commands for a table of variables to a paper: If the script resides in the folder c:\paper, it can be executed

ADD c:\paper\papertab.gnr;

Note

You may start Gekko with a particular .add or .cmd file. Gekko accepts commands as arguments, so Gekko can be called like this:

GEKKO ADD c:\adam\start1.add

This will execute start1.add when Gekko starts. The easiest way to do this is to have Gekko provide a .lnk-file to the Gekko executable (gekko.exe) in the program folder. The Gekko executable is typically found in this location: ‘drive:\Adam\Gekko\gekko.exe’.

The ADD command works the same way as running .cmd files (via the RUN command). The only difference is that ADD looks for files with extension .add if no extension is given (whereas RUN looks for .cmd files)

Related

options

OPTION folder add = [empty];

OPTION interface debug = dialog; [dialog|none]

OPTION interface sound = no; [yes|no]

OPTION interface sound type = bowl; [bowl|ding|notify|ring]

OPTION interface sound wait = 60;

Related

commands

RUN, RETURN, STOP


CLEARGOALS

Introduction

The command clears any ENDO/EXO variables. The command is quite similar to the GAUSS command, but does not revert the solve method to 'gauss'.

If a model with ENDO/EXO variables has been solved, it will have been solved by means of the Newton algorithm. After a CLEARGOALS statement, the Newton algorithm will still be used, whereas after a GAUSS statement, the Gauss algorithm is used (reverted to).

Syntax

CLEARGOALS;

Example

Consider this example:

NEW;

MODEL adam;

READ adambk;

EXO fY;

ENDO tg;

UPD fY % 2;

SIM;

CLEARGOALS;

After the CLEARGOALS statement, fY is again endogenous, and tg exogenous. If a SIM is issued after the GAUSS statement, this simulation will replicate the previous one, given that the values of tg are set in a way that ensures that the endogenous variable fY grows with 2% per period.

Related

options

OPTION solve gauss goal switchback = no; {yes|no}

Related

commands

GAUSS, ENDO, EXO


Closebanks

 | CLOSEBANKS
Introduction | CLOSEBANKS is used to clean up the workspace except for any loaded model, as if Gekko had been closed and re-opened (the only exception is that the output window is not cleared). CLOSEBANKS clears databanks, lists, scalar variables, macros and options. But beware: CLOSEBANKS does not clear a loaded model.
Syntax | CLOSEBANKS;
Example |
Note | Note that any isstart.cmd file residing in the working folder will be re-read. So any options etc. that the user wishes to be available after a CLOSEBANKS can be put into isstart.cmd (but please do not put a CLOSEBANKS in the isstart.cmd file - that will result in an infinite loop). It should be noted however, that when re-reading the isstart.cmd file, Gekko will skip any MODEL statements inside that file. You may use CLS for clearing the output window, and you may use "CLEAR *" to clear the work and base databanks at the same time. The CLOSEBANKS command is identical to the CLOSEALL command, except that CLOSEBANKS does not clear a loaded model, and ignores any MODEL commands in a isstart.cmd file. When using the same model for the analysis, CLOSEBANKS will be faster than CLOSEALL, since the model will not have to be reloaded.
Related commands | CLOSEALL, CLS, DELETE, NEW


Dekomp

 | DEKOMP
Introduction | The command DEKOMP is not yet implemented in Gekko. The command UDVALG decompose the change in a variable according to the equation in the current model.
Syntax | DEKOMP variable = f(variable) ;
Example |
Note |
Related commands | UDVALG


DUMOFF

Introduction

DUMOFF (dummy off) is used to set dummy variables to 0.

Syntax

DUMOFF [period] variables;

period | period for the update should apply to
variables | the dummy variables to be set to zero. You can use #listname or var1 var2 ....

Example

These two commands give the same result

UPD dphk = 0

DUMOFF dphk

Note

A lists of exogenization dummies is predefined as #exod. DUMOFF can be abbreviated to DUMOF.

Related

commands

DUMON, ENDOALL, EXOALL, UPD


DUMON

Introduction

DUMON (dummy on) is used to set dummy variables to 1.

Syntax

DUMON [period] variable;

period | period for the update should apply to
variables | the dummy variables to be set to 1. You can use #listname or var1 var2 ....

Example

These two commands give the same result

UPD dphk = 1

DUMON dphk

Note

A lists of exogenization dummies is predefined as #exod.

Related

commands

DUMOFF, ENDOALL, EXOALL, UPD


ENDOALL

Introduction

ENDOALL is a subroutine to ADAM. ENDOALL provides a standard setup for all dummies in the model.

Syntax

ENDOALL ;

Example

With the help of ENDOALL model setup returns to default setup concerning exogenously and endogenously variables.

Note

The ENDOALL routine is not part of Gekko. ENDOALL is supplied by the Modeling Group at Statistics Denmark.

EXOALL is the opposite subroutine. After issuing EXOALL the is no behavior relationships present in the model.

Related

commands

PSKAT, UADAM, RASQ, DEMO, BIV, EKSEMSAM, EXOALL, ENDOALL


Exoall

 | EXOALL
Introduction | EXOALL is a subroutine to ADAM. EXOALL provides a standard exogenous setup for all dummies in the model.
Syntax | EXOALL ;
Example | With the help of EXOALL the model is in a specific setup where no behavior relationships are endogenous.
Note | ENDOALL is the opposite subroutine. After issuing ENDOALL all behavior relationships are endogenous. The EXOALL routine is not part of Gekko. EXOALL is supplied by the Modeling Group at Statistics Denmark.
Related commands | PSKAT, UADAM, RASQ, DEMO, BIV, EKSEMSAM, EXOALL, ENDOALL


FLAT

Introduction

FLAT sets all variables in the work databank to 0% growth rate (i.e., constant) for the indicated period.

Syntax

FLAT [period] ;

period

The local or global period

Example

The FLAT command is equivalent to

UPD #all % 0 ;

Note

Related

commands

ZERO, UPD


GAUSS

Introduction

The command clears any ENDO/EXO variables, and afterwards sets the solve method to 'gauss'. The command is quite similar to the CLEARGOALS command, and can be thought of as short-hand for these statements:

CLEARGOALS;

OPTION solve method = gauss;

If a model with ENDO/EXO variables has been solved, it will have been solved by means of the Newton algorithm. After a CLEARGOALS statement, the Newton algorithm will still be used, whereas after a GAUSS statement, the Gauss algorithm is used (reverted to).

Syntax

GAUSS;

Example

Consider this example:

NEW;

MODEL adam;

READ adambk;

EXO fY;

ENDO tg;

UPD fY % 2;

SIM;

GAUSS;

After the GAUSS statement, fY is again endogenous, and tg exogenous, and the (default) Gauss method is used. If a SIM is issued after the GAUSS statement, this simulation will replicate the previous one, given that the values of tg are set in a way that ensures that the endogenous variable fY grows with 2% per period.

If the 'switchback' option shown below is set to 'yes', the last GAUSS statement in the example would not be necessary. With the option set, Gekko will automatically revert to Gauss-mode (with no goals set) after an ENDO/EXO simulation.

Related

options

OPTION solve gauss goal switchback = no; {yes|no}

Related

commands

CLEARGOALS, ENDO, EXO


GMULPRT

Introduction

This command prints values from the baseline databank, from the work databank, and the difference between the two databanks. The output is quite bulky, but can be convenient at times.

Syntax

GMULPRT [period ] variable [ file = filename ];

period | The local or global period for which data is compared
variable | Variable(s) er a list of variables (the whole databank is compared if no variables is given)
filename | The file you want to write the variables to

Example

Note

Related

commands

MULPRT


MACRO

Introduction

The MACRO command is used to make text substitutions in a command file. Macro’s can for instance be used to define a start and end period as a variable, to be used in subsequent commands (and other command files). The MACRO command is intended for use in command files, not for interactive use.

The MACRO command will be deprecated, and replaced by STRING, DATE and VAL commands. So please avoid using MACROs if possible.

Syntax

MACRO option [ name text ];

option | + define a macro ? show defined macro
name | the name of the macro
text | text string that the macro should contain

Example

If you often load the databank hit1295, the following macro can be used to save typing (and easily change the databank filer later on):

MACRO + bank c:

Now the bank hit1295 can be loaded with

READ !bank

Also, time periods may be handled by macros:

MACRO + startper 2010

MACRO + endper 2050

UPD < !startper !endper > tg = 0.22

SIM < !startper !endper >

Macro’s are read-only, and can only be deleted by means of the CLOSEALL command (deleting all of them). If you try to change an already existing macro, Gekko will report an error and stop.

Note

A macro must be defined before it is used. Otherwise you will get an error about an unrecognized element starting with ‘!’.

NOTE: Macros are slowly being phased out, and will not be available in Gekko in the longer run. Memory variables are intended to replaces macros, cf. STRING, DATE and VAL.

IMPORTANT NOTE: Macro’s are in reality snippets of code. These snippets can contain anything, including brackets, special characters etc. Therefore, before Gekko compiles a command file, it pre-fetches any macro’s inside that file, BEFORE the file is compiled. This can have unintended side-effects, so therefore strings, integers, and other type-safe variables will be introduced in Gekko soon (corresponding to assign-variables in a package like AREMOS).

At the present time, macros are only really working as a kind of global read-only variables, used to control a system of command files (like time periods used, files read/written etc.). Even in that case, macro’s pose problems due to the pre-fetching. If you wish to use macro’s in that way, please consider following setup:

MASTER-MASTER-FILE

========= mmaster.cmd ==================

CLOSEALL ;

ADD master.cmd ;

======================================

MASTER-FILE

========= master.cmd ====================

READ databank ;

MACRO + databank c:\project\databank.tsd ;

MACRO + databank2 c:\project\databank2.tsd ;

WRITE !databank ;

ADD slave1.cmd ;

…

…

======================================

SUB-FILE1

========= slave1.cmd ===================

READ !databank ;

…

…

======================================

The idea is to create a simple two-line master-master command file (mmaster.cmd), calling your usual master-command file (master.cmd). Macro settings should be put into the master.cmd file (and not the mmaster.cmd file).

Related

commands

LIST, STRING, DATE


MULPCT

Introduction

The command MULPCT prints the percentage differences between the Work and Baseline data banks.

Syntax

MULPCT [period] variable ;

period | The local or global period for which data is compared
variable | Variable(s) er a list of variables (the whole databank is compared if no variables is given)

Example

Printing the multiplier percentage difference for the two variables pcp and lna:

MULPCT pcp lna

If you prefer more details, please see the MULPRT command

Note

The command is in reality just short-hand for “PRT <q>”. Please consult the PRT help file regarding syntax etc.

Related

commands

MULPRT, GMULPRT, PRT, MULBK, SIM


NEW

Introduction

NEW is used to clean up the workspace, as if Gekko had been closed and re-opened (the only exception is that the output window is not cleared). NEW clears databanks, models, lists, scalar variables, macros and options.

In contrast to CLOSEALL, it does not rerun an isstart.cmd file in the working folder. This is the only difference between these two commands.

It is recommended to put a NEW or CLOSEALL statement at the top of a command file (or the starting point in a system of command files calling each other), in order to be sure that the environment is the same from session to session.

Syntax

NEW;

Example

You might use the following commands to set up your environment:

NEW;

CLS;

OPTION folder model \models;

OPTION folder bank \databanks;

OPTION solve method = newton;

MODEL mymodel;

READ mydatabank;

TIME 2012 2050;

The above commands could be put at the start of your command file, setting up the environment for a new session. Put the NEW command first, then (optionally) a CLS command, and then OPTION commands. Finally MODEL and READ commands, and perhaps a TIME command to set up the time period.

If lines 2-8 in the above example were put into a file named 'isstart.cmd', and this file were put in the working folder, the following would yield the same result:

CLOSEALL;

So in effect, CLOSEALL issues a NEW command, and then runs any isstart.cmd file.

Note

You may use CLS for clearing the output window.

Related

commands

CLS, DELETE, CLOSEALL


PCTPRT

Introduction

The command PCT prints the specified variables in percentage changes. The command is in reality just short-hand for “PRT <p>”. Please consult the PRT help file regarding syntax etc.

Syntax

PCTPRT [period] variable ;

period | The period for which data is compared
variable | Variable(s) er a list of variables (the whole databank is compared if no variables is given)

Example

Printing the annual growth rates (provided the frequency is annual) for the two variables pcp and lna:

PCTPRT pcp lna

Note

The command is in reality just short-hand for the command 'PRT <p>'.

Related

commands

PRT, MULPRT, MULPCT


PRTX

Introduction

The PRTX command is an experimantal version of the PRT command. In the longer run, PRT and PRTX will merge, but for now, PRTX has some interesting capabilities that PRT does not (yet) have.

Like PRT, PRTX prints out variables. However, PRTX can do some convenient things like printing out transposed (variables running vertically and dates running horizontally), and element-specific formatting is possible for PRTX-statements with several arguments.

Syntax

PRTX [<options>] [period] [heading = heading] var1...var_n [file = filename] ;

var : variable ['label'] [<varoption>]

options | Local time period, 'rows', 'width', 'dec', 'nwidth', 'ndec', pwidth', 'pdec', or print-codes like for instance 'p' or 'q'
period | An optional global time period
heading | An optional heading
variable | Name of the variable to be printed. Several variables can be printed, and you may also use lists or expressions.
filename | An optional file for the output.
label | An optional label in single quotes.
varoption | Element-specific options: 'width', 'dec', or print-codes like for instance 'p' or 'q'

The print-codes are as follows (the '@' indicates values from the Base databank):

d | Absolute time difference: x-x(-1)
p | Growth rate: (x/x(-1) -1)*100
m | Absolute multiplier: x-@x
q | Relative multiplier: (x/@x-1)*100
mp | Growth rate multiplier: (x/x(-1) -1)*100 - (@x/@x(-1) -1)*100
bd | Absolute time difference in Base: @x-@x(-1)
bp | Growth rate in Base: (@x/@x(-1)-1)*100

Examples

Consider the three variables X, Y and Z Theses can be printed 'normally' this way:

PRTX X Y Z;

                 X              Y              Z

 2012   1422410.1900    840244.0310    820656.7920

 2013   1449485.6800    870528.3070    856602.4050

 2014   1467763.9700    903111.8390    908734.3150

This will print out the three variables much like the PRT statement (but with no showing of percent growth rates). PRTX can alternatively print transposed, that is, with variables running vertically and dates running horizontally (by means of the 'rows' option):

PRTX<rows> X Y Z;

             2012           2013           2014

 X   1422410.1900   1449485.6800   1467763.9700

 Y    840244.0310    870528.3070    903111.8390

 Z    820656.7920    856602.4050    908734.3150

The 'rows' keyword can be understood as printing out the variables row-wise instead of column-wise. Putting a <p> print-code will show percentage growth, just as in the PRT command:

PRTX<p> X Y Z;

            X       Y       Z

 2012    1.76    3.61    4.82

 2013    1.90    3.60    4.38

 2014    1.26    3.74    6.09

The output is the same as "PRT<p> X Y Z;". But PRTX is able to transform the individual elements:

PRTX X Y<p> Z<p>;

                   X       Y       Z

 2012   1422410.1900    3.61    4.82

 2013   1449485.6800    3.60    4.38

 2014   1467763.9700    3.74    6.09

This time, only Y and Z are shown as percentage changes. An identical print can be obtained by means of:

PRTX<p> X<n> Y Z;

In this case, there is a global print-code <p> set, but for the variable X, this print-code is overriden by an element-specific printcode (<n>, meaning printing out the raw level).

In addition to print-codes, width and decimals can also be set. These can be set on a general basis, with 'width' and 'dec' codes, for instance:

PRTX<width=10 dec=2> X Y<p> Z<p>;

                X           Y           Z

 2012  1422410.19        3.61        4.82

 2013  1449485.68        3.60        4.38

 2014  1467763.97        3.74        6.09

This will print out X in levels, and Y and Z in percentage growth, all with width 10 and 2 decimals. Gekko can distinguish between formatting levels and percentages, so the following is also possible:

PRTX<nwidth=8 ndec=0 pwidth=5 pdec=1> X Y<p> Z<p>;

              X      Y      Z

 2012   1422410    3.6    4.8

 2013   1449486    3.6    4.4

 2014   1467764    3.7    6.1

In this case, X (in levels) will be formatted with width 8 and no decimals, whereas Y and Z (percentage growth) will be formatted with width 5 and 1 decimal. This formatting applies not only to <p> print-code, but to all print-codes that result in percentages figures (for instance <q> or <mp>). The formatting can also be set on the elements themselves:

PRTX X<width=8 dec=0> Y<p width=5 dec=1> Z<p width=5 dec=1>;

This yields the exact same print as the previous one.

There is a hierarchy regarding formatting. Regarding decimals for a particular element, Gekko will first look for a 'dec' in the general PRTX option field, and the for a possible 'ndec' (if the element is in levels) or 'pdec' (if the element is in percentages). Finally, Gekko will look for a 'dec' in the element-specific option field.

Labels can be introduces in the same way as regarding the PRT command, for instance

PRTX X 'Variable X' Y 'Variable Y' <p> Z 'Variable Z' <p>;

The labels must be put after the variables, but before any element-specific print-codes.

Expressions are accepted, just as in the PRT command. Wild-card lists (inside brackets []) may be used instead of regular lists:

PRTX [fX*]

This will print out all variables starting with 'fX' in the Work databank (use '?' as a single-character wild-card).

Note

You can use a TIMEFILTER to omit periods for a more readable print.

Please also see the help file regarding the PRT command. As noted in the introduction, the PRT and PRTX commands will merge at some point.

Related

options

OPTION freq a; [a|q|m]

OPTION print filewidth = 130;

OPTION print width = 100;

Related

commands

PRT, MULPRT, PPLOT, WPLOT, DISP, INFO, UDVALG


Skip

 | SKIP
Introduction | This command skips the whole command line. Alternatively you may use “()” or "//" to comment out a single line, or “/*” followed by “*/” to comment out an arbitrary section (for instance spanning multiple lines).
Syntax | SKIP ;
Example |
Note |
Related commands |


snippet_filename

 Top

The filename of the file that the output is written to.


snippet_period

 Top

(Optional). For instance "2010 2020" or "2010q1 2020q4". If inside the <> field, the period is local to the current statement, if outside the period will be changed globally. If no period is given, global time will be used.


Tabeller

 | TABELLER
Introduction | This command is not yet implemented. See the TABLE and MENU commands.
Syntax | TABELLER ;
Example | The subroutine TABELLER is not part of Gekko. TABELLER is supplied by the Modelling Group at Statistics Denmark.
Note |
Related commands | TABLE


TIMESPAN

Introduction

The command TIMESPAN is used to control periods for printing with VPRT.

Syntax

TIMESPAN period [, period [, period ...]] ;

period

sets period from start to end, start and end must be valid periods given the current time series frequency.

Example

You may define three periods like this:

TIMESPAN 2011 2015, 2016 2020, 2021 2025

VPRT fY

Using VPRT, averages and average growth rates for the variable fY will be printed, for each of the three subperiods.

Note

TIMESPAN does not alter the TIME period settings.

Related

commands

VPRT, TIME, PRT


Tspprt

 | TSPPRT
Introduction | This command is not supported at the moment. Gekko can read from TSP however, see the menu “Utililties” --> “TSP utilitites”.
Syntax |
Example |
Note |
Related commands | PRT


Undo

 | UNDO
Introduction | The UNDO command only works in combination with the SIM command, undoing a previous simulation. This can be convenient if the simulation fails.
Syntax | UNDO sim ;
Example |
Note | You must activate the option "OPTION solve undo" in order for UNDO SIM to work.
Related commands | SIM


UPDX

Introduction

The command UPDX is conceptually the same as the UPD command -- the difference is that UPDX accepts VAL variables and expression as arguments. In UPDX, you must use a comma as delimiter.

Syntax

UPDX [< period>] variable [period] operator [$] values ;

period | Local or global period
variable | Name of the variable(s) printed. Several variables can be printed at once using, var1 var2 .... You may also use lists or expressions.
operator | = sets value: var = value + sets absolute change: var = var + value * sets relative change: var = var * value ^ sets absolute change (dynamically): var = var(-1) + value % sets percent growth rate (dynamically): var/var(-1) - 1 = value/100 # changes growth rate (dynamically): var/var(-1) = var/var(-1) + value/100
values | If one value is given, this value will be applied to the entire period, else the values are delimited with blanks (a missing value can be denoted by a ‘M’). In a command file, values can be put on several lines - in that case please remember to use “&” to connect one line with the next.

The dollar symbol '$' is used if you want to preserve the growth rate after the update period

Note if one value is given, then this value will be applied to the entire period. The values are delimited with blanks (a missing value can be denoted by a ‘M’). In a command file, values can be put on several lines - in that case please remember to use “&” to connect one line with the next.

Example

Update with a VAL factor:

VAL f1 = 0.20;

UPDX <2010 2012> tg + #f1, 2*#f1, 0.10;

Note that the '+' is an operator: see the UPD command for much more information.

Note

Related

commands

UPD, GENR, PRT


VPRT

Introduction

The command VPRT is used to print pre-defined periods.

Syntax

VPRT [<b>] [period ] [heading = heading ] variable [file = filename] ;

b | Indicating reference databank
period | Local or global timespan period
heading | An optional heading
variable | Name of the variable(s) printed. Several variables can be printed at once using, var1 var2 .... You may also use lists or expressions.
filename | The result will be put into a a text file

Example

You may define three periods like this:

TIMESPAN 2011 2015, 2016 2020, 2021 2025

VPRT fY

You may put the periods inside the option brackets (like the PRT command), and 'b' can be used to indicate values from the baseline databank.

VPRT <2011 2015, 2016 2020, 2021 2025 b> fM/fY file=out.txt

Note

TIMESPAN does not alter the TIME period settings.

Related

commands

TIMESPAN, TIME, PRT


ZERO

Introduction

ZERO sets all variables in the Work databank to 0 for the indicated period.

Syntax

Zero [period] ;

period

the period simulation is made, if no period is indicated, simulation made for the global time period.

Example

Note

The Zero command is identical to UPD #all = 0;

Related

commands

FLAT, UPD