library(readxl)
library(forecast)
IVAE <- read_excel("REBE UNIVERSIDAD/ECONOMETRIA/ECONOMETRIA/ejericios/IVAE.xlsx")
col_types = c("skip", "numeric")
skip = 0
IVAE.ts <- ts(data = IVAE,
start = c(2009, 1),
frequency = 12)
Yt<- IVAE.ts
library(forecast)
#Estimar el modelo
ModeloHW<-HoltWinters(x = Yt,
seasonal = "multiplicative",
optim.start = c(0.9,0.9,0.9))
ModeloHW
Holt-Winters exponential smoothing with trend and multiplicative seasonal component.
Call: HoltWinters(x = Yt, seasonal = “multiplicative”, optim.start = c(0.9, 0.9, 0.9))
Smoothing parameters: alpha: 0.8408163 beta : 0 gamma: 1
Coefficients: [,1] a 117.0799442 b 0.1600306 s1 0.9502255 s2 1.0233274 s3 1.0518154 s4 0.9900276 s5 1.0007537 s6 0.9807088 s7 0.9600206 s8 1.0149628 s9 1.0915423 s10 0.9796752 s11 0.9584676 s12 0.9994880
#Generar el pronóstico:
PronosticosHW<-forecast(object = ModeloHW,h = 12,level = c(0.95))
PronosticosHW
Point Forecast Lo 95 Hi 95
Apr 2021 111.4044 105.94952 116.8593 May 2021 120.1386 112.77972 127.4976 Jun 2021 123.6515 114.83356 132.4694 Jul 2021 116.5461 107.01096 126.0813 Aug 2021 117.9689 107.30373 128.6341 Sep 2021 115.7630 104.33417 127.1918 Oct 2021 113.4746 101.36814 125.5810 Nov 2021 120.1312 106.57272 133.6897 Dec 2021 129.3698 114.12877 144.6109 Jan 2022 116.2681 101.78191 130.7543 Feb 2022 113.9046 98.99575 128.8134 Mar 2022 118.9394 81.61739 156.2614
#Gráfico de la serie original y del pronóstico.
PronosticosHW %>% autoplot()
library(forecast)
#Generar el pronóstico:
PronosticosHW2<-hw(y = Yt,
h = 12,
level = c(0.95),
seasonal = "multiplicative",
initial = "optimal")
PronosticosHW2
Point Forecast Lo 95 Hi 95
Apr 2021 107.4928 99.59377 115.3918 May 2021 115.3370 106.85846 123.8155 Jun 2021 115.6946 107.18632 124.2029 Jul 2021 109.6301 101.56399 117.6962 Aug 2021 112.2047 103.94477 120.4646 Sep 2021 110.2284 102.10923 118.3476 Oct 2021 107.9393 99.98348 115.8951 Nov 2021 114.4306 105.99022 122.8710 Dec 2021 122.6459 113.59234 131.6994 Jan 2022 108.5830 100.56060 116.6054 Feb 2022 107.1239 99.20182 115.0460 Mar 2022 113.1678 104.79016 121.5455
#Gráfico de la serie original y del pronóstico.
PronosticosHW2 %>% autoplot()