# Fitting an ARIMA model

I'm in need of some help. I've read a lot on fitting ARIMA models and I've ended up somewhat confused with a lot of questions.

First, why do we need the ACF and PACF of the raw data? What are we looking for? (I'm using R)

Second, I've read elsewhere on this site that the auto.arima function tends to overfit, and the best way to use it is as a first approximation. So how do we determine the best ARIMA model to use? What criteria are used in this determination?

Third, I'm trying to model daily adjusted close prices. How can I take into account days with no values such as weekends and holidays?

• Where did you read that auto.arima tends to overfit? Also, if you are modelling stock prices, there is little chance they will be anything else than a random walk, i.e. ARIMA(0,1,0), plus perhaps GARCH-type variance. Also, there should be no seasonality in stock prices so you do not need to adjust for day-of-the-week effects; hence, you can just delete the days with no observations. – Richard Hardy Sep 30 '15 at 16:27
• Thank you, I'm not sure where I read it, I've been reading a LOT about ARIMA and GARCH (school project). Indeed I've observed that if I use log returns, I get a random walk or white noise, depending on how much data I use, and I thought I was wrong. However, if I fit the raw data using auto.arima() it returns ARIMA (2,2,3). I guess what I need to know is, what criteria do I use to confirm the model I choose is the best? and where do the acf and pacf come in? – James Sep 30 '15 at 16:44
• You could check the existing questions and answers about ACF and PACF, about determining the order of an ARIMA model and about modelling stock prices. Your questions might quite likely have been asked before, just take the time to dig and find them. (Duplicate questions are not desirable, so to speak.) – Richard Hardy Sep 30 '15 at 16:54

ACF and PACF can be used to determine the autoregressive and the moving-average orders of an ARMA model. It will be easy in cases of pure AR or pure MA model, i.e. either ARMA($p$,0) or ARMA(0,$q$). (You should be able to find detailed examples in a time series textbook or elsewhere on Cross Validated.) Meanwhile, the order of an ARMA model with both $p$ and $q$ being nonzero may be difficult to read just from ACF and PACF.

I doubt that auto.arima indeed systematically tends to overfit. The algorithm behind the function has been empirically proven to work alright in many cases. For example, it delivers relatively high forecast accuracy on the M competition dataset consisting of some 3000 time series with their characteristics varying a lot. Also, note that you can choose between AICc (default), AIC and BIC for model selection in auto.arima. AICc will be optimized for forecasting, but BIC may be more suitable if you want the model selection to be consistent (I intentionally put it a little vaguely because the topic of AIC against BIC is too wide to cover here; you may see, for example, Burnham & Anderson "Multimodel Inference: Understanding AIC and BIC in Model Selection").

If you are modelling stock prices, there is little chance they will be anything else than a random walk, i.e. ARIMA(0,1,0), plus perhaps a GARCH-type pattern in the variance of the series. Also, there should be no seasonality in stock prices so you do not need to adjust for day-of-the-week effects; hence, you can just delete the days with no observations. However, if you take a long enough period, there might be some cycles and auto.arima might deliver something else than ARIMA(0,1,0). But from the subject-matter perspective it would be quite problematic for the stock prices to exhibit systematic patterns and to be predictable. It could perhaps be safer to just asssume an ARIMA(0,1,0), although I am not saying that this is unconditionally the best solution.

First, why do we need the ACF and PACF of the raw data? What are we looking for?

ACF and PACF may give you an idea about the lag structure of ARMA process. There are certain patterns for AR, MA and ARMA processes. For instance, a quick decay in ACF with cut-off in PACF would indicate AR(P) process, where cut off lag is your P etc.

Note, that for ARIMAX, i.e. when exogenous predictors are present, ACF/PACF is less useful, because predictor's correlations will show up.

So how do we determine the best ARIMA model to use? What criteria are used in this determination?

One of the criteria is AIC: lower is better. You can run combinations of ARIMA(P,D,Q) and find P,D,Q with the lowest AIC.

I personally don't use auto.arima, because my data sets are often small, and any reliance on automatic selection software is questionable. You have a lot of data, so going for auto.arima is less of an issue.

However, note, that there are many model selection criteria out there, including parsimony, for instance. Some of them are qualitative.

Third, I'm trying to model daily adjusted close prices. How can I take into account days with no values such as weekends and holidays?

The simplest and most popular way is to skip them as if they never existed. Simply work with business days. I'm not sure what's R's packages for financial time series. In MATLAB fints would handle business days. For instance, you usually would work with returns not prices, and in this case the return on Monday is over the price on last Friday (given that it was a business day) not Sunday, because exchanges are usually closed on Sundays so the price is not discoverable.

3) Treat them for what they are, price of a stock during weekend is the last known price (price EoD on Friday for example) although You may not trade, it will be the opening price on Monday morning pre-trading, nonetheless it will change instantly but is a starting point.

• Can you expand on how this fits with the other answers? It seems to contradict both of them. – mdewey Oct 25 '17 at 11:34
• Yes it does, because other answers are convenient for modeling and I don't believe time can be skipped or stopped and that it has impact on price. Just because You cannot trade something doesnt mean it doesnt have value and price at any given time. And weekend news/events are relevant but not easy to absorb and model. – Velletti Oct 26 '17 at 1:44