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 If If any of the columns listed in |
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
If any of the values in |
X |
any | A column name Cannot contain any NA values, as STL does not handle NAs. The series
|
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:
|
R |
text | Specifies which component of the decomposition is to be returned. Must be one
of the following:
|
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')"/>