Related:

Timeseries

A timeseries is a time-sequence of data in some frequency, for instance annual, quarterly or monthly. Gekko is timeseries-oriented, so timeseries and time periods are an integral part of the software. See the list of all features, or read more about timeseries below.

Short-list of all main Gekko features
  • Timeseries-oriented software, with flexible databanks. Array-series (for sparse data) are provided.
  • Data tracing: trace origins of timeseries data backwards in time.
  • Annual, quarters, months, weekly, daily and undated frequencies supported. Conversions between these are in-built.
  • Values, dates, strings, lists, maps, etc., including many functions dealing with these.
  • Matrix calculations, including construction, addition, multiplication, inversion, etc. Also supports nested lists that can represent arrays of data.
  • Seasonal correction via X12A.
  • Graphics by means of embedded gnuplot.
  • User-defined functions and procedures, and libraries can be used to store these.
  • 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 (also supports GAMS models).
  • GAMS-style expressions supported, including sums over sets, $-conditionals, etc.
  • Tabelling and menu system, outputting in text, html or Excel.
  • Read/write from Excel or other spreadsheets. Formats like tsd, prn, csv also supported.
  • So-called 'Gekcel' add-in for Excel, so that Gekko can be used from within an Excel workbook.
  • Interface to open-source Python or R for econometrics, data mining and many other things.
  • Strict language syntax (via in-built ANTLR parser), with loops, conditionals etc.
  • Free, open source. Easy installation, and used by many Danish organizations.

Handling timeseries in Gekko is very easy. Consider this example (Gekko 3.0 syntax):

y <2020 2030> = x1 + x2[-1] + x3[2015] + bank2:x4;

In this statement, the timeseries y is defined as x1 + x2 lagged one period + the value of x3 in 2015 + x4 from the databank ‘bank2’. All this is performed over the period 2020-2030. This is just a simple example, but illustrates the power of a timeseries-oriented syntax.

Combined with lists, loops, etc., the Gekko command language is very well suited for timeseries-oriented data management systems. You might for instance receive data from different sources, in different frequencies, and try to balance or manipulate these timeseries in different ways, in order to construct a databank suitable for modeling purposes. So-called array-series can be used if the timeseries data is sparse or needs to be organized in dimensions.

Gekko also operates with a concept of sequences of open databanks, that is, the possibility of opening up several databanks and have Gekko look for timeseries names in these databanks. This can be very practical, and Gekko also makes it easy to use naming schemes in such databanks. For instance, you may use names like xa, xb, xc, etc., and have Gekko loop over these names:

TIME 2015q1 2020q4;
#sectors = a, b, c;
FOR string %i = #sectors; 
  x{%i} = x{%i}[2014q4]; 
END;

This will set xa, xb and xc to their values in the fourth quarter of 2014, over the global time period 2015q1-2020q4. The code also makes use of a list (LIST) and a loop (FOR … END). Note that this naming scheme does not involve arrays or other complicated structures, so you may for instance store the timeseries in a simple spreadsheet with these names as row labels, and the time periods as column labels. In Gekko 3.0, instead of the loop you may simply write:

  x{#sectors} = x{#sectors}[2014q4];

Or if x were a multidimensional array-series, it would look like this:

  x[#sectors] = x[#sectors][2014q4];

These examples are just illustrations, and yield a small taste of the syntax and possibilities. Data management systems tend to become large in volume, so the easy timeseries syntax makes the handling of many lines of such code a breeze.

Using timeseries

Gekko timeseries are typically kept in databanks for easy storage and retrieval. Gekko databanks are open-format (using so-called protobuffers).