Lab 6
Jonathan Zhang 44311103 Zhi Yi Ye 40357105 Dustin Johnson 11338118
data <- read.csv("C:/Users/Jonathan/SkyDrive/Jonathan Zhang/UBC/Stat Courses/Stat 443/dataTempPG.csv")
data.ts <- ts(data$Annual)
You can also embed plots, for example:
plot(data.ts)
Not stationary, there is clearly a trend
par(mfrow = c(2, 1))
acf(data.ts)
pacf(data.ts)
residuals.ts <- ts(lm(data$Annual ~ data$Year)$residuals)
par(mfrow = c(3, 1))
plot(residuals.ts)
acf(residuals.ts)
pacf(residuals.ts)
We are deciding whether it is ARIMA(0,0,1) or ARIMA(0,0,9). Because the p and d parameters are 0, we are basically asking if our residuals follow an MA(1) or MA(9) process. We think it follows an MA(1) process because the acf cuts off after 1 (somewhat). MA(9) is definitely a wrong fit.
arima1 <- arima(residuals.ts, order = c(0, 0, 1), include.mean = F)
arima1
##
## Call:
## arima(x = residuals.ts, order = c(0, 0, 1), include.mean = F)
##
## Coefficients:
## ma1
## 0.235
## s.e. 0.103
##
## sigma^2 estimated as 0.972: log likelihood = -126.5, aic = 256.9
tsdiag(arima1)
confint(arima1)
## 2.5 % 97.5 %
## ma1 0.03294 0.4373
Model: X_t = 0.2351 Z_t
arima9 <- arima(residuals.ts, order = c(0, 0, 9), include.mean = F)
arima9
##
## Call:
## arima(x = residuals.ts, order = c(0, 0, 9), include.mean = F)
##
## Coefficients:
## ma1 ma2 ma3 ma4 ma5 ma6 ma7 ma8 ma9
## -0.037 0.063 0.003 -0.199 0.155 0.130 -0.088 -0.476 -0.552
## s.e. 0.103 0.131 0.097 0.132 0.115 0.121 0.112 0.118 0.109
##
## sigma^2 estimated as 0.628: log likelihood = -113, aic = 246.1
tsdiag(arima9)
confint(arima9)
## 2.5 % 97.5 %
## ma1 -0.23802 0.16428
## ma2 -0.19455 0.32038
## ma3 -0.18722 0.19404
## ma4 -0.45809 0.05914
## ma5 -0.07092 0.38176
## ma6 -0.10748 0.36834
## ma7 -0.30849 0.13159
## ma8 -0.70649 -0.24453
## ma9 -0.76521 -0.33851
Looking at the confidence intervals, all our 9 parameters are insignificant, this model is probably incorrect! Now we check AIC
AIC(arima1)
## [1] 256.9
AIC(arima9)
## [1] 246.1
Our AIC results do not agree with the model we deemed as appropriate. However, this is not surprising because the ARIMA(0,0,9) model obviously overfits the model (more parameters) and AIC does not penalize the number of parameters that much. It does not agree with our intuition. We think a smaller model is better, however AIC may not agree, this is normal.