我有一个包含几个模型的 mable:
pacman::p_load(tidyverse, fable, fpp3, feasts)
retail_data |> autoplot() + facet_wrap(vars(State))
retail_train <- retail_data |> filter(year(Month) <= max(year(Month)) - 4)
ft.mod <- retail_train |> model(
drift = RW(Turnover ~ drift())
)
ft.mod
# A mable: 8 x 3
# Key: State, Industry [8]
State Industry drift
<chr> <chr> <model>
1 Australian Capital Territory Takeaway food services <RW w/ drift>
2 New South Wales Takeaway food services <RW w/ drift>
3 Northern Territory Takeaway food services <RW w/ drift>
4 Queensland Takeaway food services <RW w/ drift>
5 South Australia Takeaway food services <RW w/ drift>
6 Tasmania Takeaway food services <RW w/ drift>
7 Victoria Takeaway food services <RW w/ drift>
8 Western Australia Takeaway food services <RW w/ drift>
我可以像这样可视化单个模型的残差:
ft.mod |> filter(State == 'Victoria') |> gg_tsresiduals() # plot appears in pane
但是,如果我尝试做一个:
ft.mod |> gg_tsresiduals()
Error: gg_tsresiduals() must be used with a mable containing only one model.
我尝试使用map()
:
ft.mod |> map( ~ gg_tsresiduals(.x))
Error: gg_tsresiduals() must be used with a mable containing only one model.
如何使用 map 迭代每个模型gg_tsresiduals()
?