|
<< Click to Display Table of Contents >> Elevator pitch (why use Gekko?) |
![]() ![]()
|
|
Before delving into the data management and modeling user guides, first a so-called elevator pitch. An elevator pitch is a brief summary that it should be possible to deliver in the time span of an elevator ride. It is, of course, possible to skip directly to the Data Management User Guide or the Modeling User Guide. But please consider spending a modest amount of time to read or at least glance through the following brief listing of the main points of the Gekko software. And if this plea does not persuade you, please consider revisiting the current page at a later time! |
Free and open-source programs like R or Python also manage data and can even run models, so what is so special about Gekko being timeseries-oriented? The following tries to explain this, highlighting some of the special concepts and syntax that Gekko uses in order to offer convenient timeseries management.
Timeseries-oriented
•Gekko operates with the concept of a global time period, so you normally do not need to state time, t, in timeseries expressions. Instead, you just use the timeseries names themselves, for instance y = 2 * x;.
•Gekko has a concept of global frequency, so you normally do not have to state the frequency of a timeseries variable, unless it differs from the global frequency. To denote a frequency explicitly, use the ! symbol, for instance x!q for a quarterly timeseries.
•Lags, leads, time differences, percentage growth, etc. have easy syntax, for instance x[-1], x[+1], dif(x), pch(x), etc. You may also use x.1 as short-hand for x[-1].
Scalars and collections
•Timeseries variables are exempt from prefix symbols, whereas scalars use % prefix symbol (for instance %x), and collections use # prefix symol (for instance #x).
•All Gekko scalars have prefix symbol %, for instance %x = 100;. Scalars can be value, date, or string.
•All Gekko collections have prefix symbol #, for instance #x = ((1, 2), 3); for a nested list of values. Collections can be list, matrix, or map.
Databanks and comparisons
•Gekko operates with the concept of a hierarchical list of open databanks, in which the first-position databank is the so-called (empty) Work databank when Gekko starts up. A databank reference can be stated explicitly with colon (:), for instance b1:x to indicate the timeseries x from the databank b1. If a databank name is not stated, Gekko will look for x first in the first-position databank, next in the second-position databank, and so on (unless such databank searching is switched off).
•Besides the list of open databanks, Gekko operates with a so-called Ref (reference) databank. You may use for instance prt <m> x; to print absolute differences between the x's in the two databanks (besides <m>, there are a lot of other comparison operators). The Ref databank is not part of the databank hierarchy.
•You may open an external Gekko databank file (.gbk file) as a 'named' databank, adding it to the end of the databank hierarchy. Alternatively, you may copy or merge the contents of an external databank file into the first-position databank with READ or IMPORT.
•You may use the special Global databank to store global variables/settings, for instance global:%tstart = 1980;.
Variable names
•The name prefix symbols % and # (for scalars and collections, respectively), and the frequency symbol ! are all to be interpreted as integrated parts of the variable name, alongside the more standard characters like a, b, ... z, etc. (+ digits and underscore).
•A variable can be uniquely identified by means of: bank + : + symbol + variable + ! + freq, where bank/variable = a simple name, symbol = % or #, and freq = a frequency character. For instance, b1:x1!q looks in the databank b1 for the variable x1 with q (quarterly) frequency, or b2:%y1 looks in the databank b2 for the scalar variable %y1. Timeseries names have no prefix symbol. Often, bank and/or frequency may be omitted.
•The names of variables residing in a given databank can be indexed and searched in different ways, using wildcards, ranges, etc. In some statements, 'naked' wildcards can be stated as simple as x*, whereas in other statements ['x*'] or {'x*'} must be used (more about wildcard logic here).
Lists
•Lists can contain any Gekko variable, and a list of strings is often used to represent variable names (or name-parts). It is often more convenient to operate on lists of names of variables, rather than on lists of the variable objects themselves. There are two ways to define lists: with strict syntax, or as naked lists:
•Strict syntax: #m = ('a', 'b'); is a list of the two strings 'a' and 'b'. Note the use of parentheses and quoted strings.
•Naked list: #m = a, b;. Parentheses and quotes can omitted for such simple lists. The result is the same as above.
•Nested lists (lists of lists) can represent multidimensional data, for instance "cells" from spreadsheets etc.
Name-composition
•Gekko uses {}-parentheses to insert name-parts from a string or list of strings. For instance, %i = 'a'; prt x{%i}y; is the same as prt xay;. The {}-parentheses can contain any expression that evaluates to a string or a list of strings.
•You may interpret the {}-parentheses as "quote-eaters", cf. the equivalence x{'a'}y = xay.
•Lists of strings can be used in name-composition, too. For instance #m = a, b, c; prt x{#m}y; is the same as prt xay, xby, xcy;.
•Instead of for instance x{%i}y or x{#m}y, you may use x%i|y or x#m|y, but this syntax is no longer officially endorsed.
•The {}-parentheses work inside strings too, for instance %i = 'a'; %s = 'x{%i}y'; is the same as %s = 'xay';.
•Instead of name-composition, it is often convenient to use array-series, with syntax like x[#m, y]. More on this page.
Operators
•Operators are often used in PRT (print), PLOT or SHEET (spreadsheet) for viewing data.
•Time-differences use operators like <d> for absolute time-difference, or <p> for percentage growth.
•Bank-differences use operators like <m> for absolute difference between the first-position and the Ref databanks, or <q> for percentage differences.
•The operators can also be used in timeseries statements, for instance x <p>= 2; or x <q>= 2;, the first making x grow 2% per period, and the last augmenting x with 2% relative to what it was. Other operators are available too, for instance x %= 2; or x += 1;.
•There is a special kind of operator, @, where @x is short-hand for ref:x, that is, fetching x from the Ref databank.
Statements, functions and procedures
•Statements can be stated with or without a <>-field to indicate 'local' options like the local time period. For instance, prt <2020 2030> x; will use the period 2020-30 in the PRT statement, but not alter the global time period. Gekko functions and procedures also support an optional local time period.
•Gekko functions support so-called Unified Function Call Syntax. So for instance the function y = f(x1, x2, x3) can alternatively be called with y = x1.f(x2, x3), moving the first argument out of the function and adding a dot (.). You may also use local time period in functions, like y = x1.f(<2010 2020>, x2, x3).
Options
•The user can state general options with the OPTION statement, whereas local options can be stated inside the <>-field of individual statements. A local option inside <...> angle brackets is only in effect during the execution of that particular statement.
Trivia
•Gekko is in general case-insensitive. So prt <p> x; is the same as PRT <P> X;.
•Commas (,) are generally used to separate lists of elements (and function arguments).
•You must use semicolon (;) at the end of a statement. In the Gekko input window, ; is set automatically when Enter is pressed.
More capabilities
Disclaimer: this section does not highlight the modeling capabilities of Gekko, for instance SIM, DECOMP etc.
Gekko has a lot more capabilities than what has been listed above. What was listed above can be said to illustrate what is special about Gekko, and where its perceived advantages lie. To read about some more capabilities: +toggle.
•Gekko has its own open databank format (.gbk), but also interfaces with a lot of other databank formats (see IMPORT/EXPORT). •Converting between frequencies, COLLAPSE and INTERPOLATE. •Copy, rename, move, delete objects between databanks. •Conditions (IF) and loops (FOR). •Linear regression (OLS) with extra possibilities. •Seasonal correction (X12A). •Operate on timeseries metadata, for instance labels, units, etc. •There are quite a lot of MATRIX possibilities (linear algebra), and conversions to/from timeseries is easy. •The MAP variable type is essentially a mini-databank, handy for storing variables by name, or used to return multiple variables from a function call. •There are a lot of possibilities and conveniences regarding array-series, and there is a tight correspondence to GAMS syntax for operating on such variables. So for instance, the array-subseries pop[m, 40] could represent the population of 40-year old males over time, instead of using a name convention like popm40 or pop_m_40 to store the same data in a normal timeseries. Array-series can be combined with sums, lists, and $-conditionals (known from GAMS). •Data-traces remember how data has been constructed, including program file names and line numbers etc. •R- and Python code/programs can be run from within Gekko, and there is also the so-called Gekcel add-in for running Gekko from within Excel. |