compotime.models.LocalTrendForecaster#
- class compotime.models.LocalTrendForecaster#
Bases:
objectLocal trend state-space forecaster.
Notes
The local trend model is described by the following equations:
\[\begin{split}\boldsymbol y_t &= \boldsymbol l_{t-1} + \boldsymbol b_{t-1} + \boldsymbol \epsilon_t \\ \boldsymbol l_t &= \boldsymbol l_{t-1} + \boldsymbol b_{t-1} + \alpha \boldsymbol \epsilon_t \\ \boldsymbol b_t &= \boldsymbol b_{t-1} + \beta \boldsymbol \epsilon_t\end{split}\]where \(\boldsymbol y_t\) represents the unbounded time series observations at timestep \(t\) that result from applying the log-ratio transform. \(\boldsymbol l_t\) and \(\boldsymbol b_t\) represent the level and the trend, respectively.
An equivalent expression is as follows
\[\begin{split}\boldsymbol y_t' &= \boldsymbol w' \boldsymbol X_{t-1} + \boldsymbol \epsilon_t' \\ \boldsymbol X_t &= \boldsymbol F \boldsymbol X_{t-1} + \boldsymbol g \boldsymbol \epsilon_t'\end{split}\]where
\(\boldsymbol X_t = \begin{bmatrix} \boldsymbol l^{'}_{t} \\ \boldsymbol b^{'}_{t} \end{bmatrix}\), \(\boldsymbol w = \begin{bmatrix} 1 \\ 1 \end{bmatrix}\), \(\boldsymbol F = \begin{bmatrix} 1 & 1 \\ 0 & 1 \end{bmatrix}\) and \(\boldsymbol g = \begin{bmatrix} \alpha \\ \beta \end{bmatrix}\).
- __init__()#
Methods
__init__()fit(y)Fit the model.
predict(horizon)Predict future values of the time series.
Attributes
optim_params_opt_success_X_fitted_curve_colnames_time_idx_idx_freq_base_col_idx_- fit(y: DataFrame) Self#
Fit the model.
- Parameters:
y – Time series dataframe, where rows represent the timestamps and columns the different shares series.
- Returns:
Fitted instance of the model.
- Return type:
Self
- predict(horizon: int) DataFrame#
Predict future values of the time series.
- Parameters:
horizon – Number of steps into the future to be predicted.
- Returns:
Predicted time series.
- Return type:
pd.DataFrame