Suavização exponencial simples

set.seed(1234)
series <- ts(runif(100,10,15), start = c(1915,1),frequency = 1)
ts.plot(series)
library(forecast)

fit.SES <- HoltWinters(series, beta = FALSE, gamma = FALSE)
fit.SES
## Holt-Winters exponential smoothing without trend and without seasonal component.
## 
## Call:
## HoltWinters(x = series, beta = FALSE, gamma = FALSE)
## 
## Smoothing parameters:
##  alpha: 0.1016823
##  beta : FALSE
##  gamma: FALSE
## 
## Coefficients:
##       [,1]
## a 11.92001
plot(fit.SES)

previ <- forecast(fit.SES, h=10,level = 95)
previ
##      Point Forecast    Lo 95    Hi 95
## 2015       11.92001 8.965780 14.87425
## 2016       11.92001 8.950546 14.88948
## 2017       11.92001 8.935391 14.90464
## 2018       11.92001 8.920312 14.91972
## 2019       11.92001 8.905309 14.93472
## 2020       11.92001 8.890380 14.94965
## 2021       11.92001 8.875524 14.96450
## 2022       11.92001 8.860740 14.97929
## 2023       11.92001 8.846028 14.99400
## 2024       11.92001 8.831385 15.00864
plot(previ)

Suavização Exponencial de Holt

dados <- read.csv2("https://raw.githubusercontent.com/pedrocostaferreira/timeseries/master/cap2-HW/consumo_energia_eletrica_regiao_sudeste.csv")
dados <- dados[-457,]

consumo <- ts(dados[,2],start=c(1979,1),frequency=12)
plot(consumo,xlab='Tempo',ylab='Consumo de Energia Elétrica (Gwh)',main='')

ajuste_holt <- HoltWinters(consumo,gamma = FALSE);ajuste_holt
## Holt-Winters exponential smoothing with trend and without seasonal component.
## 
## Call:
## HoltWinters(x = consumo, gamma = FALSE)
## 
## Smoothing parameters:
##  alpha: 0.7367828
##  beta : 0.01110493
##  gamma: FALSE
## 
## Coefficients:
##          [,1]
## a 19202.56505
## b    17.58094
plot(ajuste_holt,xlab='Tempo',ylab='Valores Observados/Ajustados',main='')

Suavização Exponencial de Holt Winters

ajuste_holtw <- HoltWinters(x = consumo);ajuste_holtw
## Holt-Winters exponential smoothing with trend and additive seasonal component.
## 
## Call:
## HoltWinters(x = consumo)
## 
## Smoothing parameters:
##  alpha: 0.6975629
##  beta : 0.001216222
##  gamma: 0.3547657
## 
## Coefficients:
##             [,1]
## a   19138.119383
## b      40.110258
## s1     -6.035901
## s2    -12.471712
## s3    -42.762197
## s4     96.244169
## s5   -427.089599
## s6   -646.417265
## s7   -697.674593
## s8   -170.322733
## s9    130.295680
## s10   311.046092
## s11   450.594555
## s12   -25.103967
prev_holtw <- forecast(ajuste_holtw, h = 12, level = 95)
plot(prev_holtw)

accuracy(prev_holtw)
##                     ME     RMSE      MAE        MPE     MAPE      MASE
## Training set -21.82465 410.9315 299.1083 -0.2415531 2.414338 0.4478681
##                   ACF1
## Training set 0.0298473