library(readxl)
seaice <- read_excel("Documents/Data Analysis and econometrics/seaice.xlsx",skip = 1)
So I used the same data set as week but instead looked at Antartica sea ice depth rather than Artic sea ice.
library(forecast)
## Registered S3 method overwritten by 'quantmod':
## method from
## as.zoo.data.frame zoo
library(seasonal)
t=c(1:255)
icets<-ts(seaice$Antarctica,t,frequency=12)
plot(icets)
ice<-window(icets,end=c(t=255))
## Warning in window.default(x, ...): 'end' value not changed
decompice<-decompose(icets,type="additive")
plot(decompice)
There is interestingly no downward trend for sea ice in Antartica. WHich makes me think that I have made a mistake as I am not climate a climate change denier. The far ore likley scenrio is that I have done somehting incorrectly
ggseasonplot(icets)
Seasonal plot shows seasonal data but no decreasing trend from year to year.
Seasonal plot lloks very similar with lows around March and highs around October.
etsfull<-ets(icets,model="ZZZ")
fcetsfull<-forecast(etsfull)
autoplot(fcetsfull)
I used the ZZZ ets model as I knew that it perfomred the best with the arctic sea ice models so I expect to perform similar for the Antartica models.
accfcetsfull<-accuracy(fcetsfull)
accfcetsfull
## ME RMSE MAE MPE MAPE MASE
## Training set -0.001250864 0.2870279 0.2215752 -0.1585677 3.808997 0.5655754
## ACF1
## Training set 0.06093694
myarimafull<-auto.arima(icets)
summary(myarimafull)
## Series: icets
## ARIMA(2,0,1)(0,1,1)[12]
##
## Coefficients:
## ar1 ar2 ma1 sma1
## 0.3693 0.2022 0.4142 -0.8788
## s.e. 0.3241 0.2423 0.3115 0.0542
##
## sigma^2 estimated as 0.081: log likelihood=-46.63
## AIC=103.26 AICc=103.51 BIC=120.72
##
## Training set error measures:
## ME RMSE MAE MPE MAPE MASE
## Training set 0.02367332 0.275536 0.2040456 -0.07347752 3.416472 0.5208308
## ACF1
## Training set -0.01121952
fcmyarimafull<-forecast(myarimafull)
autoplot(fcmyarimafull)
accmyarimafull<-accuracy(fcmyarimafull)
accmyarimafull
## ME RMSE MAE MPE MAPE MASE
## Training set 0.02367332 0.275536 0.2040456 -0.07347752 3.416472 0.5208308
## ACF1
## Training set -0.01121952
On the full data sets, the Arima model seem to win across each evalaution metric. Although metrics are close
I split into training and test sets with a roughly 80/20 split.
train<-ts(icets[1:200],frequency = 12)
test<-ts(icets[201:255],frequency = 12)
ets<-ets(train,model = "ZZZ")
ets
## ETS(A,N,A)
##
## Call:
## ets(y = train, model = "ZZZ")
##
## Smoothing parameters:
## alpha = 0.8572
## gamma = 1e-04
##
## Initial states:
## l = 8.6114
## s = -2.0545 2.7694 5.18 5.7245 5.2947 3.9571
## 1.7382 -0.7528 -3.5797 -6.0259 -6.7337 -5.5174
##
## sigma: 0.2627
##
## AIC AICc BIC
## 540.4146 543.0233 589.8894
fcets<-forecast(ets,55)
autoplot(fcets)
accets<-accuracy(fcets,test[1:55])
accets
## ME RMSE MAE MPE MAPE MASE
## Training set 0.00287898 0.2533148 0.1981419 -0.199337 3.434498 0.09509972
## Test set -0.14446080 0.4756570 0.3973897 -5.133348 8.215553 0.19073019
## ACF1
## Training set 0.06909786
## Test set NA
myarima<-auto.arima(train)
summary(myarima)
## Series: train
## ARIMA(1,0,1)(0,1,1)[12]
##
## Coefficients:
## ar1 ma1 sma1
## 0.6601 0.1446 -0.8815
## s.e. 0.0742 0.0966 0.0829
##
## sigma^2 estimated as 0.06378: log likelihood=-15.82
## AIC=39.64 AICc=39.86 BIC=52.59
##
## Training set error measures:
## ME RMSE MAE MPE MAPE MASE
## Training set 0.01558477 0.2429011 0.1852697 -0.1146198 3.173879 0.5013056
## ACF1
## Training set 0.001921232
fcmyarima<-forecast(myarima,55)
autoplot(fcmyarima)
accmyarima<-accuracy(fcmyarima,test[1:55])
accmyarima
## ME RMSE MAE MPE MAPE MASE
## Training set 0.01558477 0.2429011 0.1852697 -0.1146198 3.173879 0.08892161
## Test set 0.24148561 0.5119285 0.3936008 2.2973198 6.078179 0.18891170
## ACF1
## Training set 0.001921232
## Test set NA
The Arima model outperfoms the ZZZ ETS model but it is not as clear cut. Looking the residuals does show a greater spreadacross the residuals for the ETS model
checkresiduals(fcmyarima)
##
## Ljung-Box test
##
## data: Residuals from ARIMA(1,0,1)(0,1,1)[12]
## Q* = 17.519, df = 21, p-value = 0.6792
##
## Model df: 3. Total lags used: 24
checkresiduals(fcets)
##
## Ljung-Box test
##
## data: Residuals from ETS(A,N,A)
## Q* = 36.903, df = 10, p-value = 5.883e-05
##
## Model df: 14. Total lags used: 24
sum(residuals(fcmyarima))
## [1] 3.116954
sum(residuals(fcets))
## [1] 0.5757961
The sum of the residuals for the forecast of the arima is far from zero in comparison to the underperfomring ETS model. The postitive sum leads me to believe the model is underestimating and can be improved.
autoplot(icets)+autolayer(fcets, col="red")+autolayer(fcmyarima,col="darkgreen")
ETS by the plot gives a larger margin of error.