Skip to content
Prev 378487 / 398502 Next

very slow code execution

With 96k model fits it's going to be slow, so you might want to think
first about whether you need to do them all. Beyond that, I think this
is more in the R style, so might be quicker (I don't know how much the
loops are slowing you down), and even if not it should be easier to
adapt.

The other thing to think about is parallelising the code - the
parallel package should help.

FitModel <- function(K, data) {
  z1 <- fourier(ts(data,frequency = 7), K=K["i"])
  z2 <- fourier(ts(data,frequency=354), K=K["j"])
  z3 <- fourier(ts(data,,frequency = 365),K=K["k"])
  fit <- auto.arima(data,, xreg =cbind(z1,z2,z3), seasonal = FALSE)
  fit$aicc
}

# smaller MaxOrders used so if you run it like this, it won't take 5 hours
MaxOrders <- expand.grid(i = 1:3, j=1=7, k=1:8)
AICc <- apply(MaxOrders, FitModel, data=demand)

Bob

      AICc<- data.table(matrix(nrow = 96642, ncol = 4))for (i in 1:3) {

        
On Thu, 7 Feb 2019 at 13:44, salah maadawy <salahmaadawy at gmail.com> wrote: