|
<< Click to Display Table of Contents >> SMOOTH |
![]() ![]()
|
SMOOTH replaces missing values ("holes") inside a timeseries with values generated by means of a particular (user-chosen) method. The statement ignores the global time period, and a local time period cannot be set. Only holes between non-holes are smoothed, so the statement only deals with holes that occur after the timeseries' first non-missing value and before the timeseries' last non-missing value (use the fromSeries() function with 'dataStart'/'dataEnd' arguments if you need to know start/end dates of a timeseries).
Instead of the SMOOTH statement, you may alternatively use the similar smooth() function, for instance plot x.smooth(); (see under functions).
smooth var1 = var2 type;
var1 |
The new corrected timeseries |
var2 |
The timeseries that contains missings/holes |
type |
The type of smoothing, choose between:
•LINEAR. Linear interpolation (default). •GEOMETRIC. Geometric interpolation. •REPEAT. Repeats last known observation. •SPLINE. Cubic splines. •OVERLAY. Insert another series into the holes.
Note: default is LINEAR. You can alter the default with option smooth method = ... ; (cf. OPTION). |
The methods are as follows:
LINEAR |
Use linear interpolation (adds a fixed amount for each period in the hole(s)). |
GEOMETRIC |
Use geometric interpolation (multiplies with a fixed amount for each period in the hole(s)). |
REPEAT |
Set the values to the last known value before the hole(s). |
SPLINE |
Uses cubic splines to fill the hole(s). |
OVERLAY |
Uses another timeseries to fill the hole(s). |
•If no period is given inside the <...> angle brackets, the global period is used (cf. TIME).
•If a variable on the right-hand side of = is stated without databank, Gekko may look for it in the list of open databanks (if databank search is active, cf. MODE).
•Looping: with a list like for instance #m = a, b;, you may use for string %i = #m; smooth y{%i} = x{%i}; end; to smooth xa into ya, and xb into yb.
For instance:
reset; time 2002 2010; |
As you can see, the timeseries ts has a hole in the middle, namely the observations 2005-2007 (inclusive). Using the SMOOTH statement, these three observations are filled out. Below, the four different interpolation methods are shown (interpolated values in red):
ts ts1 ts2 ts3 ts4 ts5 |

Regarding the GEOMETRIC (green) method, note that the growth rate of ts2 is constant (31.61%) in the three interpolated years. In this particular case, SPLINE (yellow) perhaps provides the most realistic hole-filling, since it takes the curvature of the ts timeseries into consideration.
See the hpfilter() function regarding the smoothing of timeseries without holes.
option smooth method = linear;