[R] Query
Prof Brian Ripley
ripley at stats.ox.ac.uk
Wed Nov 9 12:06:02 CET 2005
On Wed, 9 Nov 2005, Armelini, Guillermo wrote:
> Dear all,
>
> My name is Guillermo I'm trying to write a short program to find all the
> possible combination in fitting an ARIMA Model. My script is the
> following:
>
> n=rnorm(100)+5
> Aux.M=matrix(NA,nrow=100,ncol=2)
> L=1
> for(i in 0:2)
> {for(j in 0:2) {for(k in 0:2)
need { here
> Aux.M[L,2]=arima(n,order=c(i,j,k),include.mean=TRUE)$aic
>
> x1=paste("AR=",i,sep=" ")
> x2=paste("I=",j,sep=" ")
> x3=paste("MA=",k,sep=" ")
> x4=paste(x1,x2,sep=" ")
> x5=paste(x4,x3,sep=" ")
>
> Aux.M[L,1]=x5
> L=L+1}}
need another } here
> After running in R, you will realize that the last for does not work. So
It does, but you did not store the resutls from it as you probably
intended.
> I have problem using three 'for command' at the same time, and I do not
> know exactly how to solve the problem. Are there any more efficient
> approach? (i.e. using a combination of while and for) Could somebody
> help me?
You have forgotten the braces for the body of the inner for() loop.
Also, 27 combinations does not need 100 rows to store.
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help
mailing list