Tema VI: Modelos ARIMA de Box&Jenkins - Lab 2

Curso: Series Cronológicas

Autor/a
Afiliación

Shu Wei Chou Chen

Escuela de Estadística, UCR

1 librerías

library(ggplot2)
library(forecast)
library(fpp2)
library(astsa)
library(car)
library(TSA)
library(tseries)
library(sarima)
library(BETS)

2 Ejemplos simulados

2.1 SARMA puro

set.seed(1000)
TT<- 150 
# TT<- 500 (prueben con varios tamaños)

2.1.1 \(SAR(1)_{12}\)

x1 <- sim_sarima(n=TT,model=list(sar=0.8, nseasons=12, sigma2 = 1))
ts.plot(x1)

acf2(x1,max.lag=50)

      [,1] [,2]  [,3] [,4] [,5] [,6]  [,7] [,8]  [,9] [,10] [,11] [,12] [,13]
ACF  -0.05 0.01 -0.06 0.16 0.07 0.06 -0.02 0.13 -0.01  0.05 -0.11  0.66  0.06
PACF -0.05 0.01 -0.06 0.15 0.09 0.07  0.01 0.11 -0.02  0.02 -0.11  0.65  0.12
     [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25]
ACF   0.05 -0.06  0.09  0.10  0.10 -0.05  0.11 -0.01  0.07 -0.05  0.36  0.08
PACF  0.07  0.07 -0.06 -0.02  0.02 -0.01  0.05 -0.02 -0.01  0.12 -0.11 -0.02
     [,26] [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36] [,37]
ACF   0.11 -0.06  0.03  0.00  0.15 -0.03  0.09 -0.06  0.03  0.01  0.19  0.04
PACF  0.08 -0.09 -0.04 -0.16  0.03  0.01 -0.02 -0.02 -0.06 -0.02 -0.05 -0.04
     [,38] [,39] [,40] [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48] [,49]
ACF   0.12 -0.01 -0.01 -0.05  0.13 -0.01  0.02 -0.09 -0.01  0.01  0.09 -0.02
PACF  0.00  0.08 -0.05  0.06 -0.01 -0.05 -0.10 -0.07  0.00 -0.10 -0.03 -0.01
     [,50]
ACF   0.03
PACF -0.14
#las raíces del polinomio autoregresivo.
raices<-polyroot(c(1,rep(0,11), -0.8))
modulo.raices<-Mod(polyroot(c(1,rep(0,11), -0.8)))
modulo.raices>1
 [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE

2.1.2 \(SMA(1)_4\)

x2 <- sim_sarima(n=TT,model=list(sma=0.8, nseasons=4, sigma2 = 1))  
ts.plot(x2)

acf2(x2,max.lag=30)

     [,1]  [,2] [,3] [,4]  [,5]  [,6]  [,7]  [,8] [,9] [,10] [,11] [,12] [,13]
ACF  0.13 -0.12 0.04 0.52  0.07 -0.17 -0.03  0.01 0.00 -0.16 -0.02  0.03  0.06
PACF 0.13 -0.14 0.08 0.51 -0.07 -0.11 -0.03 -0.38 0.05 -0.04  0.06  0.32  0.07
     [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25]
ACF  -0.01  0.01  0.13  0.12  0.06 -0.01  0.09  0.05 -0.10 -0.05  0.01 -0.04
PACF  0.10 -0.03 -0.13  0.02 -0.07  0.01  0.13 -0.06 -0.11  0.01 -0.09  0.00
     [,26] [,27] [,28] [,29] [,30]
ACF  -0.22 -0.03 -0.05 -0.06 -0.18
PACF -0.08  0.07 -0.09 -0.06 -0.09

2.1.3 \(SARMA(1,1)_7\)

x3 <- sim_sarima(n=TT,model=list(sar=0.6,sma=0.8, nseasons=7, sigma2 = 1))  
ts.plot(x3)

acf2(x3,max.lag=30)

      [,1]  [,2] [,3] [,4]  [,5]  [,6] [,7]  [,8]  [,9] [,10] [,11] [,12] [,13]
ACF  -0.06 -0.09 0.02 0.04 -0.12 -0.08 0.85 -0.04 -0.11 -0.02  0.03 -0.18 -0.13
PACF -0.06 -0.09 0.01 0.03 -0.11 -0.09 0.84  0.01 -0.17 -0.11 -0.05 -0.16 -0.09
     [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25]
ACF   0.62 -0.02 -0.16 -0.07  0.01 -0.25 -0.14  0.49  0.00 -0.19 -0.09 -0.01
PACF -0.31 -0.01 -0.05 -0.04 -0.05 -0.07  0.06  0.25  0.05 -0.01 -0.02 -0.06
     [,26] [,27] [,28] [,29] [,30]
ACF  -0.27 -0.11  0.40  0.03 -0.18
PACF -0.01  0.06 -0.08 -0.07 -0.04

2.2 SARMA mixto

TT<- 500 

2.2.1 \(SARMA(0,0,1)(1,0,0)_{12}\)

x1 <- sim_sarima(n=TT,model=list(ma=-.5,sar=0.8, nseasons=12, sigma2 = 1))
ts.plot(x1)

acf2(x1,max.lag=50)

     [,1]  [,2]  [,3]  [,4] [,5]  [,6]  [,7]  [,8] [,9] [,10] [,11] [,12] [,13]
ACF  -0.4 -0.13  0.05  0.01 0.07 -0.17  0.07  0.02 0.04 -0.10 -0.34  0.80 -0.32
PACF -0.4 -0.33 -0.20 -0.12 0.03 -0.15 -0.07 -0.06 0.03 -0.08 -0.57  0.58  0.20
     [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25]
ACF  -0.12  0.04  0.01  0.09 -0.19  0.10  0.00  0.04 -0.06 -0.32  0.66 -0.26
PACF  0.12  0.00 -0.04  0.04 -0.06  0.04 -0.06 -0.01  0.04 -0.06  0.01 -0.01
     [,26] [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36] [,37]
ACF  -0.13  0.05 -0.02  0.10 -0.18  0.13 -0.04  0.03  0.00 -0.31  0.57 -0.24
PACF -0.05  0.01 -0.05 -0.06 -0.02  0.08 -0.02 -0.05  0.03 -0.03  0.07 -0.06
     [,38] [,39] [,40] [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48] [,49]
ACF  -0.10  0.07 -0.03  0.07 -0.15  0.15 -0.05  0.01  0.05 -0.28  0.47 -0.22
PACF  0.03  0.05  0.06 -0.05 -0.02  0.01  0.04  0.00  0.05  0.08  0.01  0.01
     [,50]
ACF  -0.06
PACF  0.04

2.2.2 \(SARMA(1,0,0)(0,0,1)_{12}\)

x2 <- sim_sarima(n=TT,model=list(ar=-.5,sma=0.8, nseasons=12, sigma2 = 1))
ts.plot(x2)

acf2(x2,max.lag=50)

      [,1] [,2]  [,3] [,4]  [,5] [,6]  [,7] [,8]  [,9] [,10] [,11] [,12] [,13]
ACF  -0.49 0.27 -0.15 0.14 -0.09 0.10 -0.09 0.13 -0.12  0.15 -0.24  0.49 -0.29
PACF -0.49 0.05  0.00 0.07  0.00 0.05 -0.02 0.08 -0.03  0.07 -0.17  0.39  0.14
     [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25]
ACF   0.20 -0.16  0.11 -0.05  0.07 -0.06  0.08 -0.10  0.06 -0.04  0.03 -0.05
PACF  0.01 -0.06 -0.04  0.04  0.03  0.01 -0.03 -0.04 -0.07  0.10 -0.23 -0.08
     [,26] [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36] [,37]
ACF   0.05 -0.06  0.00  0.01  0.00 -0.01  0.02 -0.06  0.03 -0.01  0.00  0.01
PACF -0.02  0.04 -0.06 -0.03 -0.02  0.00  0.03 -0.02  0.01 -0.05  0.14  0.07
     [,38] [,39] [,40] [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48] [,49]
ACF   0.00  0.00 -0.06  0.05 -0.05  0.03 -0.03  0.01 -0.03  0.03 -0.07  0.06
PACF  0.04 -0.02 -0.03  0.02 -0.01 -0.01 -0.04  0.03 -0.03  0.05 -0.18 -0.06
     [,50]
ACF   0.00
PACF  0.07

2.2.2.1 \(SARMA(1,0,1)(1,0,0)_{12}\)

x3 <- sim_sarima(n=TT,model=list(ar=.7,ma=0.4,sar=0.9, nseasons=12, sigma2 = 1))
ts.plot(x3)

acf2(x3,max.lag=50)

     [,1]  [,2] [,3]  [,4]  [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
ACF  0.74  0.44 0.28  0.19  0.11 0.08 0.09 0.16 0.23  0.35  0.61  0.85  0.62
PACF 0.74 -0.23 0.13 -0.04 -0.04 0.07 0.03 0.16 0.07  0.26  0.54  0.55 -0.73
     [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25]
ACF   0.35  0.22  0.14  0.06  0.03  0.04  0.10  0.16  0.26  0.50  0.73  0.53
PACF  0.20  0.00  0.03 -0.09  0.01 -0.02  0.01  0.06  0.03  0.02 -0.07 -0.04
     [,26] [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36] [,37]
ACF   0.28  0.15  0.09  0.01 -0.03 -0.03  0.03  0.09  0.17  0.38  0.60  0.41
PACF  0.01 -0.06 -0.03  0.00 -0.03  0.03 -0.03 -0.03 -0.05 -0.02 -0.01 -0.01
     [,38] [,39] [,40] [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48] [,49]
ACF   0.18  0.07  0.02 -0.04 -0.07 -0.06 -0.01  0.04  0.11  0.29  0.49  0.34
PACF -0.03  0.06 -0.01  0.04  0.03  0.00 -0.03  0.01 -0.03  0.01  0.04  0.00
     [,50]
ACF   0.12
PACF -0.02

Observe la diferencia con el modelo \(SARMA(12,0,1)(0,0,0)_12\)

try(
x3a <- arima.sim(n = TT, model = list(order = c(12,0,0), 
                                      ar = c(0.7,rep(0,10),0.9)),sd=1,rand.gen= rnorm) + m
)
Error in arima.sim(n = TT, model = list(order = c(12, 0, 0), ar = c(0.7,  : 
  'ar' part of model is not stationary
coef<-c(1,-0.7,rep(0,10),-0.9)
modulo.raices<-Mod(polyroot(coef))
modulo.raices>1
 [1] FALSE  TRUE  TRUE FALSE  TRUE  TRUE  TRUE FALSE  TRUE  TRUE FALSE FALSE
all(modulo.raices>1)
[1] FALSE

devolviendo al ej 3: resolviendo \((1-\phi B)(1-\Phi B^{12})\)

coef<-c(1,-0.7,rep(0,10),-0.9,(-0.7*-0.9))
modulo.raices<-Mod(polyroot(coef))
modulo.raices>1
 [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
all(modulo.raices>1)
[1] TRUE

2.2.3 \(SARIMA(1,0,1)(0,0,1)_{12}\)

x4 <- sim_sarima(n=TT,model=list(ar=.7,ma=0.4,sma=0.9, nseasons=12, sigma2 = 1))
ts.plot(x4)

acf2(x4,max.lag=50)

     [,1]  [,2] [,3]  [,4] [,5]  [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
ACF  0.79  0.55 0.45  0.39 0.37  0.34 0.32 0.30 0.30  0.29  0.38  0.46  0.36
PACF 0.79 -0.17 0.21 -0.01 0.13 -0.02 0.07 0.03 0.05  0.03  0.32  0.04 -0.29
     [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25]
ACF   0.25  0.20  0.14  0.11  0.07  0.04  0.04  0.03 -0.01 -0.03 -0.05 -0.05
PACF  0.07 -0.08 -0.06 -0.07 -0.01 -0.06  0.01 -0.01 -0.11 -0.13 -0.10  0.24
     [,26] [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36] [,37]
ACF  -0.03 -0.02 -0.03 -0.03 -0.02 -0.06 -0.08 -0.07 -0.08 -0.08 -0.09 -0.09
PACF -0.05  0.05  0.03  0.08  0.02 -0.10  0.03  0.01  0.01  0.12  0.03 -0.18
     [,38] [,39] [,40] [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48] [,49]
ACF  -0.09 -0.10 -0.10 -0.07 -0.05 -0.06 -0.07 -0.09 -0.11 -0.11 -0.12 -0.13
PACF  0.00 -0.05 -0.01 -0.02 -0.03  0.07 -0.04 -0.04 -0.07 -0.07 -0.07  0.09
     [,50]
ACF  -0.14
PACF -0.02

2.2.4 \(SARIMA(1,0,1)(1,0,1)_{12}\)

x4 <- sim_sarima(n=TT,model=list(ar=.7,ma=0.4,sar=-0.5,sma=0.9, nseasons=12, sigma2 = 1))
ts.plot(x4)

acf2(x4,max.lag=50)

     [,1]  [,2] [,3]  [,4] [,5]  [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
ACF  0.79  0.53 0.36  0.23 0.13  0.05 0.00 0.00 0.02  0.07  0.16  0.25  0.25
PACF 0.79 -0.28 0.15 -0.13 0.02 -0.05 0.02 0.06 0.03  0.09  0.17  0.06 -0.14
     [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25]
ACF   0.19  0.11  0.06  0.04  0.02 -0.02 -0.05 -0.06 -0.08 -0.10 -0.11 -0.06
PACF  0.00 -0.08  0.04  0.07 -0.07  0.02 -0.06 -0.01 -0.05 -0.12 -0.01  0.16
     [,26] [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36] [,37]
ACF  -0.02 -0.03 -0.06 -0.07 -0.08 -0.06 -0.04 -0.01  0.01  0.02  0.05  0.09
PACF -0.07  0.01 -0.07 -0.06  0.04  0.03  0.03  0.07 -0.02  0.11  0.04 -0.02
     [,38] [,39] [,40] [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48] [,49]
ACF   0.09  0.06  0.02 -0.04 -0.08 -0.09 -0.09 -0.08 -0.07 -0.06 -0.06 -0.03
PACF -0.06 -0.04  0.00 -0.01 -0.02  0.01 -0.05  0.00 -0.02 -0.10 -0.05  0.09
     [,50]
ACF  -0.02
PACF -0.10

2.2.5 \(SARIMA(1,1,0)(0,1,1)_{12}\)

x5 <- sim_sarima(n=TT, model = list(ar=0.7,iorder=1, siorder=1,sma=0.4,
                                    nseasons=12, sigma2 = 1))
ts.plot(x5)

acf2(x5,max.lag=50)

     [,1]  [,2] [,3] [,4] [,5] [,6]  [,7]  [,8] [,9] [,10] [,11] [,12] [,13]
ACF  0.99  0.99 0.98 0.97 0.97 0.96  0.95  0.95 0.94  0.93  0.93  0.92  0.91
PACF 0.99 -0.01 0.00 0.00 0.00 0.00 -0.01 -0.01 0.00  0.00 -0.01 -0.01 -0.01
     [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25]
ACF   0.91   0.9  0.89  0.88  0.88  0.87  0.86  0.86  0.85  0.84  0.84  0.83
PACF -0.01   0.0  0.00  0.00  0.00 -0.01 -0.01  0.00  0.00 -0.01 -0.01 -0.01
     [,26] [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36] [,37]
ACF   0.82  0.82  0.81   0.8   0.8  0.79  0.78  0.77  0.77  0.76  0.75  0.75
PACF -0.01  0.00  0.00   0.0   0.0 -0.01 -0.01  0.00  0.00 -0.01 -0.01 -0.01
     [,38] [,39] [,40] [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48] [,49]
ACF   0.74  0.73  0.73  0.72  0.71  0.70  0.70  0.69  0.68  0.68  0.67  0.66
PACF -0.01  0.00  0.00  0.00  0.00 -0.01 -0.01  0.00  0.00 -0.01 -0.01 -0.01
     [,50]
ACF   0.66
PACF -0.01
x5<-x5[-c(1:14)]
ts.plot(x5)

acf2(x5,max.lag=50)

     [,1]  [,2] [,3] [,4] [,5] [,6] [,7]  [,8] [,9] [,10] [,11] [,12] [,13]
ACF  0.99  0.99 0.98 0.97 0.97 0.96 0.95  0.94 0.94  0.93  0.92  0.92  0.91
PACF 0.99 -0.01 0.00 0.00 0.00 0.00 0.00 -0.01 0.00  0.00 -0.01 -0.01 -0.01
     [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25]
ACF   0.90   0.9  0.89  0.88  0.87  0.87  0.86  0.85  0.85  0.84  0.83  0.83
PACF -0.01   0.0  0.00  0.00  0.00  0.00 -0.01  0.00  0.00 -0.01 -0.01 -0.01
     [,26] [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36] [,37]
ACF   0.82  0.81   0.8   0.8  0.79  0.78  0.78  0.77  0.76  0.75  0.75  0.74
PACF -0.01  0.00   0.0   0.0  0.00 -0.01 -0.01  0.00  0.00 -0.01 -0.01 -0.01
     [,38] [,39] [,40] [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48] [,49]
ACF   0.73  0.73  0.72  0.71   0.7   0.7  0.69  0.68  0.68  0.67  0.66  0.66
PACF -0.01  0.00  0.00  0.00   0.0   0.0 -0.01  0.00  0.00 -0.01 -0.01 -0.01
     [,50]
ACF   0.65
PACF -0.01
diff.x5 <- diff(x5,lag=1)
ts.plot(diff.x5)

acf2(diff.x5,max.lag=150)

     [,1]  [,2] [,3]  [,4] [,5] [,6]  [,7]  [,8] [,9] [,10] [,11] [,12] [,13]
ACF  0.45  0.10 0.14  0.02 0.20 0.44  0.21  0.03 0.14  0.09  0.42  0.96  0.43
PACF 0.45 -0.13 0.20 -0.16 0.36 0.22 -0.10 -0.05 0.17 -0.03  0.55  0.90 -0.61
     [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25]
ACF   0.08  0.12  0.00  0.17  0.42  0.21  0.03  0.14  0.07  0.37  0.90   0.4
PACF  0.07 -0.21 -0.01 -0.07 -0.01  0.08  0.07 -0.11  0.01 -0.09 -0.11   0.1
     [,26] [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36] [,37]
ACF   0.05  0.09 -0.03  0.13  0.40  0.21  0.03  0.13  0.06  0.34  0.85  0.38
PACF -0.06  0.12  0.00 -0.05  0.04 -0.04  0.03  0.02  0.06  0.02  0.01 -0.02
     [,38] [,39] [,40] [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48] [,49]
ACF   0.03  0.07 -0.05  0.09  0.37  0.20  0.02  0.12  0.04  0.30  0.80  0.35
PACF -0.08 -0.02 -0.13 -0.05  0.01 -0.02  0.03  0.03  0.00  0.01 -0.04 -0.01
     [,50] [,51] [,52] [,53] [,54] [,55] [,56] [,57] [,58] [,59] [,60] [,61]
ACF      0  0.04 -0.08  0.05  0.33  0.18  0.00  0.10  0.02  0.26  0.75  0.33
PACF     0  0.03 -0.01  0.00 -0.06 -0.02 -0.07  0.02  0.00 -0.02  0.01  0.02
     [,62] [,63] [,64] [,65] [,66] [,67] [,68] [,69] [,70] [,71] [,72] [,73]
ACF  -0.02  0.02 -0.10  0.01  0.30  0.16 -0.01  0.08  0.00  0.22  0.69  0.29
PACF -0.01  0.01  0.02 -0.03  0.01 -0.06 -0.01 -0.02  0.02 -0.03  0.01  0.02
     [,74] [,75] [,76] [,77] [,78] [,79] [,80] [,81] [,82] [,83] [,84] [,85]
ACF  -0.05  0.00 -0.12 -0.02  0.27  0.15 -0.03  0.06 -0.02  0.18  0.63  0.26
PACF  0.00 -0.03  0.05 -0.05  0.02 -0.01  0.00 -0.02  0.00  0.03 -0.05 -0.03
     [,86] [,87] [,88] [,89] [,90] [,91] [,92] [,93] [,94] [,95] [,96] [,97]
ACF  -0.08 -0.03 -0.15 -0.06  0.24  0.12 -0.04  0.04 -0.04  0.14  0.57  0.23
PACF  0.01 -0.04  0.01 -0.05  0.00  0.01  0.01  0.01  0.02  0.02 -0.02  0.04
     [,98] [,99] [,100] [,101] [,102] [,103] [,104] [,105] [,106] [,107] [,108]
ACF  -0.11 -0.06  -0.17  -0.10   0.20   0.11  -0.06   0.02  -0.05   0.11   0.52
PACF -0.04  0.01  -0.01   0.01   0.02  -0.01   0.01  -0.03   0.00  -0.01  -0.01
     [,109] [,110] [,111] [,112] [,113] [,114] [,115] [,116] [,117] [,118]
ACF    0.21  -0.13  -0.08  -0.18  -0.12   0.18   0.09  -0.07   0.00  -0.07
PACF   0.01  -0.01   0.03   0.01   0.01   0.00  -0.01  -0.03  -0.03   0.00
     [,119] [,120] [,121] [,122] [,123] [,124] [,125] [,126] [,127] [,128]
ACF    0.08   0.48   0.18  -0.15  -0.09  -0.18  -0.14   0.16   0.08  -0.08
PACF   0.03   0.01   0.02   0.05   0.03   0.00   0.03  -0.02   0.02   0.00
     [,129] [,130] [,131] [,132] [,133] [,134] [,135] [,136] [,137] [,138]
ACF   -0.01  -0.08   0.06   0.44   0.17  -0.16  -0.10  -0.18  -0.15   0.15
PACF   0.01  -0.03   0.05  -0.01   0.05   0.06   0.02   0.03  -0.03  -0.03
     [,139] [,140] [,141] [,142] [,143] [,144] [,145] [,146] [,147] [,148]
ACF    0.09  -0.07  -0.02  -0.09   0.04   0.40   0.15  -0.16  -0.11  -0.18
PACF   0.03  -0.02  -0.04  -0.04  -0.02  -0.04  -0.02   0.00  -0.02   0.04
     [,149] [,150]
ACF   -0.16   0.13
PACF   0.01  -0.05
sdiff.diff.x5 <- diff(diff.x5,lag=12)
acf2(sdiff.diff.x5,max.lag=50)

     [,1] [,2] [,3]  [,4] [,5] [,6] [,7]  [,8] [,9] [,10] [,11] [,12] [,13]
ACF  0.67 0.46 0.33  0.21 0.13 0.10 0.08  0.05 0.08  0.11  0.17  0.31  0.21
PACF 0.67 0.02 0.02 -0.05 0.00 0.03 0.01 -0.02 0.08  0.04  0.12  0.25 -0.25
     [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25]
ACF   0.16  0.14  0.12  0.13  0.12  0.09  0.00  0.00 -0.07 -0.09 -0.07 -0.06
PACF  0.03  0.01  0.04  0.07 -0.01 -0.06 -0.08  0.03 -0.13 -0.02 -0.08  0.09
     [,26] [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36] [,37]
ACF  -0.02  0.01  0.06  0.14  0.17  0.16  0.12  0.08  0.02  0.00  0.00 -0.02
PACF  0.05  0.01  0.04  0.08  0.02  0.00  0.04 -0.10  0.06  0.02  0.02 -0.01
     [,38] [,39] [,40] [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48] [,49]
ACF  -0.03 -0.06 -0.08 -0.05  0.01  0.02  0.05  0.03  0.01  0.03  0.01 -0.06
PACF -0.07 -0.05 -0.04  0.01  0.03 -0.01  0.02 -0.03 -0.02  0.01 -0.06 -0.10
     [,50]
ACF  -0.11
PACF -0.02

3 Ejemplos reales

3.1 Serie mensual del número de turistas que ingresaron a Costa Rica

turistas<-read.csv("turistas.csv",sep=";")
y<-ts(turistas$turistas,start=c(1991,1),frequency=12)

Transformacion logarítmica

w<-log(y)
autoplot(y) 

autoplot(w)

acf2(w)

     [,1]  [,2] [,3] [,4] [,5] [,6] [,7]  [,8] [,9] [,10] [,11] [,12] [,13]
ACF  0.78  0.48 0.35 0.37 0.39 0.37 0.34  0.28 0.25  0.35  0.58  0.71  0.53
PACF 0.78 -0.34 0.33 0.10 0.05 0.05 0.07 -0.09 0.12  0.32  0.46  0.00 -0.44
     [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25]
ACF   0.27  0.15  0.18  0.20  0.17  0.13  0.09  0.07  0.15  0.36  0.48  0.33
PACF -0.09 -0.10 -0.04 -0.04  0.02  0.04  0.03 -0.08  0.04  0.09  0.05 -0.10
     [,26] [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36] [,37]
ACF   0.11  0.01  0.04  0.06  0.02 -0.01 -0.05 -0.07  0.01  0.20  0.30  0.18
PACF  0.06 -0.11 -0.02 -0.02 -0.05  0.06 -0.06  0.02 -0.01  0.01  0.01 -0.02
     [,38] [,39] [,40] [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48]
ACF   0.00 -0.07 -0.04 -0.01 -0.05 -0.09 -0.12 -0.12 -0.03  0.13  0.22
PACF  0.06  0.02 -0.05  0.03 -0.05 -0.01  0.03  0.05 -0.02  0.02 -0.02
diffw<-diff(w)
autoplot(diffw)

acf2(diffw,max.lag=80)

     [,1]  [,2]  [,3]  [,4]  [,5]  [,6] [,7]  [,8]  [,9] [,10] [,11] [,12]
ACF  0.26 -0.39 -0.39 -0.07  0.11  0.08 0.05 -0.12 -0.35 -0.35  0.27  0.84
PACF 0.26 -0.49 -0.16 -0.11 -0.12 -0.08 0.01 -0.24 -0.41 -0.61 -0.18  0.51
     [,13] [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24]
ACF   0.25 -0.36 -0.37 -0.05  0.12  0.08  0.01  -0.1 -0.33 -0.30  0.24  0.73
PACF -0.02  0.09  0.11 -0.07 -0.07 -0.10 -0.10   0.1 -0.06  0.07 -0.07  0.03
     [,25] [,26] [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36]
ACF   0.23 -0.30 -0.33 -0.05  0.14  0.05  0.01 -0.11 -0.28 -0.26  0.22  0.64
PACF -0.13  0.03  0.00 -0.04  0.05 -0.06  0.06 -0.06  0.00  0.00 -0.01  0.05
     [,37] [,38] [,39] [,40] [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48]
ACF   0.18 -0.26 -0.29 -0.02  0.13  0.06 -0.02 -0.11 -0.25 -0.22  0.21  0.54
PACF -0.09 -0.01  0.02 -0.01  0.02  0.09 -0.05  0.03 -0.04  0.01 -0.01  0.00
     [,49] [,50] [,51] [,52] [,53] [,54] [,55] [,56] [,57] [,58] [,59] [,60]
ACF   0.16 -0.25 -0.21 -0.01  0.12  0.04 -0.03 -0.09 -0.22 -0.18  0.17  0.46
PACF  0.00 -0.04  0.09 -0.03 -0.01 -0.02 -0.03  0.03  0.01  0.04  0.00 -0.05
     [,61] [,62] [,63] [,64] [,65] [,66] [,67] [,68] [,69] [,70] [,71] [,72]
ACF   0.11 -0.20 -0.17  0.00  0.12  0.03 -0.03 -0.08 -0.18 -0.15  0.15  0.36
PACF -0.06 -0.02 -0.05 -0.05  0.06  0.01 -0.02  0.02 -0.02  0.04  0.02 -0.06
     [,73] [,74] [,75] [,76] [,77] [,78] [,79] [,80]
ACF   0.08 -0.16 -0.14  0.02   0.1  0.01 -0.04 -0.04
PACF  0.04  0.01 -0.04  0.06  -0.1 -0.02 -0.02 -0.04
sdif.diffw<-diff(diffw,lag=12)
autoplot(sdif.diffw)

acf2(sdif.diffw)

      [,1]  [,2]  [,3]  [,4]  [,5]  [,6] [,7]  [,8] [,9] [,10] [,11] [,12]
ACF  -0.41  0.06 -0.12 -0.01 -0.09  0.01 0.16 -0.12 0.20 -0.19   0.2 -0.37
PACF -0.41 -0.13 -0.18 -0.16 -0.22 -0.20 0.05 -0.09 0.14 -0.03   0.2 -0.21
     [,13] [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24]
ACF   0.20 -0.01  0.06  0.05 -0.15  0.08 -0.15  0.22 -0.23  0.26 -0.12 -0.10
PACF -0.02  0.04  0.07  0.10 -0.12 -0.04 -0.06  0.09 -0.09  0.06  0.06 -0.29
     [,25] [,26] [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36]
ACF   0.06  0.01 -0.02 -0.08  0.25 -0.25  0.15 -0.14  0.15 -0.17  0.18  0.05
PACF -0.05  0.04 -0.04 -0.10  0.01 -0.11 -0.04  0.00  0.06 -0.06  0.16  0.06
     [,37] [,38] [,39] [,40] [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48]
ACF  -0.17  0.08 -0.14  0.17 -0.12  0.16 -0.11  0.04  0.00 -0.03  0.01 -0.06
PACF -0.02  0.06 -0.05  0.03  0.08 -0.02  0.02 -0.05  0.06  0.01  0.05 -0.06

Ahora los correlogramas muestran estacionariedad.

3.1.1 Identificación de los modelos apropiados.

3.1.1.1 \(SARIMA(0,1,1)(0,1,1)_{12}\)

mod0a = Arima(sdif.diffw, order=c(0,0,1),
              seasonal=list(order=c(0,0,1),period=12))
summary(mod0a)
Series: sdif.diffw 
ARIMA(0,0,1)(0,0,1)[12] with non-zero mean 

Coefficients:
          ma1     sma1     mean
      -0.4695  -0.6359  -0.0009
s.e.   0.1176   0.1022   0.0013

sigma^2 = 0.002902:  log likelihood = 159.03
AIC=-310.06   AICc=-309.66   BIC=-299.37

Training set error measures:
                       ME       RMSE       MAE      MPE     MAPE      MASE
Training set -0.001489383 0.05310953 0.0437748 210.1104 279.9025 0.4613427
                   ACF1
Training set 0.04385499
checkresiduals(mod0a,lag=20)


    Ljung-Box test

data:  Residuals from ARIMA(0,0,1)(0,0,1)[12] with non-zero mean
Q* = 19.671, df = 18, p-value = 0.3516

Model df: 2.   Total lags used: 20
acf2(mod0a$res)

     [,1]  [,2]  [,3]  [,4]  [,5]  [,6] [,7]  [,8] [,9] [,10] [,11] [,12] [,13]
ACF  0.04 -0.01 -0.13 -0.11 -0.17  0.00 0.07  0.02 0.10 -0.08  0.05  0.05  0.15
PACF 0.04 -0.02 -0.13 -0.10 -0.17 -0.01 0.04 -0.03 0.07 -0.11  0.08  0.09  0.15
     [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25]
ACF   0.07  0.03 -0.01 -0.14 -0.07 -0.08  0.13 -0.05  0.12 -0.01 -0.10  0.04
PACF  0.10  0.04  0.07 -0.07 -0.02 -0.05  0.08 -0.11  0.05 -0.04 -0.14  0.06
     [,26] [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36] [,37]
ACF   0.03 -0.05     0  0.14 -0.15  0.00 -0.06  0.09 -0.04  0.15  0.01 -0.11
PACF -0.01 -0.10     0  0.10 -0.10  0.03 -0.02  0.12 -0.05  0.16  0.03 -0.10
     [,38] [,39] [,40] [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48]
ACF  -0.02 -0.08  0.12  0.05  0.12 -0.09 -0.11 -0.01 -0.07  0.03  0.05
PACF  0.03 -0.01  0.12  0.04  0.03 -0.06 -0.14  0.05 -0.07 -0.05 -0.05
autoplot(mod0a)

mod0a$coef
          ma1          sma1     intercept 
-0.4694823225 -0.6359307380 -0.0008554565 
coef.polinomio<-c(1,mod0a$coef[1],rep(0,10), mod0a$coef[2],mod0a$coef[1]*mod0a$coef[2])
raices<-polyroot(coef.polinomio)
modulo.raices<-Mod(raices)
modulo.raices>1
 [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
all(modulo.raices>1)
[1] TRUE

3.1.1.2 \(SARIMA(1,1,0)(0,1,1)_{12}\)

mod0b = Arima(sdif.diffw, order=c(1,0,0),
              seasonal=list(order=c(0,0,1),period=12))
summary(mod0b)
Series: sdif.diffw 
ARIMA(1,0,0)(0,0,1)[12] with non-zero mean 

Coefficients:
          ar1     sma1     mean
      -0.3379  -0.6632  -0.0008
s.e.   0.0919   0.0963   0.0017

sigma^2 = 0.00298:  log likelihood = 157.3
AIC=-306.61   AICc=-306.21   BIC=-295.91

Training set error measures:
                       ME       RMSE        MAE      MPE     MAPE      MASE
Training set -0.001111991 0.05382009 0.04504635 167.5461 300.1488 0.4747436
                    ACF1
Training set -0.04252025
checkresiduals(mod0b,lag=20)


    Ljung-Box test

data:  Residuals from ARIMA(1,0,0)(0,0,1)[12] with non-zero mean
Q* = 16.898, df = 18, p-value = 0.5301

Model df: 2.   Total lags used: 20
acf2(mod0b$res)

      [,1]  [,2]  [,3]  [,4]  [,5]  [,6]  [,7]  [,8] [,9] [,10] [,11] [,12]
ACF  -0.04 -0.13 -0.09 -0.07 -0.15  0.02  0.07  0.02 0.09 -0.11  0.02  0.04
PACF -0.04 -0.13 -0.11 -0.10 -0.19 -0.05 -0.01 -0.03 0.07 -0.12  0.04  0.05
     [,13] [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24]
ACF   0.12  0.04  0.02   0.0 -0.13 -0.07 -0.05  0.13 -0.06  0.13 -0.01 -0.11
PACF  0.15  0.11  0.07   0.1 -0.04 -0.01 -0.05  0.08 -0.11  0.07 -0.04 -0.13
     [,25] [,26] [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36]
ACF   0.06  0.04 -0.08  0.01  0.15 -0.16 -0.01 -0.04  0.09 -0.05  0.16  0.03
PACF  0.06 -0.01 -0.10  0.00  0.10 -0.08  0.01 -0.04  0.10 -0.07  0.17  0.06
     [,37] [,38] [,39] [,40] [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48]
ACF  -0.12 -0.03 -0.08  0.11  0.05  0.12 -0.10 -0.10  0.02 -0.07  0.01  0.06
PACF -0.07  0.00 -0.04  0.12  0.05  0.09 -0.03 -0.13  0.04 -0.07 -0.05 -0.06
autoplot(mod0b)

3.1.1.3 Modelo final

mod.final = Arima(w, order=c(0,1,1),
                  seasonal=list(order=c(0,1,1),period=12))
summary(mod.final)
Series: w 
ARIMA(0,1,1)(0,1,1)[12] 

Coefficients:
          ma1     sma1
      -0.4600  -0.6317
s.e.   0.1152   0.1017

sigma^2 = 0.002903:  log likelihood = 158.81
AIC=-311.62   AICc=-311.38   BIC=-303.6

Training set error measures:
                       ME       RMSE        MAE         MPE      MAPE      MASE
Training set -0.004362609 0.05039797 0.03964294 -0.04128908 0.3576184 0.4155783
                   ACF1
Training set 0.02966902
autoplot(mod.final)

3.1.1.4 Diagnóstico

res<-mod.final$res
ts.plot(res)

acf2(res)

     [,1]  [,2]  [,3]  [,4]  [,5]  [,6] [,7]  [,8] [,9] [,10] [,11] [,12] [,13]
ACF  0.03 -0.01 -0.13 -0.12 -0.17  0.01 0.08  0.03 0.10 -0.10  0.03  0.04  0.14
PACF 0.03 -0.01 -0.13 -0.12 -0.17 -0.01 0.04 -0.03 0.07 -0.12  0.05  0.08  0.15
     [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25]
ACF   0.07  0.03  0.00 -0.14 -0.09 -0.08  0.12 -0.05  0.12 -0.02 -0.12  0.04
PACF  0.10  0.03  0.07 -0.06 -0.03 -0.04  0.07 -0.11  0.05 -0.04 -0.16  0.06
     [,26] [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36] [,37]
ACF   0.02 -0.05  0.00  0.15 -0.15 -0.01 -0.07  0.09 -0.03  0.16  0.01 -0.11
PACF -0.01 -0.11 -0.02  0.10 -0.10  0.01 -0.02  0.12 -0.05  0.16  0.03 -0.09
     [,38] [,39] [,40] [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48]
ACF  -0.01 -0.09  0.11  0.05  0.12 -0.09 -0.11 -0.01 -0.09  0.03  0.05
PACF  0.04  0.00  0.13  0.04  0.04 -0.04 -0.14  0.05 -0.06 -0.06 -0.06

#Normalidad

shapiro.test(res)

    Shapiro-Wilk normality test

data:  res
W = 0.98837, p-value = 0.4006
jarque.bera.test(res)

    Jarque Bera Test

data:  res
X-squared = 1.6036, df = 2, p-value = 0.4485
qqPlot(res)

[1]  88 119

3.2 Nivel de dióxido de carbono en alerta, Canada: Serie mensual del nivel de CO2 en alerta, de 01-1994 a 12-2004.

data(co2)
ts.plot(co2)

acf2(co2,50)

     [,1]  [,2] [,3] [,4]  [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
ACF  0.89  0.66 0.44 0.30  0.23 0.21 0.21 0.25 0.36  0.54  0.72  0.79  0.69
PACF 0.89 -0.60 0.26 0.12 -0.06 0.04 0.12 0.27 0.30  0.43  0.11 -0.25 -0.28
     [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25]
ACF   0.48  0.28  0.15  0.09  0.07  0.07  0.11   0.2  0.36  0.53  0.59  0.51
PACF -0.14  0.11 -0.10 -0.02  0.00 -0.02 -0.04   0.0  0.06  0.12 -0.08 -0.06
     [,26] [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36] [,37]
ACF   0.33  0.15  0.03 -0.02 -0.04 -0.03  0.00  0.09  0.23  0.38  0.43  0.36
PACF  0.04  0.01 -0.04  0.01 -0.02  0.06 -0.05 -0.04  0.01 -0.01 -0.06 -0.03
     [,38] [,39] [,40] [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48] [,49]
ACF   0.19  0.03 -0.07 -0.11 -0.12 -0.12 -0.10 -0.03  0.10  0.22  0.27  0.20
PACF  0.00  0.04 -0.03 -0.02 -0.04 -0.05 -0.01  0.00 -0.03 -0.03  0.00  0.01
     [,50]
ACF   0.06
PACF  0.02
plot(diff(co2))

acf2(diff(co2),50)

     [,1]  [,2]  [,3]  [,4]  [,5] [,6]  [,7]  [,8]  [,9] [,10] [,11] [,12]
ACF   0.6  0.01 -0.37 -0.38 -0.26 -0.2 -0.24 -0.33 -0.33  0.00  0.57  0.86
PACF  0.6 -0.57 -0.07 -0.01 -0.24 -0.2 -0.30 -0.47 -0.58 -0.25  0.26  0.12
     [,13] [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24]
ACF   0.58  0.01 -0.33 -0.35 -0.25 -0.19 -0.20 -0.30 -0.30 -0.01  0.52  0.77
PACF -0.06 -0.21  0.10  0.03 -0.07 -0.05  0.08 -0.04 -0.02 -0.10  0.11 -0.10
     [,25] [,26] [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36]
ACF   0.51  0.01 -0.28 -0.31 -0.23 -0.18 -0.18 -0.26 -0.27  0.00  0.46  0.70
PACF -0.06 -0.04  0.08 -0.06 -0.03 -0.04  0.02 -0.04  0.09 -0.03  0.03  0.08
     [,37] [,38] [,39] [,40] [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48]
ACF   0.45  0.01 -0.26 -0.27 -0.21 -0.15 -0.17 -0.24 -0.24  0.01  0.41  0.61
PACF -0.02 -0.05  0.03  0.04  0.02  0.04  0.02 -0.01  0.12 -0.02 -0.01 -0.01
     [,49] [,50]
ACF   0.38  0.00
PACF -0.04  0.07
plot(diff(diff(co2),lag=12))

acf2(diff(diff(co2,lag=12)),50)

      [,1]  [,2] [,3]  [,4]  [,5] [,6]  [,7] [,8]  [,9] [,10] [,11] [,12] [,13]
ACF  -0.54  0.12 0.06 -0.06 -0.05 0.11 -0.09 0.12 -0.12 -0.01  0.23 -0.47  0.32
PACF -0.54 -0.24 0.01  0.01 -0.10 0.02 -0.01 0.13 -0.01 -0.13  0.23 -0.34 -0.13
     [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25]
ACF  -0.08 -0.10  0.04  0.14 -0.18  0.11 -0.12  0.07 -0.13  0.15 -0.06 -0.01
PACF -0.04 -0.12 -0.15  0.07  0.05 -0.03 -0.06 -0.06 -0.25  0.15 -0.21 -0.13
     [,26] [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36] [,37]
ACF   0.01  0.10 -0.09 -0.01  0.06 -0.04  0.03  0.01  0.12 -0.18  0.09 -0.01
PACF  0.00  0.05 -0.03  0.04 -0.01 -0.06  0.02  0.02 -0.04  0.06 -0.19 -0.05
     [,38] [,39] [,40] [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48] [,49]
ACF  -0.02 -0.08  0.16  -0.1  0.02  0.00  0.03 -0.09  0.00  0.03  0.02 -0.05
PACF  0.03 -0.12 -0.05   0.1 -0.02 -0.02  0.09 -0.08 -0.15  0.01 -0.07 -0.03
     [,50]
ACF   0.03
PACF -0.04

¿Cuáles son los modelos posibles?

mod1 = Arima(co2, order=c(0,1,1),
             seasonal=list(order=c(0,1,1),period=12))
summary(mod1)
Series: co2 
ARIMA(0,1,1)(0,1,1)[12] 

Coefficients:
          ma1     sma1
      -0.5792  -0.8206
s.e.   0.0791   0.1137

sigma^2 = 0.5683:  log likelihood = -139.54
AIC=285.08   AICc=285.29   BIC=293.41

Training set error measures:
                     ME      RMSE       MAE         MPE      MAPE      MASE
Training set 0.02621552 0.7097587 0.5393719 0.006564489 0.1460971 0.2866839
                    ACF1
Training set 0.007662042
t_test(model = mod1)
         Coeffs Std.Errors        t Crit.Values Rej.H0
ma1  -0.5791816 0.07907509 7.324451    1.978671   TRUE
sma1 -0.8206107 0.11373107 7.215361    1.978671   TRUE
autoplot(mod1)

checkresiduals(mod1,lag=30)


    Ljung-Box test

data:  Residuals from ARIMA(0,1,1)(0,1,1)[12]
Q* = 29.96, df = 28, p-value = 0.3651

Model df: 2.   Total lags used: 30
tsdiag(mod1,gof.lag=30)

3.2.1 Diagnósticos

res<-mod1$res
ts.plot(res)

acf2(res)

     [,1] [,2]  [,3]  [,4] [,5] [,6]  [,7]  [,8]  [,9] [,10] [,11] [,12] [,13]
ACF  0.01 0.01 -0.06 -0.03 0.01 0.04 -0.01 -0.02 -0.16 -0.11  0.06 -0.06  0.15
PACF 0.01 0.01 -0.06 -0.03 0.01 0.03 -0.01 -0.02 -0.15 -0.11  0.07 -0.07  0.13
     [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25]
ACF  -0.08  -0.1 -0.01  0.05 -0.16 -0.04 -0.07 -0.08 -0.17  0.10 -0.05  0.04
PACF -0.08  -0.1  0.00  0.04 -0.21 -0.09 -0.06 -0.12 -0.20  0.11 -0.16  0.00
     [,26] [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36] [,37]
ACF   0.06  0.13  0.04  0.02 -0.04  0.07  0.05  0.00 -0.04 -0.16  0.03     0
PACF  0.06  0.08 -0.03  0.01 -0.15  0.06  0.04 -0.06 -0.13 -0.06 -0.08     0
     [,38] [,39] [,40] [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48]
ACF  -0.03  0.03  0.12 -0.06 -0.01  0.06  0.04 -0.11 -0.06 -0.05  0.04
PACF -0.09 -0.07  0.00  0.01 -0.11  0.07 -0.07 -0.16 -0.08  0.00 -0.04

3.2.2 Normalidad

shapiro.test(res)

    Shapiro-Wilk normality test

data:  res
W = 0.97914, p-value = 0.04
jarque.bera.test(res)

    Jarque Bera Test

data:  res
X-squared = 4.4288, df = 2, p-value = 0.1092
qqPlot(res)

[1] 57 67

3.3 Pasajeros de avión

data(AirPassengers)
y <- AirPassengers
autoplot(y)

w<-log(y)
autoplot(w)

acf2(w)

     [,1]  [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [,11] [,12] [,13]
ACF  0.95  0.90 0.85 0.81 0.78 0.76 0.74 0.73 0.73  0.74  0.76  0.76  0.72
PACF 0.95 -0.12 0.05 0.02 0.12 0.04 0.04 0.10 0.20  0.06  0.11 -0.04 -0.49
     [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25]
ACF   0.66  0.62  0.58  0.54  0.52  0.50  0.49  0.50  0.51  0.52  0.52  0.48
PACF -0.03  0.04 -0.04  0.03  0.04  0.04  0.01  0.07 -0.03  0.06  0.03 -0.19
     [,26] [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36] [,37]
ACF   0.44  0.40  0.36  0.34  0.31   0.3  0.29  0.30  0.30  0.32  0.32  0.29
PACF -0.04  0.04 -0.04  0.04 -0.04   0.0  0.03 -0.02  0.03  0.03  0.00 -0.13
     [,38] [,39] [,40] [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48]
ACF   0.25  0.21  0.18  0.15  0.12  0.11  0.10  0.10  0.11  0.12  0.12
PACF  0.00 -0.02 -0.06  0.01  0.04 -0.03  0.03 -0.05  0.01  0.03 -0.01
diffw<-diff(w)
autoplot(diffw)

acf2(diffw)

     [,1]  [,2]  [,3]  [,4]  [,5]  [,6]  [,7]  [,8]  [,9] [,10] [,11] [,12]
ACF   0.2 -0.12 -0.15 -0.32 -0.08  0.03 -0.11 -0.34 -0.12 -0.11  0.21  0.84
PACF  0.2 -0.17 -0.10 -0.31  0.01 -0.07 -0.21 -0.49 -0.19 -0.53 -0.30  0.59
     [,13] [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24]
ACF   0.22 -0.14 -0.12 -0.28 -0.05  0.01 -0.11 -0.34 -0.11 -0.08  0.20  0.74
PACF  0.03 -0.18  0.12  0.00  0.03 -0.12  0.09 -0.05 -0.06 -0.03  0.03 -0.01
     [,25] [,26] [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36]
ACF   0.20 -0.12 -0.10 -0.21 -0.07  0.02 -0.12 -0.29 -0.13 -0.04  0.15  0.66
PACF -0.05  0.02  0.03  0.02 -0.09  0.01  0.07  0.11 -0.09  0.06 -0.09  0.06
     [,37] [,38] [,39] [,40] [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48]
ACF   0.19 -0.13 -0.06 -0.16 -0.06  0.01 -0.11 -0.29 -0.11 -0.03  0.12  0.59
PACF -0.01 -0.08  0.09  0.04 -0.03  0.05  0.00 -0.03  0.02  0.02  0.02  0.06
acf2(diffw,max.lag=70)

     [,1]  [,2]  [,3]  [,4]  [,5]  [,6]  [,7]  [,8]  [,9] [,10] [,11] [,12]
ACF   0.2 -0.12 -0.15 -0.32 -0.08  0.03 -0.11 -0.34 -0.12 -0.11  0.21  0.84
PACF  0.2 -0.17 -0.10 -0.31  0.01 -0.07 -0.21 -0.49 -0.19 -0.53 -0.30  0.59
     [,13] [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24]
ACF   0.22 -0.14 -0.12 -0.28 -0.05  0.01 -0.11 -0.34 -0.11 -0.08  0.20  0.74
PACF  0.03 -0.18  0.12  0.00  0.03 -0.12  0.09 -0.05 -0.06 -0.03  0.03 -0.01
     [,25] [,26] [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36]
ACF   0.20 -0.12 -0.10 -0.21 -0.07  0.02 -0.12 -0.29 -0.13 -0.04  0.15  0.66
PACF -0.05  0.02  0.03  0.02 -0.09  0.01  0.07  0.11 -0.09  0.06 -0.09  0.06
     [,37] [,38] [,39] [,40] [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48]
ACF   0.19 -0.13 -0.06 -0.16 -0.06  0.01 -0.11 -0.29 -0.11 -0.03  0.12  0.59
PACF -0.01 -0.08  0.09  0.04 -0.03  0.05  0.00 -0.03  0.02  0.02  0.02  0.06
     [,49] [,50] [,51] [,52] [,53] [,54] [,55] [,56] [,57] [,58] [,59] [,60]
ACF   0.19 -0.14 -0.05 -0.12 -0.03  0.00 -0.09 -0.29 -0.10 -0.01  0.10  0.52
PACF -0.04  0.06 -0.07  0.03  0.09 -0.01  0.07 -0.01  0.04  0.08  0.06  0.02
     [,61] [,62] [,63] [,64] [,65] [,66] [,67] [,68] [,69] [,70]
ACF   0.14 -0.13 -0.04 -0.09 -0.01  0.01 -0.10 -0.26 -0.09  0.00
PACF -0.05  0.01  0.03 -0.07 -0.02  0.01 -0.03  0.06 -0.01 -0.07
acf2(diffw,max.lag=80)

     [,1]  [,2]  [,3]  [,4]  [,5]  [,6]  [,7]  [,8]  [,9] [,10] [,11] [,12]
ACF   0.2 -0.12 -0.15 -0.32 -0.08  0.03 -0.11 -0.34 -0.12 -0.11  0.21  0.84
PACF  0.2 -0.17 -0.10 -0.31  0.01 -0.07 -0.21 -0.49 -0.19 -0.53 -0.30  0.59
     [,13] [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24]
ACF   0.22 -0.14 -0.12 -0.28 -0.05  0.01 -0.11 -0.34 -0.11 -0.08  0.20  0.74
PACF  0.03 -0.18  0.12  0.00  0.03 -0.12  0.09 -0.05 -0.06 -0.03  0.03 -0.01
     [,25] [,26] [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36]
ACF   0.20 -0.12 -0.10 -0.21 -0.07  0.02 -0.12 -0.29 -0.13 -0.04  0.15  0.66
PACF -0.05  0.02  0.03  0.02 -0.09  0.01  0.07  0.11 -0.09  0.06 -0.09  0.06
     [,37] [,38] [,39] [,40] [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48]
ACF   0.19 -0.13 -0.06 -0.16 -0.06  0.01 -0.11 -0.29 -0.11 -0.03  0.12  0.59
PACF -0.01 -0.08  0.09  0.04 -0.03  0.05  0.00 -0.03  0.02  0.02  0.02  0.06
     [,49] [,50] [,51] [,52] [,53] [,54] [,55] [,56] [,57] [,58] [,59] [,60]
ACF   0.19 -0.14 -0.05 -0.12 -0.03  0.00 -0.09 -0.29 -0.10 -0.01  0.10  0.52
PACF -0.04  0.06 -0.07  0.03  0.09 -0.01  0.07 -0.01  0.04  0.08  0.06  0.02
     [,61] [,62] [,63] [,64] [,65] [,66] [,67] [,68] [,69] [,70] [,71] [,72]
ACF   0.14 -0.13 -0.04 -0.09 -0.01  0.01 -0.10 -0.26 -0.09  0.00   0.1  0.43
PACF -0.05  0.01  0.03 -0.07 -0.02  0.01 -0.03  0.06 -0.01 -0.07   0.0 -0.09
     [,73] [,74] [,75] [,76] [,77] [,78] [,79] [,80]
ACF   0.12 -0.12 -0.04 -0.06  0.00  0.01 -0.09 -0.22
PACF  0.03  0.02 -0.06 -0.06 -0.01 -0.02 -0.04  0.00

Parece que necesita una diferencia estacional.

3.3.1 Sin diferenciación estacional

Vamos a ajustar sin diferencia estacional para ver qué pasa…

mod0a <- Arima(log(y), c(1, 1, 1),seasonal = list(order = c(1, 0, 0), period = 12))
summary(mod0a)
Series: log(y) 
ARIMA(1,1,1)(1,0,0)[12] 

Coefficients:
         ar1      ma1    sar1
      0.4369  -0.7264  0.9204
s.e.  0.3553   0.2847  0.0295

sigma^2 = 0.001806:  log likelihood = 238.9
AIC=-469.79   AICc=-469.5   BIC=-457.94

Training set error measures:
                      ME       RMSE        MAE        MPE      MAPE      MASE
Training set 0.002627609 0.04190571 0.03305645 0.04767249 0.6052955 0.2730989
                    ACF1
Training set -0.04464352
autoplot(mod0a)

checkresiduals(mod0a,lag=20)


    Ljung-Box test

data:  Residuals from ARIMA(1,1,1)(1,0,0)[12]
Q* = 31.564, df = 17, p-value = 0.01704

Model df: 3.   Total lags used: 20
mod0a <- Arima(log(y), c(1, 1, 1),seasonal = list(order = c(1, 0, 0), period = 12),method="CSS")
mod0a$coef
       ar1        ma1       sar1 
 0.2424271 -0.5930691  0.9492398 
coef.polinomio<-c(1,-mod0a$coef[1],rep(0,10), -mod0a$coef[3],mod0a$coef[1]*mod0a$coef[3])
raices<-polyroot(coef.polinomio)
modulo.raices<-Mod(raices)
modulo.raices>1
 [1] TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE TRUE
all(modulo.raices>1)
[1] TRUE
acf2(mod0a$res)

      [,1] [,2]  [,3]  [,4] [,5] [,6]  [,7] [,8] [,9] [,10] [,11] [,12] [,13]
ACF  -0.02 0.12 -0.15 -0.02 0.03 0.02 -0.04 0.02 0.15 -0.09 -0.06 -0.38  0.03
PACF -0.02 0.12 -0.15 -0.04 0.07 0.00 -0.06 0.04 0.18 -0.12 -0.11 -0.32  0.03
     [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25]
ACF  -0.05  0.09 -0.09  0.03 -0.02 -0.06 -0.15 -0.01 -0.02  0.24  0.06 -0.03
PACF  0.00 -0.02 -0.09  0.06  0.01 -0.13 -0.16  0.13 -0.07  0.14 -0.06 -0.02
     [,26] [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36] [,37]
ACF   0.03 -0.03  0.00 -0.05 -0.08 -0.03  0.14 -0.09  0.02 -0.15 -0.03  0.02
PACF  0.04  0.01 -0.11  0.01 -0.12 -0.12 -0.02 -0.02 -0.04  0.00 -0.09  0.04
     [,38] [,39] [,40] [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48]
ACF   0.01 -0.03 -0.05 -0.08  0.04 -0.09 -0.01 -0.03   0.0  0.14  0.05
PACF -0.01 -0.04 -0.15 -0.16  0.03 -0.13 -0.06 -0.07  -0.1  0.05  0.03

3.3.2 Con diferenciación estacional

sdif.diffw<-diff(diffw,lag=12)
autoplot(sdif.diffw)

acf2(sdif.diffw)

      [,1]  [,2]  [,3]  [,4] [,5] [,6]  [,7]  [,8] [,9] [,10] [,11] [,12] [,13]
ACF  -0.34  0.11 -0.20  0.02 0.06 0.03 -0.06  0.00 0.18 -0.08  0.06 -0.39  0.15
PACF -0.34 -0.01 -0.19 -0.13 0.03 0.03 -0.06 -0.02 0.23  0.04  0.05 -0.34 -0.11
     [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25]
ACF  -0.06  0.15 -0.14  0.07  0.02 -0.01 -0.12  0.04 -0.09  0.22 -0.02  -0.1
PACF -0.08 -0.02 -0.14  0.03  0.11 -0.01 -0.17  0.13 -0.07  0.14 -0.07  -0.1
     [,26] [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36] [,37]
ACF   0.05 -0.03  0.05 -0.02 -0.05 -0.05  0.20 -0.12  0.08 -0.15 -0.01  0.05
PACF -0.01  0.04 -0.09  0.05  0.00 -0.10 -0.02  0.01 -0.02  0.02 -0.16 -0.03
     [,38] [,39] [,40] [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48]
ACF   0.03 -0.02 -0.03 -0.07  0.10 -0.09  0.03 -0.04 -0.04  0.11 -0.05
PACF  0.01  0.05 -0.08 -0.17  0.07 -0.10 -0.06 -0.03 -0.12 -0.01 -0.05

Ahora los correlogramas muestran estacionariedad.

3.3.3 Identificación de los modelos apropiados.

####Empezamos con la parte estacional

3.3.3.0.1 \(SARIMA(0,1,0)(0,1,1)_{12}\)
mod1a <- Arima(log(y), c(0, 1, 0),seasonal = list(order = c(0, 1, 1), period = 12))
summary(mod1a)
Series: log(y) 
ARIMA(0,1,0)(0,1,1)[12] 

Coefficients:
         sma1
      -0.6021
s.e.   0.0784

sigma^2 = 0.00155:  log likelihood = 235.78
AIC=-467.56   AICc=-467.46   BIC=-461.81

Training set error measures:
                       ME      RMSE        MAE         MPE      MAPE     MASE
Training set 0.0003217254 0.0374046 0.02716147 0.006150192 0.4905912 0.224397
                 ACF1
Training set -0.33562
checkresiduals(mod1a,lag=20)


    Ljung-Box test

data:  Residuals from ARIMA(0,1,0)(0,1,1)[12]
Q* = 38.473, df = 19, p-value = 0.005164

Model df: 1.   Total lags used: 20
acf2(mod1a$res)

      [,1]  [,2]  [,3]  [,4]  [,5] [,6]  [,7]  [,8] [,9] [,10] [,11] [,12]
ACF  -0.34  0.06 -0.09 -0.10  0.08 0.06 -0.07 -0.05 0.14  -0.1  0.04 -0.02
PACF -0.34 -0.06 -0.10 -0.18 -0.03 0.08 -0.05 -0.12 0.13   0.0 -0.05 -0.01
     [,13] [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24]
ACF   0.01  0.01  0.09 -0.20  0.10  0.03 -0.07 -0.06  0.01  -0.1  0.22 -0.04
PACF  0.06  0.00  0.08 -0.13  0.01  0.07 -0.06 -0.18 -0.02  -0.1  0.10  0.02
     [,25] [,26] [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36]
ACF  -0.06  0.08 -0.03 -0.04  0.00 -0.05 -0.07  0.19 -0.18  0.07 -0.06 -0.03
PACF  0.00  0.09  0.09 -0.06 -0.04 -0.03 -0.08  0.03 -0.11 -0.01 -0.06 -0.12
     [,37] [,38] [,39] [,40] [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48]
ACF   0.09  0.04 -0.04 -0.01 -0.06  0.03 -0.04  0.05 -0.11  0.05  0.02  0.00
PACF  0.04  0.06  0.03 -0.02 -0.14  0.07 -0.02 -0.04 -0.10 -0.01 -0.03  0.03
autoplot(mod1a)

3.3.3.0.2 \(SARIMA(0,1,0)(1,1,0)_{12}\)
mod1b <- Arima(log(y), c(0, 1, 0),seasonal = list(order = c(1, 1, 0), period = 12))
summary(mod1b)
Series: log(y) 
ARIMA(0,1,0)(1,1,0)[12] 

Coefficients:
         sar1
      -0.4320
s.e.   0.0817

sigma^2 = 0.001717:  log likelihood = 230.51
AIC=-457.02   AICc=-456.93   BIC=-451.27

Training set error measures:
                       ME       RMSE       MAE        MPE     MAPE      MASE
Training set 0.0005159887 0.03937397 0.0288573 0.00955034 0.521137 0.2384073
                   ACF1
Training set -0.3737297
checkresiduals(mod1b,lag=20)


    Ljung-Box test

data:  Residuals from ARIMA(0,1,0)(1,1,0)[12]
Q* = 44.038, df = 19, p-value = 0.0009329

Model df: 1.   Total lags used: 20
acf2(mod1b$res)

      [,1]  [,2]  [,3]  [,4] [,5] [,6]  [,7]  [,8] [,9] [,10] [,11] [,12] [,13]
ACF  -0.37  0.08 -0.12 -0.05 0.09 0.05 -0.07 -0.04 0.17 -0.11  0.05 -0.10  0.02
PACF -0.37 -0.07 -0.13 -0.16 0.01 0.10 -0.03 -0.08 0.18  0.02 -0.02 -0.06 -0.01
     [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25]
ACF  -0.01  0.10 -0.16  0.11  0.01 -0.06 -0.06  0.06 -0.12  0.27 -0.22 -0.04
PACF -0.06  0.05 -0.12  0.03  0.08 -0.04 -0.16  0.07 -0.09  0.17 -0.13 -0.11
     [,26] [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36] [,37]
ACF   0.06  0.01 -0.02 -0.02 -0.03 -0.10  0.23 -0.19  0.05 -0.06 -0.05  0.08
PACF  0.01  0.07 -0.12 -0.04 -0.01 -0.11  0.01 -0.02 -0.04 -0.03 -0.16  0.03
     [,38] [,39] [,40] [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48]
ACF   0.05 -0.07  0.03 -0.08  0.06 -0.06  0.08 -0.08  0.04  0.01 -0.03
PACF  0.04  0.03 -0.04 -0.15  0.08 -0.07 -0.07 -0.05 -0.06  0.00 -0.01
autoplot(mod1b)

3.3.3.1 La parte no estacional

3.3.3.1.1 \(SARIMA(1,1,0)(0,1,1)_{12}\)
mod2a <- Arima(log(AirPassengers), c(1, 1, 0),seasonal = list(order = c(0, 1, 1), period = 12))
summary(mod2a)
Series: log(AirPassengers) 
ARIMA(1,1,0)(0,1,1)[12] 

Coefficients:
          ar1     sma1
      -0.3395  -0.5619
s.e.   0.0822   0.0748

sigma^2 = 0.001391:  log likelihood = 243.74
AIC=-481.49   AICc=-481.3   BIC=-472.86

Training set error measures:
                       ME       RMSE        MAE         MPE      MAPE      MASE
Training set 0.0004500154 0.03529899 0.02662601 0.008828412 0.4816646 0.2199733
                    ACF1
Training set -0.02338686
checkresiduals(mod2a,lag=24)


    Ljung-Box test

data:  Residuals from ARIMA(1,1,0)(0,1,1)[12]
Q* = 32.074, df = 22, p-value = 0.07615

Model df: 2.   Total lags used: 24
acf2(mod2a$res)

      [,1]  [,2]  [,3]  [,4] [,5] [,6]  [,7]  [,8] [,9] [,10] [,11] [,12] [,13]
ACF  -0.02 -0.09 -0.13 -0.12 0.09 0.08 -0.09 -0.03 0.13 -0.05 -0.01 -0.04  0.00
PACF -0.02 -0.09 -0.14 -0.14 0.06 0.05 -0.11 -0.03 0.15 -0.07 -0.04 -0.01  0.04
     [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25]
ACF   0.05  0.06 -0.17  0.06  0.05 -0.10 -0.09 -0.04 -0.03  0.23  0.00 -0.06
PACF  0.00  0.03 -0.14  0.08  0.03 -0.13 -0.14  0.01 -0.07  0.13 -0.04  0.03
     [,26] [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36] [,37]
ACF   0.07 -0.01 -0.05 -0.03 -0.09 -0.04  0.15 -0.12  0.00 -0.06 -0.04  0.11
PACF  0.09  0.03 -0.09 -0.02 -0.05 -0.06  0.02 -0.11  0.01 -0.10 -0.09  0.09
     [,38] [,39] [,40] [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48]
ACF   0.07 -0.04 -0.05 -0.07  0.00 -0.02  0.01 -0.09  0.03  0.04  0.04
PACF  0.04  0.01 -0.08 -0.10  0.09 -0.07 -0.05 -0.09  0.00 -0.02  0.04
autoplot(mod2a)

3.3.3.1.2 \(SARIMA(0,1,1)(0,1,1)_{12}\)
mod2b <- Arima(log(AirPassengers), c(0, 1, 1),seasonal = list(order = c(0, 1, 1), period = 12))
summary(mod2b)
Series: log(AirPassengers) 
ARIMA(0,1,1)(0,1,1)[12] 

Coefficients:
          ma1     sma1
      -0.4018  -0.5569
s.e.   0.0896   0.0731

sigma^2 = 0.001371:  log likelihood = 244.7
AIC=-483.4   AICc=-483.21   BIC=-474.77

Training set error measures:
                       ME       RMSE        MAE        MPE      MAPE      MASE
Training set 0.0005730622 0.03504883 0.02626034 0.01098898 0.4752815 0.2169522
                   ACF1
Training set 0.01443892
checkresiduals(mod2b,lag=20)


    Ljung-Box test

data:  Residuals from ARIMA(0,1,1)(0,1,1)[12]
Q* = 17.688, df = 18, p-value = 0.4764

Model df: 2.   Total lags used: 20
acf2(mod2b$res)

     [,1] [,2]  [,3]  [,4] [,5] [,6]  [,7]  [,8] [,9] [,10] [,11] [,12] [,13]
ACF  0.01 0.02 -0.13 -0.11 0.06 0.06 -0.06 -0.03 0.12 -0.06  0.00 -0.05  0.01
PACF 0.01 0.02 -0.13 -0.11 0.07 0.05 -0.10 -0.03 0.16 -0.08 -0.05 -0.01  0.05
     [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25]
ACF   0.03  0.06 -0.16  0.05  0.01 -0.10 -0.10 -0.03 -0.03  0.22  0.01 -0.04
PACF -0.02  0.03 -0.14  0.07  0.01 -0.15 -0.14  0.05 -0.04  0.14 -0.02  0.02
     [,26] [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36] [,37]
ACF   0.06 -0.02 -0.05 -0.05 -0.08 -0.06  0.13 -0.13     0 -0.07 -0.03   0.1
PACF  0.08  0.01 -0.11 -0.03 -0.04 -0.07  0.02 -0.11     0 -0.07 -0.07   0.1
     [,38] [,39] [,40] [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48]
ACF   0.06 -0.04 -0.05 -0.09 -0.01 -0.05  0.00 -0.09  0.03  0.05  0.06
PACF  0.03 -0.03 -0.08 -0.11  0.09 -0.08 -0.06 -0.08  0.02  0.00  0.06
autoplot(mod2b)

3.3.4 Modelo final

mod.final <- mod2b
summary(mod.final)
Series: log(AirPassengers) 
ARIMA(0,1,1)(0,1,1)[12] 

Coefficients:
          ma1     sma1
      -0.4018  -0.5569
s.e.   0.0896   0.0731

sigma^2 = 0.001371:  log likelihood = 244.7
AIC=-483.4   AICc=-483.21   BIC=-474.77

Training set error measures:
                       ME       RMSE        MAE        MPE      MAPE      MASE
Training set 0.0005730622 0.03504883 0.02626034 0.01098898 0.4752815 0.2169522
                   ACF1
Training set 0.01443892
autoplot(mod.final)

res<-mod.final$res
ts.plot(res)

acf2(res)

     [,1] [,2]  [,3]  [,4] [,5] [,6]  [,7]  [,8] [,9] [,10] [,11] [,12] [,13]
ACF  0.01 0.02 -0.13 -0.11 0.06 0.06 -0.06 -0.03 0.12 -0.06  0.00 -0.05  0.01
PACF 0.01 0.02 -0.13 -0.11 0.07 0.05 -0.10 -0.03 0.16 -0.08 -0.05 -0.01  0.05
     [,14] [,15] [,16] [,17] [,18] [,19] [,20] [,21] [,22] [,23] [,24] [,25]
ACF   0.03  0.06 -0.16  0.05  0.01 -0.10 -0.10 -0.03 -0.03  0.22  0.01 -0.04
PACF -0.02  0.03 -0.14  0.07  0.01 -0.15 -0.14  0.05 -0.04  0.14 -0.02  0.02
     [,26] [,27] [,28] [,29] [,30] [,31] [,32] [,33] [,34] [,35] [,36] [,37]
ACF   0.06 -0.02 -0.05 -0.05 -0.08 -0.06  0.13 -0.13     0 -0.07 -0.03   0.1
PACF  0.08  0.01 -0.11 -0.03 -0.04 -0.07  0.02 -0.11     0 -0.07 -0.07   0.1
     [,38] [,39] [,40] [,41] [,42] [,43] [,44] [,45] [,46] [,47] [,48]
ACF   0.06 -0.04 -0.05 -0.09 -0.01 -0.05  0.00 -0.09  0.03  0.05  0.06
PACF  0.03 -0.03 -0.08 -0.11  0.09 -0.08 -0.06 -0.08  0.02  0.00  0.06
#Normalidad
shapiro.test(res)

    Shapiro-Wilk normality test

data:  res
W = 0.98637, p-value = 0.1674
jarque.bera.test(res)

    Jarque Bera Test

data:  res
X-squared = 5.2265, df = 2, p-value = 0.0733
qqPlot(res)

[1] 62 29
#Pronóstico
forecast(mod.final)
         Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95
Jan 1961       6.110186 6.062729 6.157642 6.037607 6.182764
Feb 1961       6.053775 5.998476 6.109074 5.969203 6.138347
Mar 1961       6.171715 6.109555 6.233874 6.076650 6.266779
Apr 1961       6.199300 6.130966 6.267635 6.094792 6.303809
May 1961       6.232556 6.158560 6.306552 6.119388 6.345724
Jun 1961       6.368779 6.289524 6.448033 6.247569 6.489988
Jul 1961       6.507294 6.423109 6.591479 6.378544 6.636044
Aug 1961       6.502906 6.414064 6.591749 6.367034 6.638779
Sep 1961       6.324698 6.231431 6.417965 6.182058 6.467338
Oct 1961       6.209008 6.111516 6.306500 6.059908 6.358109
Nov 1961       6.063487 5.961947 6.165028 5.908195 6.218780
Dec 1961       6.168025 6.062591 6.273459 6.006778 6.329272
Jan 1962       6.206435 6.089996 6.322874 6.028358 6.384512
Feb 1962       6.150025 6.026590 6.273459 5.961248 6.338801
Mar 1962       6.267964 6.137910 6.398018 6.069064 6.466865
Apr 1962       6.295550 6.159197 6.431903 6.087016 6.504084
May 1962       6.328805 6.186432 6.471179 6.111064 6.546547
Jun 1962       6.465028 6.316878 6.613177 6.238453 6.691603
Jul 1962       6.603543 6.449834 6.757252 6.368466 6.838620
Aug 1962       6.599156 6.440082 6.758229 6.355874 6.842438
Sep 1962       6.420947 6.256684 6.585211 6.169728 6.672167
Oct 1962       6.305257 6.135963 6.474552 6.046344 6.564171
Nov 1962       6.159737 5.985557 6.333917 5.893352 6.426122
Dec 1962       6.264274 6.085342 6.443206 5.990621 6.537927
autoplot(forecast(mod.final))

3.3.5 \(SARIMA(0,1,1)(0,1,1)_{12}\)

Incluyendo la transformación logarítmica

mod2b <- Arima(AirPassengers, c(0, 1, 1),seasonal = list(order = c(0, 1, 1), period = 12),lambda=0)
summary(mod2b)
Series: AirPassengers 
ARIMA(0,1,1)(0,1,1)[12] 
Box Cox transformation: lambda= 0 

Coefficients:
          ma1     sma1
      -0.4018  -0.5569
s.e.   0.0896   0.0731

sigma^2 = 0.001371:  log likelihood = 244.7
AIC=-483.4   AICc=-483.21   BIC=-474.77

Training set error measures:
                     ME     RMSE      MAE          MPE     MAPE     MASE
Training set 0.05140418 10.15504 7.357553 -0.004079016 2.623636 0.229706
                    ACF1
Training set -0.03689673
autoplot(forecast(mod2b,h=50))