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

.model name clash when forecasting from components() #275

Open
gregfoletta opened this issue Sep 26, 2020 · 3 comments
Open

.model name clash when forecasting from components() #275

gregfoletta opened this issue Sep 26, 2020 · 3 comments
Labels
enhancement New feature or request

Comments

@gregfoletta
Copy link

Hi,

When forecasting off the back of a components() call, you run into an issue because there is already a '.model' column.

I ran into this when running through Chapter 8, Exercise 10 in FPP3. Of course I could be doing this in the wrong manner, so apologies for this issue if that is the case.

This is similar to #96.

Could it be that functions that generate a 'model':

a. Warn and rename the existing .model columns to something else? Or
b. Is this clash detected at the start of the function call and a suitable error thrown?

Here's an example of my code:

library(dplyr)
library(fable)
library(feasts)

tsibbledata::aus_retail %>%
    filter(`Series ID` == 'A3349606J') %>% 
    model(STL(Turnover)) %>% 
    components() %>% 
    model(ETS(season_adjust)) %>% 
    forecast(h = 12)

The errors:

Error: Failed to create output due to bad names.
* Choose another strategy with `names_repair`
Run `rlang::last_error()` to see where the error occurred.

█
├─<error/rlang_error>
│ Failed to create output due to bad names.
│ * Choose another strategy with `names_repair`
└─<error/vctrs_error_names_must_be_unique>
  Names must be unique.
Backtrace:
  1. dplyr::filter(., `Series ID` == "A3349606J")
  1. fabletools::model(., STL(Turnover))
  1. generics::components(.)
  1. fabletools::model(., ETS(season_adjust))
  9. fabletools::forecast(., h = 12)
 12. tidyr:::pivot_longer.data.frame(...)
 13. tidyr::pivot_longer_spec(...)
 19. vctrs::vec_cbind(...)
 21. vctrs:::validate_unique(names = names, arg = arg)
 22. vctrs:::stop_names_must_be_unique(names, arg)
 23. vctrs:::stop_names(...)
 24. vctrs:::stop_vctrs(class = c(class, "vctrs_error_names"), ...)
Run `rlang::last_trace()` to see the full context.
@gregfoletta
Copy link
Author

OK, so I think in my particular use-case I should have used decomposition_model() - but I think the issue still stands. Perhaps a warning is best?

@mitchelloharawild
Copy link
Member

This should be handled as a side-effect of #268, where I agree that a warning should be given in this case.

@mitchelloharawild
Copy link
Member

This approach should also consider other generated key names, such as .rep from generate().

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

No branches or pull requests

2 participants