I am working on a time-series project in which I am forecasting the daily activity of something (let's call it 'Y') based on three years of historical data. I know that Y is affected by calendar effects such as Holidays (e.g., it will go down on Christmas). When I analyze the data, I want to account for the calendar effects.

It is clear-cut how to create dummy variables for Holidays (e.g., 1 for Xmas and 0 for the remainder of days). It is less clear, however, how to create variables that account for the lead and lag effects of different calendar days. This is particularly important because a few of my days of interest (days that are not normal holidays but of interest to my study) are likely to have significant lead AND/OR lag effects. For example, activity should start increasing over the course of 30 days (30 is a simple estimate based on visual examination of the data) up to a particular calendar day of interest and for another calendar day of interest, activity should go up on that day and then remain up for a few weeks after, then slowly coming back down.

In this context, I have two questions. One, is there a good statistical approach that I can use to determine what the lag and lead impact is of certain calendar days (i.e., how many days around the calendar day of interest appear to be impacted by that calendar day)? Any particularly open-source package in either python or R?

Second, what should variables that incorporate lead and lag effects look like? For example, would a variable with a lead effect that builds up then drops off look like this: [0, 0, 0, 0, 1, 2, 3, 4 5, 6, 0, 0, 0]?

In my first go-around with these data, I used a GBM with variables encoding holiday/calendar effects. For the calendar days that have substantial lead and lag impacts (impacts identified through visual examination and domain knowledge), I just created a variable that has days until that calendar day (e.g., [4, 3, 2, 1, 0, 365, 364, 363, etc.]. This model works fairly well but I think that I can improve it by improving how my variables represent calendar effects.

Thanks a bunch for any responses.


Create a predictor variable (zeroes except a 1 at the beginning of the exceptional period and then specify a poylynomial of order k where k is the expected length. This will form the long response that you are looking for. Make sure that you also accommodate individually tailored windows of response around each major event and level shifts or local time trends.

| cite | improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.