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)
}

...

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to