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

Limit scoping of accuracy.default() #912

Open
mitchelloharawild opened this issue Jul 6, 2022 · 1 comment
Open

Limit scoping of accuracy.default() #912

mitchelloharawild opened this issue Jul 6, 2022 · 1 comment

Comments

@mitchelloharawild
Copy link
Collaborator

forecast/R/errors.R

Lines 244 to 254 in 465d278

accuracy.default <- function(object, x, test = NULL, d = NULL, D = NULL, f = NULL, ...) {
if (!is.null(f)) {
warning("Using `f` as the argument for `accuracy()` is deprecated. Please use `object` instead.")
object <- f
}
if (!any(is.element(class(object), c(
"ARFIMA", "mforecast", "forecast", "ts", "integer", "numeric",
"Arima", "ets", "lm", "bats", "tbats", "nnetar", "stlm", "baggedModel"
)))) {
stop("First argument should be a forecast object or a time series.")
}

The error produced can be confusing when users encounter it from using other packages (for example: https://stackoverflow.com/questions/72873984/r-fabletools-accuracy-first-argument-should-be-a-forecast-object-or-a-time-ser).

The current error is specific to the forecast package, and doesn't generalise well - especially since the function also works for models and not just forecasts and time series.

The correct approach would be to register S3 methods for each of these classes and not export a default method. However at minimum I think that the error should be improved.

@robjhyndman
Copy link
Owner

Improved error message in 2906e97

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

2 participants