STL_Residual - chart function
STL_Residual is a time series decomposition function. Along with STL_Seasonal and STL_Trend, 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. In performing this operation, part of the variation in the input metric will neither fit within the seasonal nor the trend component, and will be defined as the residual component. The STL_Residual chart function captures this portion of the calculation.
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.
Since time series decomposition primarily looks for seasonality and general variations in data, the information in the residual is considered the least significant of the three components. However, a skewed or periodic residual component can help identify issues in the calculation, such as incorrect periodicity settings.
At minimum, STL_Residual 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.
Syntax:
STL_Residual(target_measure, period_int [,seasonal_smoother [,trend_smoother]])
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_Residual 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_Trend - chart function | This is the function used to compute the trend component of a time series. |
For a tutorial with a full example showing how to use this function, see Tutorial - Time series decomposition in Qlik Sense.