compotime.models.LocalLevelForecaster#

class compotime.models.LocalLevelForecaster#

Bases: object

Local level state-space forecaster.

Notes

The local level model is described by the following equations:

\[\begin{split}\boldsymbol y_t &= \boldsymbol l_{t-1} + \boldsymbol \epsilon_t \\ \boldsymbol l_t &= \boldsymbol l_{t-1} + \alpha \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, and \(\boldsymbol l_t\) represents the local level.

Equivalently, to express it in the same terms as the LocalTrendForecaster, it is possible to use

\[\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 = \boldsymbol l^{'}_{t}\), \(\boldsymbol w = 1\), \(\boldsymbol F = 1\), and \(\boldsymbol g = \alpha\).

__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