forecast.hts not being called, even explicitly, with R 4.3.0

Good afternoon, I just upgraded to 4.3.0 and it seems to have caused my existing hierarchical time series forecast code to break. I confirmed that the error only shows up in 4.3.0 by running the code fine on a machine that uses 4.2.3. All packages were up to date with same versions. The error is:

Error in method == "comb" && fmethod == "rw" :
'length = 3' in coercion to 'logical(1)'
3.
forecast.gts(y, h = forecast_horizon, FUN = function(x) do.call(my_method,
list(x, lambda = "auto")))
2.
forecast(y, h = forecast_horizon, FUN = function(x) do.call(my_method,
list(x, lambda = "auto")))
1.
forecast_school(school_name, school_time_series, start_year,
freq, current_year, current_cycle_month, current_month_name,
nodes, funnel_stages)

This appears to be coming from this section of the code:

Blockquote

if (my_method == "nnetar") {
allf <- forecast(y, h = forecast_horizon, FUN = function(x) do.call(my_method, list(x, repeats = 200, lambda = "auto", P = 1, maxit = 1000, decay = 1, scale.inputs = FALSE, size = 2)))
} else if (my_method == "auto.arima") {
allf <- forecast(y, h = forecast_horizon, FUN = function(x) do.call(my_method, list(x, max.d = 1, max.D = 1)))
} else {
allf <- forecast(y, h = forecast_horizon, FUN = function(x) do.call(my_method, list(x, lambda = "auto")))
}

Blockquote

It appears that the forecast() function is calling forecast.gts() on the hts object. It is possible that some changes in R or the forecast package resulted in the forecast() function behaving differently. I then switched to explicitly calling the hts explicitly with forecast.hts.

Blockquote

if (my_method == "nnetar") {
allf <- forecast.hts(y, h = forecast_horizon, FUN = function(x) do.call(my_method, list(x, repeats = 200, lambda = "auto", P = 1, maxit = 1000, decay = 1, scale.inputs = FALSE, size = 2)))
} else if (my_method == "auto.arima") {
allf <- forecast.hts(y, h = forecast_horizon, FUN = function(x) do.call(my_method, list(x, max.d = 1, max.D = 1)))
} else {
allf <- forecast.hts(y, h = forecast_horizon, FUN = function(x) do.call(my_method, list(x, lambda = "auto")))

Blockquote

But then I got this error:
Error in forecast.hts(y, h = forecast_horizon, FUN = function(x) do.call(my_method, :
could not find function "forecast.hts"

At this point I just ran the simple code:
forecast.hts(hts(), h = 1)

And got the same error. I reinstalled hts but the problem has persisted. Any advice on how to proceed is appreciated. I can downgrade to an older version of R but this is not a long term solution.

There is no forecast.hts() function; forecast.gts() is the appropriate method for hts and gts objects. An hts object has class c("hts", "gts") so that it will call forecast.gts() as required.

Please provide a reproducible example of the problem.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.