signaflo / java-timeseries

Time series analysis in Java
MIT License
195 stars 49 forks source link

Arima forecast requires complete time series #5

Open twiechert opened 6 years ago

twiechert commented 6 years ago

Currently, one needs to provide the complete time series, in order to build an ARIMA model and subsequently obtain forecasts. When used in a streaming application, so that the time series is of possibly infinite length, this approach becomes unfeasible.

Let me shortly introduce my use case: I'm trying to use this framework in an application, where I consume a time series in a streaming fashion. Using window based aggregation, I downsample the series to exactly one value / 15 minutes. Given already fitted coefficients, I need to forecast one step ahead. When evaluating the forecast method, I have access to the last p time series values and the last q errors¹ (but not the whole time series).

What I popose is a method to allow forecasting trough a "partial" ARIMA model given by

model(TimeSeries lastP_Observations, TimeSeries lastQ_Errors, ArimaCoefficients coeffs)

¹ The errors are basically obtained by joining the time series stream with the time shifted forecast stream and calculating the differences.

signaflo commented 6 years ago

@twiechert, the proposed method seems pretty simple, but the accuracy could be improved. I would really like to have an updating model that uses the Kalman Filter, which has the Markov property, and thus requires little memory for models with reasonable numbers of coefficients. The main difference would be that you only need to supply the observations, whereas the most recent error estimates are stored by and updated by the Kalman Filter. Also, you wouldn't need to create a new object whenever new observations come in. You would update the already existing one. This would be easy when you already have the coefficients. But when you need to estimate the coefficients, it becomes more complicated.

I'll look into this some more. I like the idea of shifting to a streaming mindset, since that is where applications are moving and it could be a bit of a differentiator.

signaflo commented 6 years ago

@twiechert , created a new branch called streaming where I expect to start making these changes.

twiechert commented 6 years ago

This sounds amazing!