Skip to content

One Step Ahead Predictions with ExponentialSmoothing #7077

@dtoniolo

Description

@dtoniolo

The problem

I have a time series divided in two consecutive train and test partitions. I need the model to perform well in one step ahead predictions. However, there seems to be no way to do this without refitting the model.

Code

I test the model in this toy example:

from statsmodels.tsa.holtwinters import Holt

data = load_data_from_somewhere()
n = data.size
train = data[:0.8*n]
test = data[0.8*n:]
mod = Holt(train)
fitted_mod = mod.fit(smoothing_level=.5, smoothing_slope=.05)

at this point, if fitted_mod where a state space model, i could do the following (related to what's explained here, but without the cross validation):

complete_mod = Holt(data)
fitted_complete_mod = complete_mod.filter(fitted_mod.params)
pred = fitted_complete_mod.predict(start=0.8*n)
# then compute metrics like MSE between pred and train

however, this is not possibile with Holt: the filter method fails. I can find no other way to do this. I'd like to make it clear that I do not want to refit the parameters, instead I wish to keep the same ones from the train fit.

Additional problem

As explained in the user guide, Exponential Smoothing are not compatible, in general, with the state space formulation. For this reason, three different implementations are provided.

The Hold instance provided here should be of class statsmodels.tsa.holtwinters.Holt, but is of type statsmodels.tsa.statespace.structural.UnobservedComponents instead. I do not now how this behaviour is possible and generates inconsistency, because fitted_complete_mod is of type statsmodels.tsa.holtwinters.results.HoltWintersResultsWrapper, instead of the statsmodels.tsa.statespace.structural.UnobservedComponentsResultsWrapper one would expect as output of the fit method of an UnobservedComponents.

Solution

There should be a clearer distinction between the classes of incompatible objects. Moreover, there should be a clear way to create an exponential smoothing model with some predefined parameters.

Note

If what I have described above is intended behaviour, then I apologise for opening the issue. If this is the case, I'd like to write a documentation page like this one so that other users won't repeat my mistake.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions