tidyverts / tidyverts/fabletools
Modeling an empty tsibble (with key) should not error
Open
@mitchelloharawild is already working on this.
Since May 7, 2021.
bug
- Dominant language
- R
- Stars
- 98
- Forks
- 37
- PR merge metrics
- No merged PRs in 30d
Description
In batch processing consistency is king. Sometimes we might apply filter on a dataset and remove all the data. Still calling model on such a tsibble should, in my opinion, not produce an error but return an empty mable. This allows us to write simple and consistent pipelines without unnecessary error checking.
This works:
> tsibble(i = 1:12, quantity = 1, index = "i") %>% filter(i > 1) %>% model(x = MEAN(quantity))
# A mable: 1 x 1
x
<model>
1 <MEAN>
> tsibble(i = 1:12, quantity = 1, index = "i") %>% filter(i > 12) %>% model(x = MEAN(quantity))
# A mable: 1 x 1
x
<model>
1 <NULL model>
Warning message:
1 error encountered for x
[1] All observations are missing, a model cannot be estimated without data.
but having a tsibble with key fails:
tsibble(i = 1:12, k = 1, quantity = 1, index = "i", key = "k") %>% filter(i > 12) %>% model(x = MEAN(quantity))
Error in `[[.default`(mdl, 1) : subscript out of bounds
>
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.