Week 3 ETS Models

Demetri Chokshi-Fox

I pulled payroll data from the ST. Louis FRED from the last decade, non seasonally adjusted.

library(forecast)
## Warning: package 'forecast' was built under R version 3.5.3
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 3.5.3
library(readxl)
## Warning: package 'readxl' was built under R version 3.5.3
Nonfarm_payroll_non_seasonally_adj = as.data.frame(read_excel("C:/Users/Demetri/Downloads/Nonfarm payroll non seasonally adj.xls"))
## New names:
## * `` -> ...4
payrolldata = ts(Nonfarm_payroll_non_seasonally_adj[,2], start = c(2009, 6), end = c(2019, 6), frequency = 12)
autoplot(payrolldata)

Exponential Smoothing

fc1 = ses(payrolldata, h=6)
autoplot(fc1) + autolayer(fitted(fc1), series="Fitted") + ylab("Total Nonfarm Payrolls") + xlab("Year")

Holt-Winters Seasonal Trend

fc2 = hw(payrolldata, seasonal = "additive")
fc3 = hw(payrolldata, seasonal = "multiplicative")
autoplot(payrolldata) + autolayer(fc2, series="HW additive forecasts", PI=FALSE) +
  autolayer(fc3, series="HW multiplicative forecasts", PI=FALSE) +
  xlab("Year") +
  ylab("Total Nonfarm Payrolls") +
  ggtitle("Total US Nonfarm Payrolls") +
  guides(colour=guide_legend(title="Forecast"))

ETS Forecast

fc4 = ets(payrolldata, model = "ZZZ")
fc4 %>% forecast(h=6) %>% autoplot()

### Comparisons

summary(fc1)
## 
## Forecast method: Simple exponential smoothing
## 
## Model Information:
## Simple exponential smoothing 
## 
## Call:
##  ses(y = payrolldata, h = 6) 
## 
##   Smoothing parameters:
##     alpha = 0.9999 
## 
##   Initial states:
##     l = 131950.3653 
## 
##   sigma:  1120.251
## 
##      AIC     AICc      BIC 
## 2283.430 2283.636 2291.818 
## 
## Error measures:
##                    ME     RMSE      MAE     MPE      MAPE     MASE
## Training set 168.2529 1110.954 872.8625 0.11536 0.6291998 0.392445
##                    ACF1
## Training set 0.05767136
## 
## Forecasts:
##          Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95
## Jul 2019       152306.9 150871.3 153742.6 150111.3 154502.6
## Aug 2019       152306.9 150276.7 154337.2 149202.0 155411.9
## Sep 2019       152306.9 149820.5 154793.4 148504.2 156109.7
## Oct 2019       152306.9 149435.8 155178.0 147916.0 156697.9
## Nov 2019       152306.9 149097.0 155516.9 147397.7 157216.2
## Dec 2019       152306.9 148790.6 155823.3 146929.2 157684.7
summary(fc2)
## 
## Forecast method: Holt-Winters' additive method
## 
## Model Information:
## Holt-Winters' additive method 
## 
## Call:
##  hw(y = payrolldata, seasonal = "additive") 
## 
##   Smoothing parameters:
##     alpha = 0.9574 
##     beta  = 0.0542 
##     gamma = 0.0024 
## 
##   Initial states:
##     l = 129983.338 
##     b = 158.4382 
##     s = 715.4336 44.5601 -862.9382 -1515.997 -2210.469 837.3239
##            1235.532 953.2517 184.7078 -173.7604 -293.3689 1085.726
## 
##   sigma:  175.2466
## 
##      AIC     AICc      BIC 
## 1847.348 1853.290 1894.877 
## 
## Error measures:
##                    ME     RMSE      MAE         MPE       MAPE       MASE
## Training set 5.160776 163.2494 122.5643 0.003693694 0.08903825 0.05510574
##                      ACF1
## Training set -0.007951161
## 
## Forecasts:
##          Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95
## Jul 2019       151114.1 150889.5 151338.7 150770.6 151457.5
## Aug 2019       151424.8 151105.3 151744.2 150936.2 151913.3
## Sep 2019       151976.4 151577.2 152375.6 151365.9 152586.9
## Oct 2019       152937.0 152465.1 153408.8 152215.3 153658.6
## Nov 2019       153410.2 152869.7 153950.8 152583.6 154236.9
## Dec 2019       153206.2 152599.3 153813.0 152278.0 154134.3
## Jan 2020       150350.2 149678.4 151022.0 149322.8 151377.6
## Feb 2020       151237.1 150501.3 151972.9 150111.8 152362.4
## Mar 2020       152081.9 151282.5 152881.3 150859.3 153304.4
## Apr 2020       153181.9 152319.1 154044.7 151862.4 154501.4
## May 2020       154045.3 153119.1 154971.4 152628.8 155461.7
## Jun 2020       154608.8 153619.0 155598.5 153095.1 156122.4
## Jul 2020       153421.6 152367.8 154475.3 151810.0 155033.2
## Aug 2020       153732.3 152614.4 154850.2 152022.6 155442.0
## Sep 2020       154283.9 153101.4 155466.4 152475.4 156092.4
## Oct 2020       155244.5 153996.9 156492.1 153336.5 157152.5
## Nov 2020       155717.8 154404.6 157030.9 153709.4 157726.1
## Dec 2020       155513.7 154134.4 156893.0 153404.2 157623.2
## Jan 2021       152657.7 151211.7 154103.8 150446.2 154869.3
## Feb 2021       153544.6 152031.3 155058.0 151230.1 155859.1
## Mar 2021       154389.4 152808.1 155970.7 151971.0 156807.8
## Apr 2021       155489.4 153839.5 157139.3 152966.1 158012.7
## May 2021       156352.8 154633.7 158071.9 153723.7 158981.9
## Jun 2021       156916.3 155127.3 158705.2 154180.3 159652.2
summary(fc3)
## 
## Forecast method: Holt-Winters' multiplicative method
## 
## Model Information:
## Holt-Winters' multiplicative method 
## 
## Call:
##  hw(y = payrolldata, seasonal = "multiplicative") 
## 
##   Smoothing parameters:
##     alpha = 0.7201 
##     beta  = 0.0792 
##     gamma = 0.0321 
## 
##   Initial states:
##     l = 129960.8202 
##     b = 142.3643 
##     s = 1.0053 1.0001 0.9939 0.9893 0.9843 1.0059
##            1.0087 1.0068 1.001 0.9986 0.9985 1.0078
## 
##   sigma:  0.0014
## 
##      AIC     AICc      BIC 
## 1879.677 1885.618 1927.205 
## 
## Error measures:
##                    ME     RMSE      MAE         MPE       MAPE      MASE
## Training set 2.722386 181.1236 136.1738 0.002185978 0.09911656 0.0612247
##                   ACF1
## Training set 0.2431852
## 
## Forecasts:
##          Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95
## Jul 2019       151024.1 150745.5 151302.6 150598.1 151450.0
## Aug 2019       151243.9 150887.0 151600.8 150698.1 151789.8
## Sep 2019       151768.7 151334.6 152202.8 151104.8 152432.6
## Oct 2019       152798.7 152285.5 153311.8 152013.8 153583.5
## Nov 2019       153243.2 152651.6 153834.8 152338.4 154147.9
## Dec 2019       152997.5 152329.0 153666.0 151975.1 154019.9
## Jan 2020       149866.4 149134.0 150598.9 148746.3 150986.6
## Feb 2020       150805.9 149989.3 151622.5 149557.0 152054.8
## Mar 2020       151669.9 150767.0 152572.8 150289.0 153050.8
## Apr 2020       152800.2 151806.6 153793.8 151280.6 154319.8
## May 2020       153744.7 152658.8 154830.6 152083.9 155405.4
## Jun 2020       154328.0 153149.8 155506.2 152526.0 156130.0
## Jul 2020       153038.3 151777.3 154299.2 151109.8 154966.7
## Aug 2020       153258.8 151905.3 154612.4 151188.8 155328.9
## Sep 2020       153788.3 152337.3 155239.4 151569.2 156007.5
## Oct 2020       154829.8 153273.8 156385.8 152450.1 157209.5
## Nov 2020       155278.0 153620.4 156935.6 152742.9 157813.1
## Dec 2020       155026.8 153273.2 156780.3 152345.0 157708.5
## Jan 2021       151852.0 150036.2 153667.7 149075.0 154629.0
## Feb 2021       152801.7 150874.2 154729.2 149853.8 155749.5
## Mar 2021       153674.9 151633.9 155715.9 150553.5 156796.4
## Apr 2021       154817.9 152656.9 156978.9 151513.0 158122.8
## May 2021       155772.6 153491.4 158053.9 152283.7 159261.5
## Jun 2021       156361.4 153962.6 158760.2 152692.8 160030.0
summary(fc4)
## ETS(A,A,A) 
## 
## Call:
##  ets(y = payrolldata, model = "ZZZ") 
## 
##   Smoothing parameters:
##     alpha = 0.9574 
##     beta  = 0.0542 
##     gamma = 0.0024 
## 
##   Initial states:
##     l = 129983.338 
##     b = 158.4382 
##     s = 715.4336 44.5601 -862.9382 -1515.997 -2210.469 837.3239
##            1235.532 953.2517 184.7078 -173.7604 -293.3689 1085.726
## 
##   sigma:  175.2466
## 
##      AIC     AICc      BIC 
## 1847.348 1853.290 1894.877 
## 
## Training set error measures:
##                    ME     RMSE      MAE         MPE       MAPE       MASE
## Training set 5.160776 163.2494 122.5643 0.003693694 0.08903825 0.05510574
##                      ACF1
## Training set -0.007951161

:

Looks like Holt Winters Additive and my ETS function tied for AIC comparisons, most likely because they were essentially the same thing.

. .