## 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 |
---|---|---|---|

(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.Â |

(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. |

(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]