Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

auto.arima runtime stepwise increase #877

Open
Someone894 opened this issue Feb 16, 2021 · 0 comments
Open

auto.arima runtime stepwise increase #877

Someone894 opened this issue Feb 16, 2021 · 0 comments

Comments

@Someone894
Copy link

Hello,

some time ago the runtime of the forecast we are using doubled from one (monthly) execution to the next. So I've wrote a small test script to analyze how the execution time of some of the forecasting method performs with different length timeseries:

start <- 1
end <- 100

# FROM: https://github.com/robjhyndman/M4metalearning/blob/61ddc7101680e9df7219c359587d0b509d2b50d6/R/forec_methods_list.R#L40
auto_arima_forec <- function(x, h) {
  model <- forecast::auto.arima(x, stepwise = FALSE, approximation = FALSE)
  forecast::forecast(model, h = h)$mean
}

generate_random_ts <- function(a = 1:1000, b = 0, c = 7) {
  sin(a * rnorm(1, b, c)) +
	sin(a * rnorm(1, b^2, c^2)) +
	sin(a * rnorm(1, b^3, c^3)) +
	sin(a * rnorm(1, b^4, c^4)) +
	seq(a) / runif(a, 1, 10)
}

set.seed(4711)
truex <- generate_random_ts()
#plot(truex, type = "l")

timeseries <- list()
for (i in start:end) {
  x <- ts(head(truex, i), frequency = 12)
  timeseries <- rlist::list.append(timeseries, x)
}

jobs <- lapply(
  timeseries[1:length(timeseries)],
  function(x) {
	local({
	  x <- x
	  bquote(auto_arima_forec(.(x), 24))
	})
  }
)

names(jobs) <- paste0(
  "Length ts: ",
  stringr::str_pad(start:end, 3, pad = "0")
)

mbm <- microbenchmark::microbenchmark(list = jobs)

save(mbm, file = "mbm.RData")

options(microbenchmark.unit = "eps")
print(mbm)

options(microbenchmark.unit = "relative")
print(mbm)

plot <- ggplot2::autoplot(mbm)
print(plot)

Most of them just (more or less) linearly increase in runtime for longer timeseries, which is to be expected. But the auto.arima method seems to be exploding (4-5 times more execution time) when the timeseries becomes longer then 71 month (=6 Years).

ARIMA_Plot_1-100_lin

Do you know why this is the case and is it possible to decrease the magnitude of this sudden jump?

In order to keep this Issue short I only posted code and image for the auto.arima case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant