1. Learn
  2. /
  3. Courses
  4. /
  5. Forecasting Product Demand in R

Exercise

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!

Instructions

100 XP
  • 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.