0

I'm using example data from the Forecasting: Principles and Practice textbook chapter on VAR models here to make forecast plots using the fable package.

I'd like to be able to select a single plot from those returned by autoplot. For example, in the code below, how can I select and display the plot for Income only? I'd also like to be able to access the forecast point values and upper and lower bounds for the model with Income as the response variable.

When I try to see the results of the forecast() call, I get an "ERROR while rich displaying an object" so I can't see how to subset this object. This could be because I'm running this analysis on Deepnote (like a Jupyter notebook), I'm unsure. But perhaps filtering or selecting or subsetting in some way before or after calling forecast() will get me the data and plot I'm looking for.

library(fpp3)
fit <- us_change %>%
  model(
    aicc = VAR(vars(Consumption, Income)),
    bic = VAR(vars(Consumption, Income), ic = "bic")
  )
fit %>%
  select(aicc) %>%
  forecast() %>%
  autoplot(us_change %>% filter(year(Quarter) > 2010))

us_change autoplots

meenaparam
  • 1,949
  • 2
  • 17
  • 29
  • 1
    I suspect the issues with viewing the fable is due to running it on Deepnote - I'll investigate this (https://github.com/tidyverts/fabletools/issues/339). It is also not currently possible to plot just one response variable from a multivariate model, I'll add this when we transition to using the {ggdist} package for plotting forecast distributions (https://github.com/tidyverts/fabletools/issues/338). – Mitchell O'Hara-Wild Dec 08 '21 at 23:29
  • Thanks @MitchellO'Hara-Wild, I think you're right as I did try again in RStudio and I didn't get the same errors. Thanks also for confirming that I can't plot just one variable at the moment, as I had thought I wasn't using the API correctly to allow that to happen. I'll go back to manual plotting and will look forward to the extra functionality in future. `fabletools` is fab! – meenaparam Dec 09 '21 at 10:47

0 Answers0