gs_quant.timeseries.technicals.trend

trend(x, method=SeasonalModel.ADDITIVE, freq=Frequency.YEAR)[source]

Trend of series with seasonality and residuals removed.

Parameters:
  • x (Series) – time series with at least two years worth of data.

  • method (SeasonalModel) – ‘additive’ or ‘multiplicative’. Type of seasonal model to use. ‘multiplicative’ is appropriate when the magnitude of the series’s values affect the magnitude of seasonal swings; ‘additive’ is appropriate when seasonal swings’ sizes are independent of the series’s values.

  • freq (Frequency) – ‘year’, ‘quarter’, ‘month’, or ‘week’. Period in which full cycle occurs (i.e. the “period” of a wave).

Return type:

Series

Returns:

date-based time series with trend of input series.

Usage

Uses a centered moving average and convolution to decompose the input series into seasonal, trend, and residual components. This function returns the trend component.

If using the default additive model:

\(Y_t = X_t - S_t - R_t\)

If using the multiplicative model:

\(Y_t = X_t / (S_t * R_t)\)

Examples

Generate price series and compute its trend.

>>> prices = generate_series(1000)
>>> trend(prices)

See also

seasonally_adjusted()