signaflo / java-timeseries

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

ARIMA is unstable on incomplete seasons #50

Open JBudinGanacos opened 1 year ago

JBudinGanacos commented 1 year ago

I am making ARIMA predictions with yearly seasonality and data. with 24 months of history, the prediction is as good as cn be expected with s little data, but if I use 25 months of history, the prediction is very unstable (slightly modifying one measure can result in a massive trend change).

Example input : 10 | 11 | 12 | 8 | 6 | 4 | 5 | 6 | 6 | 5 | 4 | 3 | 2 | 2.5 | 3 | 2 | 1 | 0.5 | 0.1 | 0 | 1 | 0.2 | 1 | 0 | 0.3 | 0.4 | 0.2 with the following ARIMA parameters : p = 0 d = 1 q = 1 aP = 0 aD = 1 aQ = 1, the previsions are increasing (athough the history is clearly decreasing). Changing the second value (the 11) into a 13 or a 9 makes the predictions seem correct.

When I perform the same prediction with only the 24 first value, the prediction is not as sensitive, and changing one input value only marginally affects the prediction.

See screenshot : Capture

I suspect this is due to this line in ArimaModel.java : this.differencedSeries = observations.difference(1, order.d()).difference(seasonalFrequency, order.D());

JBudinGanacos commented 1 year ago

When I replace the 2nd value (11) by 13, this is what I get, which seems a lot more appropriate.

Capture