Looking at the arima.c code related to arima fitting I noticed that the code is mainly a merge of: - Gardner, G, Harvey, A. C. and Phillips, G. D. A. (1980) Algorithm AS154. An algorithm for exact maximum likelihood estimation of autoregressive-moving average models by means of Kalman filtering. Applied Statistics 29, 311–322. - Jones, R. H. (1980) Maximum likelihood fitting of ARMA models to time series with missing observations. Technometrics 20 389–395. The first is used to fit the initial P0 matrix, and the second to do the forecasts. The AS154 implementation of P0 computation is O(r^4/8) in memory requirements, where r is roughly the period length. This is the origin of the ugly: src/library/stats/src/arima.c:838: if(r > 350) error(_("maximum supported lag is 350")); I noted on the same AS154 paper that the initial P0 verify this equation: P0 = T P0 T' + R R' So I modified the arima.c code to find iteratively the solution of this equation (starting from P0 = I) The resulting code finds a solution very similar to the one of the original code in a fraction of the occupied memory and in a time that is similar for small lags and faster for bigger lags (without the r<350 limit). Here the modified code: https://gist.github.com/911292 The question is, there are theoretical guarantees that the iterative solution is the right solution? Some hints/directions/books? Matteo Bertini [[alternative HTML version deleted]]