Description
Computes a linear regression by fitting a straight line to the data and taking seasonality into account.
Syntax
SEASONAL_LINEAR_REGRESSION(Input Block, Seasonality [, Ranking Dimension])
Arguments
Argument | Type | Dimensions | Description |
---|---|---|---|
Input Block (required) | Number | Any Dimensions | This is the data source on which the seasonal linear regression is computed, and must be a Metric with data points as an expression of Integer or Number type. This Metric must include the same Dimension that is used in the |
Seasonality (required) | Integer | No Dimension | Length of the seasonality. It must be greater than 1, for example, if you observe a quarterly on a Metric defined by month, the Seasonality length is 3. If you observe a yearly seasonality on a Metric defined by month, the Seasonality length is 12. |
Ranking Dimension (optional) | Dimension | Not applicable | This is a Dimension applied to the time series taken in the |
Returns
Type | Dimensions |
---|---|
Number | Dimensions of Input Block |
With N being the Seasonality length of the serie, the function returns:
Blank for value before the first non blank value.
(A * x + B ) * SeasonalityFactor(x) after the first non blank value
To compute SeasonalityFactor, A and B, we use the classical decomposition method, called multiplicative decomposition, over historical data.
Notes:
Blank observations (in the input Block) between the first non-blank value and the last non-blank values are considered as 0.
The function requires 2 times the seasonality in terms of datapoint between the first non-blank value and the last non-blank values.
Examples
Formula | Description |
---|---|
| Computes a yearly seasonality over a metric defined by quarter. |
| Computes a yearly seasonality over a metric defined by month. |
| Computes a quarterly seasonality over a metric defined by month. |
Example using SEASONAL_LINEAR_REGRESSION(Actuals, 4)
:
Using SEASONAL_LINEAR_REGRESSION as Forecasting Function
A common use case for using the SEASONAL_LINEAR_REGRESSION function is to prepare a forecast. It’s a good method when your observation series shows a linear trend and a seasonality.
See also
Related articles: FORECAST ETS , FORECAST_LINEAR
[References: Multiplicative decomposition , wikipedia]