# Predict sales levels with decision trees

I need to build a model using climate variables (temperature, rainfall) to predict monthly sales (horizon of 6 months) for certain product. The data has strong seasonality and a standard regression model would works fine, the problem is that the historic data will not be updated, meaning that the observed data points will not be incorporated into the model.

Whats a good way to solve this? What if i split the sales data into levels (say 'WEAK', 'NORMAL', 'HIGH', VERY HIGH') and then use a regression tree? Is there any 'danger' in doing this?

For a standard regression model, how i deal with the seasonality if the new points will not be incorporated?

I'm using R, thanks!

• What do you mean by "the historic data will not be updated"? In addition, are you sure that temperature and rainfall are more important than promotions, marketing and price changes? – Stephan Kolassa Dec 21 '12 at 16:09
• It's a 6 month forecast, so after the first month pass by the observed value (what occurred) will not be appended to the data. That's the problem: i need seasonality to take care of these variations that you mentioned. – Fernando Dec 21 '12 at 16:17

Given that you have monthly data, you can model the seasonality using dummy variables, e.g.:

foo <- data.frame(sales=rnorm(48,10,10),
month=rep(c("Jan","Feb","Mar","Apr","May","Jun",
"Jul","Aug","Sep","Oct","Nov","Dec"),4))
model <- lm(sales~month,data=foo)
predict(model,newdata=data.frame(month="Dec"))


However, a more common approach would be to use seasonal exponential smoothing. See, e.g., here.

And I think that your weather data will be completely useless: with monthly data, temperature and rainfall will be collinear with the month dummies, and weather simply varies too much within months. In particular: for a six-month ahead forecast you would need to forecast temperature and rainfall also for six months ahead, which is probably not possible to get better than "it will be June, so it will probably be warmer than today".

• That's a good point, 6 months climate forecast is too much ahead! Anyway, if a build a decision tree, should i include the months as well? – Fernando Dec 21 '12 at 18:00
• Given that you say that your data is strongly seasonal, you should definitely include month dummies if you decide to go with a regression tree. However, you really don't want to classify, you want to forecast... and a tree would not be my first choice to do so. – Stephan Kolassa Dec 21 '12 at 18:23
• You regression will always give the same results in my case: the historic data will not be updated, that's why i need predictors. Is there a problem(regarding forecast performance) if i build a model with seasonal dummy + predictors? thanks – Fernando Dec 21 '12 at 18:36
• A regression will work just fine with causal predictors. You will just need to be careful that you don't over-parameterize your model if you only have a short history. – Stephan Kolassa Dec 21 '12 at 18:42
• But what kind of test i can perform to choose between only seasonal OR seasonal + predictors? – Fernando Dec 21 '12 at 18:51