Se cargan los datos
library(readxl)
Table_IMAE <- read_excel("C:/Users/SANCHEZ/Desktop/GABRIEL2021/Universidad/Ciclo V/Econometria/Table_IMAE.xlsx",
sheet = "Hoja1", col_types = c("skip",
"numeric"), skip = 5)
names(Table_IMAE)<-c("IMAE")
Se convierte en serie temporal
Table_IMAE.ts<-ts(data = Table_IMAE$IMAE,start = c(2019,1),frequency = 12) |> print()
## Jan Feb Mar Apr May Jun Jul Aug Sep Oct
## 2019 107.83 106.07 112.65 109.70 114.75 114.66 111.05 113.16 111.80 108.84
## 2020 109.05 109.55 103.92 87.43 89.84 96.18 97.82 103.72 107.63 105.61
## 2021 107.19 107.58 113.34 110.63 115.79 117.57 112.28 115.19 114.58 111.55
## 2022 110.98 112.08 120.22 112.86 121.77 119.19 115.94 120.09 117.75 115.39
## 2023 114.63 114.24 125.03 116.47 128.29 126.58 121.44 122.39 118.13 116.64
## 2024 120.22
## Nov Dec
## 2019 116.81 122.66
## 2020 111.45 120.52
## 2021 118.60 126.27
## 2022 121.54 129.59
## 2023 128.23 133.66
## 2024
Calculo de Pronóstico modelo Holt-Winters
library(forecast)
## Registered S3 method overwritten by 'quantmod':
## method from
## as.zoo.data.frame zoo
#Estimar el modelo
ModeloHW<-HoltWinters(x = Table_IMAE.ts,
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 = Table_IMAE.ts, seasonal = "multiplicative", optim.start = c(0.9, 0.9, 0.9))
##
## Smoothing parameters:
## alpha: 1
## beta : 0
## gamma: 0
##
## Coefficients:
## [,1]
## a 115.6959521
## b -0.9824213
## s1 1.0532405
## s2 1.0045275
## s3 0.8476272
## s4 0.8739906
## s5 0.9384891
## s6 0.9978989
## s7 1.0150932
## s8 1.0048430
## s9 0.9895984
## s10 1.0811708
## s11 1.1544178
## s12 1.0391029
#Generar el pronóstico:
PronosticosHW<-forecast(object = ModeloHW,h = 5,level = c(0.98))
PronosticosHW
## Point Forecast Lo 98 Hi 98
## Feb 2024 120.82094 105.35674 136.2851
## Mar 2024 114.24603 92.87611 135.6159
## Apr 2024 95.56886 71.81392 119.3238
## May 2024 97.68267 68.71568 126.6497
## Jun 2024 103.96943 69.23267 138.7062
#GrÔfico de la serie original y del pronóstico.
PronosticosHW %>% autoplot()
Segun el modelo Holt-Winters se espera una caĆda constante hasta mayo, a lo que en junio le seguriria un rebote
Calculo de forma automatica modelo SARIMA
library(forecast)
library(TSstudio)
IMAE.arima.automatico<-auto.arima(y = Table_IMAE.ts)
summary(IMAE.arima.automatico)
## Series: Table_IMAE.ts
## ARIMA(0,1,1)(1,0,0)[12]
##
## Coefficients:
## ma1 sar1
## 0.3623 0.8440
## s.e. 0.1552 0.0585
##
## sigma^2 = 17.31: log likelihood = -177.2
## AIC=360.4 AICc=360.82 BIC=366.68
##
## Training set error measures:
## ME RMSE MAE MPE MAPE MASE
## Training set 0.06770115 4.056577 3.1059 0.006669302 2.776455 0.4312283
## ACF1
## Training set -0.05881266
Pronostico automatico
library(forecast)
#tabla
pronostico.arima.automatico<-forecast(object = IMAE.arima.automatico,h = 5,level = c(.98)) |> print()
## Point Forecast Lo 98 Hi 98
## Feb 2024 120.0607 110.3827 129.7387
## Mar 2024 129.1674 112.8123 145.5224
## Apr 2024 121.9428 100.9354 142.9502
## May 2024 131.9188 107.1169 156.7206
## Jun 2024 130.4755 102.3872 158.5639
#Grafico
IMAE.arima.automatico |> forecast(h = 5,level = c(.98)) |> autoplot()
Con el modelo SARIMA se espera un crecimiento en el IMAE para junio del 2024