Skip to content
All library documents

Rolling ARIMA Coefficient Stability and Price-Return Comparisons

Article Quant Q&A · Author: Nour

Summary

This document examines fitting ARIMA models across rolling windows to track coefficient changes. Its central difficulty is that automatic model selection may choose a different order in each window, so the first reported coefficient may represent an autoregressive term in one fit and a moving-average term in another. Comparing such values does not provide a consistent measure of coefficient stability. The discussion does not offer a complete solution for enforcing a fixed model specification.

The example also contrasts automatic ARIMA fits to stock prices and log returns. A response identifies a faulty historical price segment associated with a stock split, recommends matching logarithmic transformations when comparing price and return models, and notes that weak return autocorrelation limits expectations for ARIMA forecasting. It suggests inspecting autocorrelation and rolling mean returns to study behavior. These are diagnostics for the cited stock-data example, not evidence that ARIMA models or rolling coefficients will predict reliably across assets or periods.

Key ideas

  • Automatic ARIMA selection can change model order across rolling windows, making a fixed coefficient position ambiguous.
  • Coefficient stability is easier to assess when the same model specification and coefficient meaning are maintained across windows.
  • Price and return comparisons should use consistent logarithmic transformations.
  • Faulty split-adjustment data can distort fitted models and apparent return behavior.
  • Weak return autocorrelation may limit the predictive value of an ARIMA fit; rolling mean returns are suggested as a behavior diagnostic.

Tags

Full text
# rollapply with Arima model: testing for stability of coefficients


# rollapply with Arima model: testing for stability of coefficients












I am trying to fit an arima model on a rolling window using rollapply.My aim is to plot a graph of the evolution of the coefficient, plot the error and the standard deviation. well i encountered the following problems:

1) each window in the roll apply have different set of coeffcients: basically when i plot auto.arima()$coef[1] over time it could be ar1 or ma1 or anything.The reason i am doing this is that plotting the coefficient stability permits to judge the stability of coefficient and assess the accuracy of the model.

```
getSymbols("ICICIBANK.NS")
ICICIBANK.NS<-as.data.frame(ICICIBANK.NS)
ICICIBANK.NSreturns<-c(NA,diff(log(ICICIBANK.NS$ICICIBANK.NS.Adjusted)))
z<-ICICIBANK.NS$returns
z<-na.omit(z)
y<-rollapply(as.zoo(z),width=100,FUN=function(x) auto.arima(x)$coef[1])
```

basically i am trying here to have a look at the evolution of the first coefficient.but the model changes from one window to another.

Does anyone have an idea how solve this? or maybe some lead i can work on ?

2) when i do auto.arima to log returns i get an ARIMA(0,0,0) and when i dot it for raw raw prices i get ARIMA(3,1,3):

```
getSymbols("ICICIBANK.NS");
ICICIBANK.NS<-as.data.frame(ICICIBANK.NS)
ICICIBANK.NSreturns<-c(NA,diff(log(ICICIBANK.NS$ICICIBANK.NS.Adjusted)))
auto.arima(ICICIBANK.NS$returns)

Series: ICICIBANK.NS$returns 
ARIMA(0,0,0) with zero mean     

sigma^2 estimated as 0.003309:  log likelihood=3042.76
AIC=-6083.51   AICc=-6083.51   BIC=-6077.86

auto.arima(ICICIBANK.NS$ICICIBANK.NS.Adjusted)

Series: ICICIBANK.NS$ICICIBANK.NS.Adjusted 
ARIMA(3,1,3) with drift         

Coefficients:
         ar1      ar2     ar3      ma1     ma2      ma3   drift
      0.0741  -0.0998  0.5626  -0.0572  0.0662  -0.8633  0.1087
s.e.  0.0306   0.0323  0.0279   0.0192  0.0200   0.0159  0.0606

sigma^2 estimated as 77.62:  log likelihood=-7610.48
AIC=15236.96   AICc=15237.02   BIC=15282.22
```

why would auto.arima() work with prices and not log returns ?

## Answer by WaltS (score 4)

https://quant.stackexchange.com/a/17446

There are a couple of issues with your example. First, for this ticker, there is a problem with the Yahoo price data for the period 2014-11-26 through 2014-12-03 in which the prices drop about 80% and then return to their trend line. This appears to be related to a stock split which Yahoo isn't handling properly and isn't real. Its causing part of your problem with the arima calculations. Also to get the arima results for prices and returns to agree, you need to compare the results with either both log or both not log but not mixed. For the log data, the prices model is (2,1,2) and the returns model is (2,0,2) with the same coefficients which is what you should expect. Finally, you might look at the acf plots for the returns and notice that these don't show any significant autocorrelation so you might not expect too much from the arima results for prediction purposes. If you're looking for changes in the behavior of the stock, you might start with plotting the changes in the mean over a rolling window. Code related to these comments follows:

```
library(quantmod)
library(forecast)

ICICIBANK.NS <- getSymbols("ICICIBANK.NS", auto.assign=FALSE)[,6]
ICICIBANK.NSreturns <- diff(ICICIBANK.NS, log=TRUE, na.pad=FALSE) 
big_ret <- which(abs(ICICIBANK.NSreturns)>.5)   # finds erroneously large returns at start and end of period with bad data
bad_rows <- (big_ret[1]+1):(big_ret[2])
bad_data <- ICICIBANK.NS[bad_rows]
ICICIBANK.NS  <-  ICICIBANK.NS[-bad_rows,]
ICICIBANK.NSreturns <- diff(ICICIBANK.NS, log=TRUE, na.pad=FALSE) 
ar_prices <- auto.arima(log(ICICIBANK.NS))
ar_returns <- auto.arima(ICICIBANK.NSreturns)
acf(ICICIBANK.NSreturns)
mean_returns <- rollmean(ICICIBANK.NSreturns, k=100)
plot(mean_returns)
```

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.