events_to_regressors: Generates regressors from a named list of Events

Description Usage Arguments Value Examples

Description

Generates regressors from a named list of Events

Usage

1
2
events_to_regressors(events, dates, h = NULL, seasonal = T,
  time_series = NULL, K = 3)

Arguments

events

List of Event objects like the output from table_to_events().

dates

Sequence of Date objects one for each row of the regressor table.

h

Optional days to forecast for generating forecast regressors.

seasonal

If true this will generate a single seasonal component with forecast::fourier(time_series, K=K) or forecast::fourierf(time_series, K=K, h=h) if h was specified.

time_series

ts object that is the data you are trying to forecast.

K

input to forecast::fourier() and forecast::fourierf()

Value

Returns an xreg data.frame groups by event name.

Examples

1
2
3
4
5
6
7
8
regs_table <- data.frame(event=c("christmas", "christmas", "promotion"),
                         start=c("2014-12-25", "2015-12-25", "2015-11-27"),
                         end=c("2014-12-25", "2015-12-25", "2015-11-30"),
                         time_function= c("none","none","inverse"),
                         stringsAsFactors=FALSE)

events_to_regressors(table_to_events(regs_table),
                     seq(as.Date("2015-11-01"), as.Date("2016-01-01"), by = 1))

wjhrdy/foregen documentation built on May 4, 2019, 7:33 a.m.