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 Ranking Dimension  argument. |
Seasonality (required) | Integer | No Dimension or Dimensions of Text 1 | 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 Input Block . This is optional if it’s a datetime Dimension from the calendar. If this is not the case, then this is mandatory. It’s also mandatory if the Metric is defined on several time Dimensions. |
Â
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 |
---|---|
SEASONAL_LINEAR_REGRESSION(Actuals, 4, Quarter) | Computes a yearly seasonality over a metric defined by quarter. |
SEASONAL_LINEAR_REGRESSION( Actuals, 12, Month) | Computes a yearly seasonality over a metric defined by month. |
SEASONAL_LINEAR_REGRESSION( Actuals, 3, 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
nReferences: Multiplicative decomposition , wikipedia]