get_forecasts() extracts the true out-of-sample forecasts from an object previously fitted with get_models().

get_forecasts(.tbl, ...)

# S3 method for default
get_forecasts(.tbl, ...)

# S3 method for tbl_df
get_forecasts(.tbl, ...)

Arguments

.tbl

A tidy tibble of the tbl_time class.

...

Additional parameters to be passed to forecast.

Value

A tidy tibble.

See also

Examples

library(YahooTickers)
library(dplyr)
#> 
#> Attaching package: ‘dplyr’
#> The following objects are masked from ‘package:stats’:
#> 
#>     filter, lag
#> The following objects are masked from ‘package:base’:
#> 
#>     intersect, setdiff, setequal, union
library(forecast)

# Download and forecast time series using the "auto.arima"
# function from the forecast package
get_tickers(dow) %>%
  slice(1:2) %>%
  get_stocks(., periodicity = "monthly") %>%
  get_returns(., tickers, log, TRUE, adjusted) %>%
  get_models(., tickers, adjusted, 100, 1, FALSE, auto.arima,
             seasonal = FALSE, stationary = TRUE) %>%
  get_forecasts(.) # h = 1 because .assess = 1
#> # A tibble: 86 × 8
#>    date       tickers adjusted point_forecast   lo.80   lo.95  hi.80 hi.95
#>    <date>     <fct>      <dbl>          <dbl>   <dbl>   <dbl>  <dbl> <dbl>
#>  1 2018-06-01 MMM      0.00423         0.0110 -0.0514 -0.0844 0.0734 0.106
#>  2 2018-07-01 MMM      0.0763          0.0111 -0.0513 -0.0843 0.0735 0.106
#>  3 2018-08-01 MMM     -0.00662         0.0114 -0.0514 -0.0846 0.0741 0.107
#>  4 2018-09-01 MMM      0.00568         0.0107 -0.0518 -0.0848 0.0732 0.106
#>  5 2018-10-01 MMM     -0.102           0.0119 -0.0486 -0.0806 0.0723 0.104
#>  6 2018-11-01 MMM      0.0888          0.0109 -0.0513 -0.0842 0.0730 0.106
#>  7 2018-12-01 MMM     -0.0805          0.0109 -0.0514 -0.0844 0.0733 0.106
#>  8 2019-01-01 MMM      0.0500          0.0110 -0.0512 -0.0842 0.0732 0.106
#>  9 2019-02-01 MMM      0.0348          0.0104 -0.0508 -0.0832 0.0717 0.104
#> 10 2019-03-01 MMM      0.00877         0.0111 -0.0500 -0.0824 0.0722 0.105
#> # … with 76 more rows