1. Introduction

2. Data Exploration

##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
## -13.000  -4.000   1.000   1.413   6.000  30.000
## [1] "SD = 7.48"
## [1] "period = 6"

After differencing by 6 lags, the seasonal pattern disappear in the ACF plot and time plot looks more regularized than before, suggesting adding a seasonal component to the model.

3. ARMA Model

ts_1 <- ts(select2,frequency = 6)
de_1 <- decompose(ts_1)
plot(de_1)

arima_1<-arima(rand_1, order = c(2,0,2))
arima_1
## 
## Call:
## arima(x = rand_1, order = c(2, 0, 2))
## 
## Coefficients:
##          ar1      ar2      ma1     ma2  intercept
##       0.8745  -0.7877  -1.6479  0.6479     -9e-04
## s.e.  0.0396   0.0346   0.0576  0.0572      8e-04
## 
## sigma^2 estimated as 13.2:  log likelihood = -912.45,  aic = 1836.89
## 
##  Shapiro-Wilk normality test
## 
## data:  arima_1$residuals
## W = 0.99509, p-value = 0.3684

5. SARMA Model

sarima_1<-arima(select2,order = c(2,0,2),seasonal=list(order=c(2,0,0),period=6))
sarima_1
## 
## Call:
## arima(x = select2, order = c(2, 0, 2), seasonal = list(order = c(2, 0, 0), period = 6))
## 
## Coefficients:
##          ar1      ar2      ma1     ma2    sar1    sar2  intercept
##       0.7825  -0.8281  -0.5906  0.5632  0.1422  0.1296     1.5357
## s.e.  0.0796   0.0759   0.1103  0.1015  0.0662  0.0628     0.4305
## 
## sigma^2 estimated as 38.87:  log likelihood = -1105.31,  aic = 2226.62

Therefore, the SARIMA model is acceptable.

6. Forecast

train <- select2[1:((0.9)*length(select2))]
test <- select2[(0.9*length(select2)+1):length(select2)]
train22 <- arima(train,order = c(2,0,2),seasonal=list(order=c(2,0,0),period=6))
pred_ <- predict(train22, n.ahead = (length(select2)-(0.9*length(select2))))
ts.plot(test,pred_$pred,col=1:2)
u=pred_$pred+1.96*pred_$se
l=pred_$pred-1.96*pred_$se
xx = c(time(u), rev(time(u)))
yy = c(l, rev(u))
polygon(xx, yy, border = 8, col = gray(.6, alpha = .2))
lines(pred_$pred, type="p", col=2)

7. Conclusion and Discussion

8. Reference