Below I am forecasting for the next 30 days . If the input data is around 100k the for loop is extremely slow (takes about 2 hours) . the code using the for loop as below.
ns<-ncol(TS) # count number of columns to run the loop
output<-matrix(NA,nrow=30,ncol=ns)
for (i in 2:ns)
{
output[,i]<- forecast(auto.arima(TS[,i],allowmean = T,D=1),h=30 )$mean
i=i+1
}
I have tried using lapply as below but the run time remains the same.
lapply(TS, function(x) forecast(auto.arima(x,allowmean = T,D=1),h=30 ))
Is there an alternate function/method I can use to improve the performance?