ComenzarEmpieza gratis

Create holiday / promotional effect variables

We saw some notion of seasonality in the previous exercise, but let's test to make sure that something actually is there. Your bosses think that their products would be more desired around the weeks of Christmas, New Year's, and Valentine's Day. The marketing department also mentions that they have been running promotional deals the week before Mother's Day the previous 5 years. Let's create a binary indicator variable for New Year's!

Este ejercicio forma parte del curso

Forecasting Product Demand in R

Ver curso

Instrucciones del ejercicio

  • Create a date index for the weeks of New Year's in your training data set called n.dates.
  • Build an xts object called newyear using the date index n.dates.
  • Create a sequence of 154 dates from Jan. 19, 2014 (your training data time frame) called dates_train.
  • Merge the newyear object with the training dates from the last bullet and fill all the missing values with 0's.

Ejercicio interactivo práctico

Prueba este ejercicio y completa el código de muestra.

# Create date indices for New Year's week
n.dates <- as.Date(c("2014-12-28", "2015-12-27", "2016-12-25"))

# Create xts objects for New Year's
newyear <- as.xts(rep(1, 3), order.by = ___)

# Create sequence of 154 weeks for merging
dates_train <- seq(as.Date("2014-01-19"), length = ___, by = ___)

# Merge training dates into New Year's object
newyear <- ___(newyear, ___, fill = ___)
Editar y ejecutar código