[R] Forecast package, auto.arima() convergence problem, and AIC/BIC extraction

Phillip Middleton phillip.middleton at RACKSPACE.COM
Fri May 18 20:28:53 CEST 2012


Hi all, 


First:
I have a small line of code I'm applying to a variable which will be
placed in a matrix table for latex output of accuracy measures:

acc.aarima <-  signif(accuracy(forecast(auto.arima(tix_ts,
stepwise=FALSE), h=365)), digits=3).

The time series referred to is univariate (daily counts from 12-10-2010
until 5-8-2010 (so not 2 full periods of data)), and I'm working on some
initial model comparisons given what methods I can use (I will be adding
Bayesian forecasts eventually as well given the lack of history).

I am receiving an error w/r/t a convergence problem from auto.arima:

-------------------------------------------------------------------	
Warning messages:
	1: In auto.arima(y, max.P = 0, max.Q = 0, stationary = TRUE, ...) :
	Unable to fit final model using maximum likelihood. AIC value approximated
	2: In stats:::arima(x = x, order = order, seasonal = seasonal,
include.mean = include.mean,  :
	possible convergence problem: optim gave code=1
-------------------------------------------------------------------

This is telling me that the maxit setting has reached it's limit of
iterations in optim(), but how can I address this in auto.arima()?


Second: 
I wish also to include information criteria in the latex tables from each
of the resulting models. Some models (like ARIMA) keep AIC, BIC, and AICc
as list properties within 'x$model', however, others only list AIC. These
are obviously calculated in, for example 'x.naive$model' and not list
objects. Can anyone recommend a way to extract all 3 bits of information
so that I can place this in the resulting model comparison table?

Below is some code for the framework of the output. It is currently 6
models (rows) and 6 columns (measures), I want to add 3 columns for AIC,
BIC, and AICc - but I need a way to get this information for the models
and placed into the matrix before LaTeX'ing it:

===========================================================================
=====
acc.naive <- signif(accuracy(naive(tix_ts, h=365)), digits=3)
acc.snaive <-  signif(accuracy(snaive(tix_ts, h=365)), digits=3)	
acc.ets <-  signif(accuracy(forecast(ets(tix_ts), h=365)), digits=3)
acc.etsa <- signif(accuracy(forecast(ets(tix_ts,model="AAZ"), h=365)),
digits=3) 
acc.aarima <-  signif(accuracy(forecast(auto.arima(tix_ts,
stepwise=FALSE), h=365)), digits=3)
acc.arfima <-  signif(accuracy(forecast(arfima(tix_ts), h=365)), digits=3)


x <- 
matrix(c(acc.naive,acc.snaive,acc.ets,acc.etsa,acc.aarima,acc.arfima),
ncol=6, byrow=TRUE)
rownames(x) = c("Naive Model [Arima(0,1,0)]","Naive (Seasonal) Model
[Arima(0,0,0)(0,1,0)m]","ETS Model", "ETS Model(A,A,N)","ARIMA (5,1,0)
Model","ARFIMA Model")
colnames(x) = c("ME","RMSE","MAE","MPE","MAPE","MASE")



cell.format <- matrix(rep("", nrow(x) * ncol(x)), ncol = 6)



latex(x,title="MC-Tix-ModelAcc-Apr2012")
===========================================================================
======


Any thoughts would greatly be appreciated.


Phillip H. Middleton



More information about the R-help mailing list