PIB real trimestral desestacionalizado
library(forecast)
## Warning: package 'forecast' was built under R version 3.6.3
## Registered S3 method overwritten by 'xts':
## method from
## as.zoo.xts zoo
## Registered S3 method overwritten by 'quantmod':
## method from
## as.zoo.data.frame zoo
#Modelo sin restricciones
m_PIB<-auto.arima(PIB$PIB)
summary(m_PIB)
## Series: PIB$PIB
## ARIMA(0,1,0) with drift
##
## Coefficients:
## drift
## 3088.6068
## s.e. 280.8908
##
## sigma^2 estimated as 4814312: log likelihood=-546.24
## AIC=1096.49 AICc=1096.7 BIC=1100.68
##
## Training set error measures:
## ME RMSE MAE MPE MAPE MASE
## Training set 1.284436 2157.885 1475.564 -0.07309312 0.8729784 0.4424969
## ACF1
## Training set -0.06440184
#Modelo sin drift
m_PIB2<-auto.arima(PIB$PIB,allowdrift=FALSE)
summary(m_PIB2)
## Series: PIB$PIB
## ARIMA(2,1,0)
##
## Coefficients:
## ar1 ar2
## 0.3216 0.5000
## s.e. 0.1310 0.1328
##
## sigma^2 estimated as 6188158: log likelihood=-553.82
## AIC=1113.64 AICc=1114.06 BIC=1119.92
##
## Training set error measures:
## ME RMSE MAE MPE MAPE MASE ACF1
## Training set 465.8613 2425.659 1650.831 0.3424838 1.026997 0.4950566 -0.1187033
Tasa de desempleo promedio trimestral desestacionalizada
m_TD<-auto.arima(TD$TD)
summary(m_TD)
## Series: TD$TD
## ARIMA(0,1,5)
##
## Coefficients:
## ma1 ma2 ma3 ma4 ma5
## -0.0351 0.2424 0.1028 -0.3887 0.1900
## s.e. 0.1245 0.1098 0.1198 0.1023 0.1234
##
## sigma^2 estimated as 0.17: log likelihood=-38.51
## AIC=89.03 AICc=90.25 BIC=103.01
##
## Training set error measures:
## ME RMSE MAE MPE MAPE MASE
## Training set -0.04996637 0.3958958 0.2898513 -0.4190405 2.496315 0.8574606
## ACF1
## Training set -0.00364443
DTF promedio trimestral
#la serie viene por defecto mensual, la convertimos en formato xts
library(xts)
## Loading required package: zoo
##
## Attaching package: 'zoo'
## The following objects are masked from 'package:base':
##
## as.Date, as.Date.numeric
DTF_xts<-xts(DTF, order.by = DTF$mes)
#eliminamos la columna de mes
DTF_xts<-DTF_xts[,-1]
#Generamos la serie trimestral
DTF_Q<-to.period(DTF_xts,period="quarters",OHLC = FALSE)
DTF_mq<-DTF_Q[,1]
DTF_mq<-data.frame(DTF_mq)
#Ahora sĂ generamos el modelo
m_DTF<-auto.arima(DTF_mq)
summary(m_DTF)
## Series: DTF_mq
## ARIMA(2,1,4)
##
## Coefficients:
## ar1 ar2 ma1 ma2 ma3 ma4
## -0.2932 0.6621 0.6135 -0.4951 -0.4547 -0.2422
## s.e. 0.1391 0.1310 0.1526 0.1639 0.0886 0.0940
##
## sigma^2 estimated as 55.44: log likelihood=-466.74
## AIC=947.48 AICc=948.35 BIC=967.92
##
## Training set error measures:
## ME RMSE MAE MPE MAPE MASE
## Training set -0.9724365 7.254774 4.922157 -12.38908 20.18791 0.9444475
## ACF1
## Training set -0.02212227
Y asĂ sucesivamente con las otras bases de datos
Realice pronĂ³sticos de las variables de arriba por tres periodos y muestre un grĂ¡fico con las bandas de pronĂ³stico
# PronĂ³stico PIB
f_PIB<-forecast(m_PIB,h=3)
plot(f_PIB)
f_PIB2<-forecast(m_PIB2,h=3)
plot(f_PIB2)
# PronĂ³stico Desempleo
f_TD<-forecast(m_TD,h=3)
plot(f_TD)
# PronĂ³stico DTF
f_DTF<-forecast(m_DTF,h=3)
plot(f_DTF)