[R] predict and arima

Jose-Marcio Martins da Cruz Jose-Marcio.Martins at mines-paristech.fr
Tue Feb 8 18:40:25 CET 2011


I think ther's a bug here :

bdp wrote:
>
> Some code I have been playing with to do this follows ...
>
> get.best.arima<- function(x.ts, minord=c(0,0,0,0,0,0),
> maxord=c(2,1,1,2,1,1))
> {
> 	# function based on 'Introductory Time Series with R'
> 	best.aic<- 1e8 # a big number
> 	n<- length(x.ts)
> 	for(p in minord[1]:maxord[1]) for(d in minord[2]:maxord[2]) for(q in
> minord[3]:maxord[3])
> 	{
> 		for(P in minord[4]:maxord[4]) for(D in minord[5]:maxord[5]) for(Q in
> minord[6]:maxord[6])
> 		{
> 			fit<- arima(x.ts, order=c(p,q,d), seas=list(order=c(P,D,Q),

maybe it should be :

  			fit<- arima(x.ts, order=c(p,d,q), seas=list(order=c(P,D,Q),

exchange q and d !

> 				frequency(x.ts)), method='CSS')
> 			fit.aic<- -2 * fit$loglik + (log(n) + 1) * length(fit$coef)
> 			if(fit.aic<  best.aic) # probably should  do other tests here before
> accepting
> 			{
> 				best.aic<- fit.aic
> 				best.fit<- fit
> 				best.model<- c(p,d,q,P,D,Q)
> 			}
> 		}
> 	}
> 	#print(best.aic)
> 	#print(best.model)
> 	return(best.fit)
> }

...



More information about the R-help mailing list