[R] very slow code execution

salah maadawy @@|@hm@@d@wy @end|ng |rom gm@||@com
Wed Feb 6 13:03:04 CET 2019


i am a beginner regarding R but i am trying to do a simple thing, but it is
taking too much time and i am asking if there is any way to achieve what i
need, i have a time series data set with 730 data points, i detected 7, 354
and 365 seasonality periods. i am trying to use Fourier terms for
seasonality and for loop to get the K value for each while minimizing AICc,
my code is

    AICc<- data.table(matrix(nrow = 96642, ncol = 4))for (i in 1:3) {
  for (j in 1:177) {
    for (k in 182) {                     #i,j and k values are choosen
with regad that K cannot exceed seasonality period/2
      z1 <- fourier(ts(demand,frequency = 7), K=i)
      z2 <- fourier(ts(demand,frequency=354), K=j)
      z3 <- fourier(ts(demand,frequency = 365),K=k)
      fit <- auto.arima(demand, xreg =cbind(z1,z2,z3),
         seasonal = FALSE)
      fit$aicc
      AICc[,1]<-i
      AICc[,2]<-j
      AICc[,3]<-k
      AICc[,4]<-fit$aicc
    }

  }
}
  AICc

i have created a data table to store AICc values from all possible i,j,k
combinations so that i can find later the minimum AICc value. the problem
now is that it is taking forever to do so not only to iterate all
combinations but also due to the large K values.

, is there any possible solution for this? thank you in advance

	[[alternative HTML version deleted]]



More information about the R-help mailing list