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 exercício faz parte do curso
Forecasting Product Demand in R
Instruções do exercício
- Create a date index for the weeks of New Year's in your training data set called
n.dates. - Build an
xtsobject callednewyearusing the date indexn.dates. - Create a sequence of 154 dates from Jan. 19, 2014 (your training data time frame) called
dates_train. - Merge the
newyearobject with the training dates from the last bullet and fill all the missing values with 0's.
Exercício interativo prático
Experimente este exercício completando este código de exemplo.
# 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 = ___)