Command language

The Gekko command language takes advantage of the timeseries-oriented nature of Gekko. You can perform general programming tasks in the command language, but using it for timeseries data management or modeling show its particular forte.

See the list of all features, or read more about language and programming below.

Short-list of all main Gekko features
  • Timeseries-oriented software, with flexible databanks.
  • Annual, quarters, months and undated frequencies supported, more to come. Conversions between these are in-built.
  • Lists, values, dates, strings, etc., including many functions dealing with these.
  • Matrix calculations, including construction, addition, multiplication, inversion, etc. etc.
  • Seasonal correction via X12A.
  • Graphics by means of embedded gnuplot.
  • User-defined functions.
  • Dynamically loaded and compiled models, including failsafe mode.
  • Gauss and Newton solvers, with ordering and feedback logic. Fair-Taylor or Newton-Fair-Taylor solver for forward-looking models. Any number of simultaneous goals/means possible.
  • In-built equation browser, with integrated labels/explanations.
  • Decomposition/tracking of changes in model equations.
  • Tabelling and menu system, outputting in text, html or Excel.
  • Read/write from Excel or other spreadsheets. Formats like tsd, prn, csv supported.
  • Interface to the free open-souce R package for econometrics, data mining etc.
  • Strict language syntax (via in-built ANTLR parser), with loops, conditionals etc.
  • Free, open source. Easy installation, and used by many Danish organizations.

The Gekko language has been redesigned in Gekko 2.0, the primary focus being:

  1. Make the language natural for timeseries handling
  2. Provide easy use of name-lists and name-composition
  3. Avoid unnecessary cluttering of the syntax

Regarding (1), you may consult the examples on the timeseries page. Regarding (2), timeseries databanks are often organized using some naming patterns/schemes. For instance, the timeseries may use the pattern K{i}{j} to state the type {i} and sector {j} of capital stocks, for instance Kma, Kmo, Kba, Kbo, where the capital types are ‘m’ and ‘b’, and the sectors are ‘a’ and ‘o’. Looping over and handling such name patterns is central in Gekko, for instance:

FOR i = m, b;
  FOR j = a, b;
    SERIES <2015 2020> K{i}{j} = K{i}{j}[-1];

This loops over the types ‘m’ and ‘b’, combined with the sectors ‘a’ and ‘o’. Inside the loop, the capital stock is set equal to the lagged capital stock, that is, the capital stock in the previous time period, effectively telling Gekko to use the values in 2014 for the period 2015-2020. The loop is equivalent to:

SERIES <2015 2020> Kma = Kma[-1];
SERIES <2015 2020> Kmo = Kmo[-1];
SERIES <2015 2020> Kba = Kba[-1];
SERIES <2015 2020> Kbo = Kbo[-1];

These four K-timeseries might be reside in a Gekko databank, or alternatively as rows or columns in a spreadsheet or .csv file or some other file format. Central to Gekko is the idea that a string (a sequence of letters inclosed in hyphens, for instance ‘Kma’) can be used either as the string itself (the collection of these particular letters and symbols), or to refer to a timeseries. This might not sound like such a big deal, but in practice it helps to keep the Gekko syntax simple and compact.

Regarding bullet (3) above, in some languages, accessing timeseries like K{i}{j} above would have to be done using some function syntax, for instance something like get(“K” + i + j, t) or get(“K”, i, j, t), where t is the time period. Even the lag might not be straightforward, if the frequency is not annual, so that you would have to use a lag() function, for instance get(“K” + i + j, lag(t, -1)) instead of K{i}{j}[-1]. This is just an example, but if the software language is for instance matrix-oriented, timeseries manipulations quickly end up being quite verbose and unnatural.

Further reading regarding the Gekko language syntax and its advantages: