STL_Trend - chart function
STL_Trend is a time series decomposition function. Along with STL_Seasonal and STL_Residual, this function is used to decompose a time series into seasonal, trend, and residual components. In the context of the STL algorithm, time series decomposition is used to identify both a recurring seasonal pattern and a general trend, given an input metric and other parameters. The STL_Trend function will identify a general trend, independent of seasonal patterns or cycles, from time series data.
The three STL functions are related to the input metric through a simple sum:
STL_Trend + STL_Seasonal + STL_Residual = Input metric
STL (seasonal and trend decomposition using Loess) employs data smoothing techniques, and through its input parameters, allows the user to adjust the periodicity of the calculations it performs. This periodicity determines how the time dimension of the input metric (a measure) is segmented in the analysis.
At minimum, STL_Trend takes an input metric (target_measure) and an integer value for its period_int, returning a floating-point value. The input metric will be in the form of an aggregation that varies along the time dimension. Optionally, you can include values for the seasonal_smoother and trend_smoother to adjust the smoothing algorithm.
You can work with this function by entering it directly into the expression editor for a chart.
Syntax:
Return data type: dual
Argument | Description |
---|---|
target_measure |
The measure to decompose into Seasonal and Trend components. This should be a measure such as Sum(Sales) or Sum(Passengers) that varies along the time dimension. This must not be a constant value. |
period_int |
The periodicity of the dataset. This parameter is an integer value representing the number of discrete steps that make up one period, or seasonal cycle, of the signal. For instance, if the time series is segmented into one section for each quarter of the year, you must set the period_int to a value of 4 to define the periodicity as Year. |
seasonal_smoother |
Length of the seasonal smoother. This must be an odd integer. The seasonal smoother uses data for a particular phase in the seasonal variation, over a number of periods. One discrete step of the time dimension is used from each period. The seasonal smoother indicates the number of periods used for smoothing. For example, if the time dimension is segmented by month and the period is Year (12), the seasonal component will be computed so that each particular month of each year is calculated from data for the same month, both in that year and in adjacent years. The seasonal_smoother value is the number of years used for smoothing. |
trend_smoother |
Length of the trend smoother. This must be an odd integer. The trend smoother uses the same time scale as the period_int parameter, and its value is the number of granules used for smoothing. For example, if a time series is segmented by month, the trend smoother will be the number of months used for smoothing. |
The STL_Trend chart function is often used in combination with the following functions:
Function | Interaction |
---|---|
STL_Seasonal - chart function | This is the function used to compute the seasonal component of a time series. |
STL_Residual - chart function | When breaking down an input metric into seasonal and trend component, part of the measures variation will not fit within either of the two main components. The STL_Residual function computes this portion of the decomposition. |
For a tutorial with a full example showing how to use this function, see Tutorial - Time series decomposition in Qlik Sense.