g_stl(G;S;O;X;NP;OPTS;R)

Performs a time-series decomposition on the column X using the STL (Seasonal-Trend decomposition using LOESS). (Available as of version 19.00)

Description

The implementation of g_stl(G;S;O;X;NP;OPTS;R) is based on the standard FORTRAN implementation (https://www.netlib.org/a/stl).

Function type

Vector only

Syntax

g_stl(G;S;O;X;NP;OPTS;R)

Input

Argument Type Description
G any A space- or comma-separated list of column names

Rows are in the same group if their values for all of the columns listed in G are the same.

If G is omitted, all rows are considered to be in the same group.

If any of the columns listed in G contain N/A, the N/A value is considered a valid grouping value.

S NA Currently ignored.
O integer A space- or comma-separated list of column names that determine the row order within a particular group

If O is omitted, the order is the current display order of the table.

If any of the values in O are N/A, an error is returned.

X any A column name

Cannot contain any NA values, as STL does not handle NAs.

The series X must contain at lest two periods of data (2*NP data points) for each break, or an error is returned.

NP integer The seasonality (period length) of the data, such as 7 for a weekly-recurring pattern over daily data, or 12 for a yearly-recurring pattern over monthly data.
OPTS list-value Optional OPTION:VALUE pairs, separated by commas.
Options include the following:
  • robust (robust:1 specifies that robust iterations should be used to handle outliers)
  • outer_loops (use with robust)
  • seasonal_length
  • trend_length
  • low_pass_length
  • seasonal_degree
  • trend_degree
  • low_pass_degree
  • seasonal_jump
  • trend_jump
  • low_pass_jump
  • inner_loops
R text Specifies which component of the decomposition is to be returned. Must be one of the following:
  • 'seasonal'
  • 'trend'
  • 'remainder'
  • 'weights' (use with robust in OPTS to return the final robustness weights)

Return Value

For every row in each group defined by G, g_stl returns the times-series decomposition of X using LOESS. The order of the values is determined by the values in O; if O is omitted, the values are presented in the order they appear in the table.

Example

The following example query uses default settings for g_stl(G;S;O;X;NP;OPTS;R). The sum of the components of the decomposition is the original series, so the final selection retains all 30 rows.

<table cols="x">
5.0;9.0;2.0;9.0;0.0;6.0;3.0;8.0;5.0;8.0;7.0;8.0;8.0;0.0;2.0;5.0;0.0;5.0;
6.0;7.0;3.0;6.0;1.0;4.0;4.0;4.0;3.0;7.0;5.0;8.0
</table>
<willbe name="s" value="g_stl(;;;x;7;;'seasonal')"/>
<willbe name="t" value="g_stl(;;;x;7;;'trend')"/>
<willbe name="r" value="g_stl(;;;x;7;;'remainder')"/>
<willbe name="y" value="s+t+r"/>
<sel value="x=y"/>

Note how the sum of seasonal, trend, and remainder equals the original value.

This example uses the OPTS argument to return the final robustness weights.

<table cols="x">
5.0;9.0;2.0;9.0;0.0;6.0;3.0;8.0;5.0;8.0;7.0;8.0;8.0;0.0;2.0;5.0;
0.0;5.0;6.0;7.0;3.0;6.0;1.0;4.0;4.0;4.0;3.0;7.0;5.0;8.0
</table>
<willbe name="s" value="g_stl(;;;x;7;robust:1,outer_loops:10;'seasonal')"/>
<willbe name="t" value="g_stl(;;;x;7;robust:1,outer_loops:10;'trend')"/>
<willbe name="r" value="g_stl(;;;x;7;robust:1,outer_loops:10;'remainder')"/>
<willbe name="w" value="g_stl(;;;x;7;robust:1,outer_loops:10;'weights')"/>