sw_sweep: Tidy forecast objects

View source: R/sw_sweep.R

sw_sweepR Documentation

Tidy forecast objects

Description

Tidy forecast objects

Usage

sw_sweep(x, fitted = FALSE, timetk_idx = FALSE, rename_index = "index", ...)

Arguments

x

A time-series forecast of class forecast.

fitted

Whether or not to return the fitted values (model values) in the results. FALSE by default.

timetk_idx

If timetk index (non-regularized index) is present, uses it to develop forecast. Otherwise uses default index.

rename_index

Enables the index column to be renamed.

...

Additional arguments passed to tk_make_future_timeseries()

Details

sw_sweep is designed to coerce forecast objects from the forecast package into tibble objects in a "tidy" format (long). The returned object contains both the actual values and the forecasted values including the point forecast and upper and lower confidence intervals.

The timetk_idx argument is used to modify the return format of the index.

  • If timetk_idx = FALSE, a regularized time index is always constructed. This may be in the format of numeric values (e.g. 2010.000) or the higher order yearmon and yearqtr classes from the zoo package. A higher order class is attempted to be returned.

  • If timetk_idx = TRUE and a timetk index is present, an irregular time index will be returned that combines the original time series (i.e. date or datetime) along with a computed future time series created using tk_make_future_timeseries() from the timetk package. The ... can be used to pass additional arguments to tk_make_future_timeseries() such as inspect_weekdays, skip_values, etc that can be useful in tuning the future time series sequence.

The index column name can be changed using the rename_index argument.

Value

Returns a tibble object.

See Also

tk_make_future_timeseries()

Examples

library(forecast)
library(sweep)
library(dplyr)

# ETS forecasts
USAccDeaths %>%
    ets() %>%
    forecast(level = c(80, 95, 99)) %>%
    sw_sweep()



sweep documentation built on July 9, 2023, 7:10 p.m.