# Incorporating seasonality into CART models

The problem I am trying to solve it predicting sales for an item for the next $n$ weeks.

Obviously, seasonality is a major factor for such predictions. If we use a time series based model, then we generally produce a raw forecast and multiply the raw forecast by the seasonality indices.

If we use CART to produce such forecasts, then how to we incorporate such seasonality factors into the model? Can they be new variables for the model?

There are a couple ways to interpret seasonality in your questions and the solution varies accordingly.

1. You can add a categorical dummy variable to control and capture the effect of seasonality. Let's say you have 4 seasons (Q1, Q2, Q3, and Q4). Then you need to add a dummy variable where the values of the dummy represent the season associated with the measurement period. This is the most straightforward solution and is typical of estimates sales with seasonality. (Note that in a typical linear regression only 3 dummies would be required -- each dummy would represent the incremental sales vs. the baseline with no dummies so all 4 states are captured.)

2. If your time-series exhibits seasonality following an auto-regressive process (as interpreted in the comments above), you can create an autoregressive process not using CART. However, you would miss on the ability of CART to discriminate the population using other predictors. My suggestion here would be to add a new continuous independent variable which is the lag of the prior period's sales. I would normalize your sales growth so you are dealing with stationary series (perhaps log of sales divided by log of sales from the prior period if the series exhibits exponential growth).

3. A third solution would be to add "time dummies". This would mean adding date as a variable to the model. You must have a strong understanding of the relationship between time and your dependent variable if you elect this unconventional approach however. If you add a continuous time-variable then CART will identify if there are changes in the functional form of the sales dependent variable over different periods of time.

Predictive models http://en.wikipedia.org/wiki/Predictive_analytics include CART ( requires cross-sectional i.e. time independent data ) and TIME SERIES which exploits the information content available from correlated and auto-correlated data. It sounds to me "The problem I am trying to solve it predicting sales for an item for the next n weeks." that you need to be focusing on ARMAX Models incorporating wherever possible predictor series(X). You might pursue http://en.wikipedia.org/wiki/Autoregressive_moving_average_model.