Starting off as a muggle that naïve to the Math's and Data Science world.

Day 58

Smoothing Techniques (Con’t)

Regression on seasonality and trend

Linear RegressionVSTrend Component
Multi-Linear RegressionVS / to handleSeasonality Component

Using dummy encoding to handle season. 3 dummy to handle quarterly, 11 dummy to handle monthly.


Excel

1. Raw Data; Predict Year 6.

SeasonYear 1Year 2Year 3Year 4Year 5
Fall34973726398942484443
Winter34843589387041054307
Spring35523742399642634466
Summer38374050432745444795

2. Transform into tall format.

3. Create row number and name it as “Slope”.

4. Create Dummy Encoding to all the season.


5. Check if Excel solver is enable.


6. Open Regression dialog.


7. Setup accordingly.


8. Excel produce regression result, but we only interested to highlighted red.


9. Fill-up earlier formula.


10. Make prediction.


11. Result.


R

seasonaldummy(data)  create dummy encoding

imported_sales_dummy <- seasonaldummy(imported_sales)

Result:


Next, create row number

imported_sales_time <- 1:length(imported_sales)

tslm(data)  create [T]ime [S]eries [L]inear [M]odel

imported_sales_reg <- tslm(imported_sales~imported_sales_time+imported_sales_dummy)

Result:


Plot chart

plot(imported_sales, ylab='Sales')
lines(imported_sales_reg$fitted.values, col=2, lwd=2)
legend("topleft",
c("Actual","Linear Reg."),
col=1:2,
lwd=2,
cex=1)



Winter’s Exponential Smoothing

Extension of Holts Method, by introducing beta parameter.

  • alpha = level smoothing constant
  • beta = trend smoothing constant
  • gamma = seasonality smoothing constant

ps. this has additive and multiplicative hyperparameter as well.


Excel

1. Raw Data; Predict Year 4 with condition of:
alpha = 0.1
beta = 0.3
gamma = 0.4


2. Calculate initial year level smoothing.


3. Calculate initial year trend smoothing.


4. Calculate initial year seasonal smoothing.


5. You should achieve following result.


6. Continue on subsequent years for level smoothing.


7. Continue on subsequent years for trend smoothing.


8. Continue on subsequent years for seasonal smoothing.


9. You should achieve following result.


10. Creating the forecast column.


11. You should achieve following result.


12. Make prediction.


13. Result.

Leave a comment