# Sample size for best forecasting ARIMA model

How can we decide the size or portion of the data given to get the ARIMA that has the best forecasting properties?

I mean, for example, we have a hourly series with over 28.000 elements.

Which is the criteria that tells us: do ARIMA over last 100 elements, or 250 last elements, so the ARIMA we get is better for forecasting? I am interested in short time prediction, like for 24 hours.

I read everywhere but found no criterion yet.

A good rule of thumb is: more is usually better.

Then again, more may not always be better. For instance, your data-generating process may have changed strongly over time, so that the data from before the change may not reflect current and future dynamics of your series any more. In such a case, it may indeed be better not to use your full dataset. (You may want to look at our questions tagged if you suspect something like this to be going on.)

Overall, the best way to assess almost anything about a forecast is to use a holdout sample. Hold out the last part of your data, say the last week (168 hours). Fit a model to the $n$ historical periods before that. Forecast out 24 hours. Note the error. Move the entire setup forward one hour (fit with $n$ historical periods, forecast 24 hours ahead, note the error). Do this until you have gone through your holdout sample. You should now have 168-24+1=145 errors. Do this for various "reasonable" values of $n$. Pick the one that yields the lowest error.

You will need to specify "reasonable" values of $n$, best based on your prior knowledge. Alternatively, just pick some numbers than make sense. You will also need to specify the forecast accuracy measure you want to use. I'd recommend the Mean Squared Error (MSE) if you are looking for unbiased point forecasts.

This section in a free online forecasting textbook is very helpful.

That said, 28000 hourly data points correspond to over three years of data. Without knowing anything else about your data, I suspect that there may be multiple sources of seasonality involved, like intra-daily, intra-weekly (e.g, for retail, call center or electricity demands, which show strong weekly patterns), or intra-yearly (like temperatures or weather information more generally). (S)ARIMA is not really made for handling multiple seasonalities. If you suspect that your data exhibits complex seasonalities, it will probably be more useful if you use a dedicated model to model these than if you optimize the history used by an inappropriate model like ARIMA. This earlier question may be helpful, as may other questions in the time-series tag on "complex seasonalities".

• Thank you, I suspect any kind of seasonality because this is a cryptocoin evolution time serie. And surprised that there are no hypothesis contrasts or criteria values for that n picking. The way you explain is the way i am trying, but can be little messy about which is the issue that changes the accuracy, if the arima order selection or the n size, so thats the reason I cant decide about the sizing. – Guillermo González Sánchez Feb 1 '16 at 22:41
• Note: the linked textbook is co-written by the maintainer of the forecast package. – user81847 Feb 2 '16 at 0:41
• @GuillermoGonzálezSánchez Ah, since it's financial data, you may want to consider a different class of models, such as those used in high-frequency (financial) time-series. Usually, these models hone in on specifying the nature of volatility. Within the class of ARIMA models, a random walk seems the most appropriate, a priori. What sort of ARIMA model(s) have you chosen? At least, tentatively selected? – Graeme Walsh Feb 2 '16 at 1:07
• I am trying in fact ARMA (autoarima gives me usually less than order 4 in ar and ma) over the diferenced logs, and now trying to add possibly GARCH ones to handle volatility. Will check the high frequency ones. My goal is just predict safes daily mínima and maxima , thats why i am working minimizing upper 95% confidence prediction and maximizing lower 95% predictions. But need more accuracy. – Guillermo González Sánchez Feb 2 '16 at 7:39