The dataset use in this project describes the minimum daily temperature over 10 years (19981 and 1990) in Melbourne, Australia. The units are in degree celsius and there are 3650 observations. The source of the data was created by Australian Bureau of meteorology. We will analyze this dataset to capture the trend, applied transformation on the data where required, plot the ACF & PACF’s and coefficient tests on suitable models, and forecast for the next five years.
# loading relevant packages into rstudio
library(readr)
library(dplyr)
library(tidyr)
library(TSA)
library(tseries)
library(lmtest)
library(forecast)
library(fUnitRoots)
library(FitAR)
library(astsa)
# reading the dataset into R
Mel_Min_temp <- read.csv("Minimun Daily Temperature.csv", header = TRUE)
head(Mel_Min_temp,5)
## ï..Year Month Day Minimum.Daily.Temperature.Degree..Degree.C..
## 1 1981 1 1 20.7
## 2 1981 1 2 17.9
## 3 1981 1 3 18.8
## 4 1981 1 4 14.6
## 5 1981 1 5 15.8
# converting the dataframe to time series object
min_TempTS <- ts(Mel_Min_temp$Minimum.Daily.Temperature.Degree..Degree.C..,
start=c(1981, 1), end=c(1990, 365), frequency = 365)
#checking the class of the dataset
class(min_TempTS)
## [1] "ts"
#plotting time Series data
plot(min_TempTS , col=c("blue"), ylab='Min temperature', xlab='Time', type='o',
main = "Time series plot of minimum temperature in Melbourne.")
Figure 1: shows the changes in daily minimum temperature in melbourne from 1981 to 1990. We can conclude the plot as well as some strong cyclic behaviour. there is no apparent trend in the data over this period.
#converting daily minimum temperature to a monthly mean teamperature to better see seasonality
monthlyMinTemp <- aggregate(Mel_Min_temp$Minimum.Daily.Temperature.Degree..Degree.C..~Month+Mel_Min_temp$ï..Year,
Mel_Min_temp, mean )
head(monthlyMinTemp,5)
## Month Mel_Min_temp$ï..Year
## 1 1 1981
## 2 2 1981
## 3 3 1981
## 4 4 1981
## 5 5 1981
## Mel_Min_temp$Minimum.Daily.Temperature.Degree..Degree.C..
## 1 17.712903
## 2 17.678571
## 3 13.500000
## 4 12.356667
## 5 9.490323
# converting monthly temperature data into times series data
monthlyMinTempTS <- ts(monthlyMinTemp$`Mel_Min_temp$Minimum.Daily.Temperature.Degree..Degree.C..`,
start=c(1981, 1), end=c(1990, 12), frequency = 12)
monthlyMinTempTS
## Jan Feb Mar Apr May Jun Jul
## 1981 17.712903 17.678571 13.500000 12.356667 9.490323 7.306667 7.577419
## 1982 16.567742 15.921429 14.935484 11.470000 9.583871 5.606667 4.641935
## 1983 13.180645 16.807143 15.777419 10.596667 10.116129 6.600000 6.890323
## 1984 14.309677 14.944828 12.867742 10.750000 8.112903 7.730000 5.987097
## 1985 14.219355 14.032143 15.877419 12.976667 9.419355 7.073333 6.135484
## 1986 13.825806 14.196429 14.690323 11.653333 10.274194 7.526667 6.961290
## 1987 13.235484 13.889286 12.619355 12.250000 9.806452 8.273333 5.983871
## 1988 16.493548 14.524138 14.748387 12.833333 11.387097 8.386667 8.232258
## 1989 15.180645 16.371429 15.803226 12.563333 10.725806 6.560000 6.332258
## 1990 15.577419 15.417857 14.835484 13.433333 9.748387 7.720000 8.183871
## Aug Sep Oct Nov Dec
## 1981 7.238710 10.143333 10.087097 11.890000 13.680645
## 1982 7.903226 7.280000 9.545161 12.486667 13.754839
## 1983 8.706452 9.210000 10.312903 11.993333 14.396774
## 1984 8.696774 8.046667 10.632258 12.623333 12.643333
## 1985 7.635484 8.803333 10.490323 13.073333 14.109677
## 1986 7.387097 8.933333 9.683871 11.793333 12.935484
## 1987 8.022581 9.810000 10.238710 13.150000 13.254839
## 1988 8.725806 9.883333 10.890323 12.253333 15.436667
## 1989 6.770968 8.486667 9.867742 12.876667 13.951613
## 1990 7.825806 9.166667 11.345161 12.656667 14.367742
plot(monthlyMinTempTS, col=c("blue"), ylab='Min temperature', xlab='Time', type='o',
main = "Time series plot of monthly minimum temperature in Melbourne.")
After converting the daily minimum temperature to a monthly mean max temperature, we can clearly see a strong seasonality pattern. Further Analysis will need to be performed.
# scatterPlot to Check correlations of changes in minimum daily temperature
y = min_TempTS # read the daily min temp series into y
x = zlag(min_TempTS) # generate first lag of the min temp series
head(y)
## Time Series:
## Start = c(1981, 1)
## End = c(1981, 6)
## Frequency = 365
## [1] 20.7 17.9 18.8 14.6 15.8 15.8
head(x)
## [1] NA 20.7 17.9 18.8 14.6 15.8
index = 2:length(x) # Create an index to get rid of the first NA value in x
cor(y[index],x[index]) # Calculate correlation between numerical values in x and y
## [1] 0.7748702
plot(y[index],x[index],ylab='Min temperature series', xlab='The first lag of min temperature series', main = 'Scatter plot of min temperature series and its first lag')
As Scatter plot shows, the correlation value 0.774 proved that there is strong positive linear relationship between previous day’s min temperature on the next day’s min temperature
bb = monthlyMinTempTS
aa = zlag(monthlyMinTempTS)
index = 2: length(aa)
cor(bb[index], aa[index])
## [1] 0.8020674
We can see an upward trend and high correlation
plot(y = monthlyMinTempTS, x = zlag(monthlyMinTempTS), ylab = 'Min temp', xlab = 'Previous Year temp')
####Daily data
day.= season(min_TempTS)
model1_Daily = lm(min_TempTS~day.)
summary(model1_Daily)
##
## Call:
## lm(formula = min_TempTS ~ day.)
##
## Residuals:
## Min 1Q Median 3Q Max
## -8.300 -1.808 -0.070 1.700 11.870
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.585e+01 8.760e-01 18.094 < 2e-16 ***
## day.Season-2 -5.700e-01 1.239e+00 -0.460 0.645459
## day.Season-3 -1.160e+00 1.239e+00 -0.936 0.349142
## day.Season-4 -1.810e+00 1.239e+00 -1.461 0.144087
## day.Season-5 -2.000e+00 1.239e+00 -1.614 0.106523
## day.Season-6 -2.190e+00 1.239e+00 -1.768 0.077181 .
## day.Season-7 -1.100e+00 1.239e+00 -0.888 0.374630
## day.Season-8 -9.300e-01 1.239e+00 -0.751 0.452872
## day.Season-9 -6.600e-01 1.239e+00 -0.533 0.594227
## day.Season-10 -4.000e-01 1.239e+00 -0.323 0.746797
## day.Season-11 -5.300e-01 1.239e+00 -0.428 0.668801
## day.Season-12 -6.800e-01 1.239e+00 -0.549 0.583100
## day.Season-13 -9.000e-01 1.239e+00 -0.727 0.467579
## day.Season-14 5.500e-01 1.239e+00 0.444 0.657088
## day.Season-15 8.800e-01 1.239e+00 0.710 0.477529
## day.Season-16 -5.000e-02 1.239e+00 -0.040 0.967807
## day.Season-17 -9.000e-01 1.239e+00 -0.727 0.467579
## day.Season-18 -7.600e-01 1.239e+00 -0.613 0.539591
## day.Season-19 -1.600e+00 1.239e+00 -1.292 0.196597
## day.Season-20 -3.500e-01 1.239e+00 -0.283 0.777554
## day.Season-21 -9.100e-01 1.239e+00 -0.735 0.462648
## day.Season-22 -1.740e+00 1.239e+00 -1.405 0.160240
## day.Season-23 -1.690e+00 1.239e+00 -1.364 0.172592
## day.Season-24 -1.320e+00 1.239e+00 -1.066 0.286708
## day.Season-25 -1.050e+00 1.239e+00 -0.848 0.396727
## day.Season-26 -8.600e-01 1.239e+00 -0.694 0.487594
## day.Season-27 -8.600e-01 1.239e+00 -0.694 0.487594
## day.Season-28 -1.060e+00 1.239e+00 -0.856 0.392246
## day.Season-29 -1.600e-01 1.239e+00 -0.129 0.897241
## day.Season-30 4.600e-01 1.239e+00 0.371 0.710418
## day.Season-31 -1.060e+00 1.239e+00 -0.856 0.392246
## day.Season-32 -7.600e-01 1.239e+00 -0.613 0.539591
## day.Season-33 -1.860e+00 1.239e+00 -1.501 0.133335
## day.Season-34 -1.320e+00 1.239e+00 -1.066 0.286708
## day.Season-35 -3.000e-01 1.239e+00 -0.242 0.808664
## day.Season-36 -1.630e+00 1.239e+00 -1.316 0.188337
## day.Season-37 -1.120e+00 1.239e+00 -0.904 0.366009
## day.Season-38 -4.900e-01 1.239e+00 -0.396 0.692468
## day.Season-39 1.180e+00 1.239e+00 0.953 0.340897
## day.Season-40 5.600e-01 1.239e+00 0.452 0.651263
## day.Season-41 -1.140e+00 1.239e+00 -0.920 0.357513
## day.Season-42 -1.140e+00 1.239e+00 -0.920 0.357513
## day.Season-43 -1.080e+00 1.239e+00 -0.872 0.383376
## day.Season-44 -5.300e-01 1.239e+00 -0.428 0.668801
## day.Season-45 1.180e+00 1.239e+00 0.953 0.340897
## day.Season-46 2.120e+00 1.239e+00 1.711 0.087115 .
## day.Season-47 1.420e+00 1.239e+00 1.146 0.251768
## day.Season-48 8.000e-01 1.239e+00 0.646 0.518464
## day.Season-49 -9.700e-01 1.239e+00 -0.783 0.433675
## day.Season-50 -1.260e+00 1.239e+00 -1.017 0.309175
## day.Season-51 -2.400e-01 1.239e+00 -0.194 0.846395
## day.Season-52 5.000e-02 1.239e+00 0.040 0.967807
## day.Season-53 -2.500e-01 1.239e+00 -0.202 0.840079
## day.Season-54 -1.280e+00 1.239e+00 -1.033 0.301560
## day.Season-55 -2.020e+00 1.239e+00 -1.631 0.103069
## day.Season-56 -1.310e+00 1.239e+00 -1.057 0.290374
## day.Season-57 -1.390e+00 1.239e+00 -1.122 0.261923
## day.Season-58 -6.700e-01 1.239e+00 -0.541 0.588651
## day.Season-59 2.100e-01 1.239e+00 0.170 0.865399
## day.Season-60 6.700e-01 1.239e+00 0.541 0.588651
## day.Season-61 1.700e-01 1.239e+00 0.137 0.890858
## day.Season-62 -6.700e-01 1.239e+00 -0.541 0.588651
## day.Season-63 -1.800e-01 1.239e+00 -0.145 0.884482
## day.Season-64 4.800e-01 1.239e+00 0.387 0.698433
## day.Season-65 -5.673e-13 1.239e+00 0.000 1.000000
## day.Season-66 -2.800e-01 1.239e+00 -0.226 0.821196
## day.Season-67 -4.600e-01 1.239e+00 -0.371 0.710418
## day.Season-68 -1.220e+00 1.239e+00 -0.985 0.324784
## day.Season-69 -2.370e+00 1.239e+00 -1.913 0.055817 .
## day.Season-70 -1.750e+00 1.239e+00 -1.413 0.157852
## day.Season-71 -1.410e+00 1.239e+00 -1.138 0.255122
## day.Season-72 -2.770e+00 1.239e+00 -2.236 0.025417 *
## day.Season-73 -1.750e+00 1.239e+00 -1.413 0.157852
## day.Season-74 -1.430e+00 1.239e+00 -1.154 0.248445
## day.Season-75 -1.240e+00 1.239e+00 -1.001 0.316917
## day.Season-76 -2.080e+00 1.239e+00 -1.679 0.093239 .
## day.Season-77 -1.380e+00 1.239e+00 -1.114 0.265370
## day.Season-78 -7.500e-01 1.239e+00 -0.605 0.544940
## day.Season-79 -4.200e-01 1.239e+00 -0.339 0.734603
## day.Season-80 -1.170e+00 1.239e+00 -0.944 0.345004
## day.Season-81 -6.300e-01 1.239e+00 -0.509 0.611098
## day.Season-82 -8.500e-01 1.239e+00 -0.686 0.492669
## day.Season-83 -1.350e+00 1.239e+00 -1.090 0.275898
## day.Season-84 -2.160e+00 1.239e+00 -1.744 0.081319 .
## day.Season-85 -2.550e+00 1.239e+00 -2.058 0.039627 *
## day.Season-86 -1.910e+00 1.239e+00 -1.542 0.123216
## day.Season-87 -2.830e+00 1.239e+00 -2.284 0.022408 *
## day.Season-88 -3.370e+00 1.239e+00 -2.720 0.006555 **
## day.Season-89 -2.120e+00 1.239e+00 -1.711 0.087115 .
## day.Season-90 -1.780e+00 1.239e+00 -1.437 0.150850
## day.Season-91 -2.320e+00 1.239e+00 -1.873 0.061188 .
## day.Season-92 -2.670e+00 1.239e+00 -2.155 0.031210 *
## day.Season-93 -2.800e+00 1.239e+00 -2.260 0.023871 *
## day.Season-94 -1.780e+00 1.239e+00 -1.437 0.150850
## day.Season-95 -1.980e+00 1.239e+00 -1.598 0.110068
## day.Season-96 -2.100e+00 1.239e+00 -1.695 0.090135 .
## day.Season-97 -3.080e+00 1.239e+00 -2.486 0.012958 *
## day.Season-98 -3.360e+00 1.239e+00 -2.712 0.006717 **
## day.Season-99 -3.840e+00 1.239e+00 -3.100 0.001953 **
## day.Season-100 -3.990e+00 1.239e+00 -3.221 0.001291 **
## day.Season-101 -2.560e+00 1.239e+00 -2.067 0.038858 *
## day.Season-102 -2.160e+00 1.239e+00 -1.744 0.081319 .
## day.Season-103 -1.610e+00 1.239e+00 -1.300 0.193815
## day.Season-104 -1.890e+00 1.239e+00 -1.526 0.127189
## day.Season-105 -2.630e+00 1.239e+00 -2.123 0.033827 *
## day.Season-106 -4.940e+00 1.239e+00 -3.988 6.82e-05 ***
## day.Season-107 -5.760e+00 1.239e+00 -4.650 3.46e-06 ***
## day.Season-108 -4.830e+00 1.239e+00 -3.899 9.86e-05 ***
## day.Season-109 -4.930e+00 1.239e+00 -3.980 7.05e-05 ***
## day.Season-110 -5.600e+00 1.239e+00 -4.520 6.39e-06 ***
## day.Season-111 -5.510e+00 1.239e+00 -4.448 8.96e-06 ***
## day.Season-112 -4.810e+00 1.239e+00 -3.883 0.000105 ***
## day.Season-113 -4.300e+00 1.239e+00 -3.471 0.000525 ***
## day.Season-114 -4.390e+00 1.239e+00 -3.544 0.000400 ***
## day.Season-115 -4.820e+00 1.239e+00 -3.891 0.000102 ***
## day.Season-116 -5.250e+00 1.239e+00 -4.238 2.32e-05 ***
## day.Season-117 -4.600e+00 1.239e+00 -3.713 0.000208 ***
## day.Season-118 -4.540e+00 1.239e+00 -3.665 0.000251 ***
## day.Season-119 -4.040e+00 1.239e+00 -3.261 0.001121 **
## day.Season-120 -5.370e+00 1.239e+00 -4.335 1.50e-05 ***
## day.Season-121 -5.190e+00 1.239e+00 -4.190 2.87e-05 ***
## day.Season-122 -4.040e+00 1.239e+00 -3.261 0.001121 **
## day.Season-123 -3.970e+00 1.239e+00 -3.205 0.001365 **
## day.Season-124 -3.810e+00 1.239e+00 -3.076 0.002118 **
## day.Season-125 -4.400e+00 1.239e+00 -3.552 0.000388 ***
## day.Season-126 -4.250e+00 1.239e+00 -3.431 0.000609 ***
## day.Season-127 -6.030e+00 1.239e+00 -4.868 1.18e-06 ***
## day.Season-128 -6.290e+00 1.239e+00 -5.077 4.04e-07 ***
## day.Season-129 -6.210e+00 1.239e+00 -5.013 5.65e-07 ***
## day.Season-130 -5.070e+00 1.239e+00 -4.093 4.37e-05 ***
## day.Season-131 -5.110e+00 1.239e+00 -4.125 3.80e-05 ***
## day.Season-132 -4.880e+00 1.239e+00 -3.939 8.34e-05 ***
## day.Season-133 -6.310e+00 1.239e+00 -5.094 3.71e-07 ***
## day.Season-134 -5.860e+00 1.239e+00 -4.730 2.34e-06 ***
## day.Season-135 -6.330e+00 1.239e+00 -5.110 3.41e-07 ***
## day.Season-136 -6.760e+00 1.239e+00 -5.457 5.20e-08 ***
## day.Season-137 -6.750e+00 1.239e+00 -5.449 5.44e-08 ***
## day.Season-138 -6.380e+00 1.239e+00 -5.150 2.76e-07 ***
## day.Season-139 -6.120e+00 1.239e+00 -4.940 8.19e-07 ***
## day.Season-140 -7.570e+00 1.239e+00 -6.111 1.11e-09 ***
## day.Season-141 -8.150e+00 1.239e+00 -6.579 5.49e-11 ***
## day.Season-142 -8.300e+00 1.239e+00 -6.700 2.44e-11 ***
## day.Season-143 -6.860e+00 1.239e+00 -5.538 3.31e-08 ***
## day.Season-144 -5.550e+00 1.239e+00 -4.480 7.71e-06 ***
## day.Season-145 -6.390e+00 1.239e+00 -5.158 2.64e-07 ***
## day.Season-146 -6.980e+00 1.239e+00 -5.634 1.90e-08 ***
## day.Season-147 -6.420e+00 1.239e+00 -5.182 2.32e-07 ***
## day.Season-148 -6.150e+00 1.239e+00 -4.964 7.24e-07 ***
## day.Season-149 -6.260e+00 1.239e+00 -5.053 4.58e-07 ***
## day.Season-150 -5.630e+00 1.239e+00 -4.545 5.70e-06 ***
## day.Season-151 -6.790e+00 1.239e+00 -5.481 4.55e-08 ***
## day.Season-152 -7.660e+00 1.239e+00 -6.183 7.05e-10 ***
## day.Season-153 -8.000e+00 1.239e+00 -6.458 1.22e-10 ***
## day.Season-154 -8.840e+00 1.239e+00 -7.136 1.18e-12 ***
## day.Season-155 -7.070e+00 1.239e+00 -5.707 1.25e-08 ***
## day.Season-156 -8.060e+00 1.239e+00 -6.506 8.87e-11 ***
## day.Season-157 -8.520e+00 1.239e+00 -6.878 7.26e-12 ***
## day.Season-158 -8.290e+00 1.239e+00 -6.692 2.58e-11 ***
## day.Season-159 -8.730e+00 1.239e+00 -7.047 2.22e-12 ***
## day.Season-160 -8.300e+00 1.239e+00 -6.700 2.44e-11 ***
## day.Season-161 -7.160e+00 1.239e+00 -5.780 8.18e-09 ***
## day.Season-162 -7.980e+00 1.239e+00 -6.442 1.35e-10 ***
## day.Season-163 -8.610e+00 1.239e+00 -6.950 4.38e-12 ***
## day.Season-164 -8.590e+00 1.239e+00 -6.934 4.90e-12 ***
## day.Season-165 -7.660e+00 1.239e+00 -6.183 7.05e-10 ***
## day.Season-166 -7.800e+00 1.239e+00 -6.296 3.45e-10 ***
## day.Season-167 -8.800e+00 1.239e+00 -7.104 1.48e-12 ***
## day.Season-168 -9.730e+00 1.239e+00 -7.854 5.40e-15 ***
## day.Season-169 -9.840e+00 1.239e+00 -7.943 2.68e-15 ***
## day.Season-170 -8.620e+00 1.239e+00 -6.958 4.14e-12 ***
## day.Season-171 -8.660e+00 1.239e+00 -6.991 3.30e-12 ***
## day.Season-172 -8.700e+00 1.239e+00 -7.023 2.63e-12 ***
## day.Season-173 -8.940e+00 1.239e+00 -7.217 6.59e-13 ***
## day.Season-174 -9.080e+00 1.239e+00 -7.330 2.89e-13 ***
## day.Season-175 -9.040e+00 1.239e+00 -7.297 3.66e-13 ***
## day.Season-176 -9.250e+00 1.239e+00 -7.467 1.05e-13 ***
## day.Season-177 -1.005e+01 1.239e+00 -8.113 6.92e-16 ***
## day.Season-178 -9.360e+00 1.239e+00 -7.556 5.37e-14 ***
## day.Season-179 -8.810e+00 1.239e+00 -7.112 1.40e-12 ***
## day.Season-180 -9.280e+00 1.239e+00 -7.491 8.73e-14 ***
## day.Season-181 -7.940e+00 1.239e+00 -6.409 1.67e-10 ***
## day.Season-182 -8.030e+00 1.239e+00 -6.482 1.04e-10 ***
## day.Season-183 -8.720e+00 1.239e+00 -7.039 2.35e-12 ***
## day.Season-184 -8.970e+00 1.239e+00 -7.241 5.53e-13 ***
## day.Season-185 -9.620e+00 1.239e+00 -7.766 1.08e-14 ***
## day.Season-186 -9.780e+00 1.239e+00 -7.895 3.93e-15 ***
## day.Season-187 -9.860e+00 1.239e+00 -7.959 2.36e-15 ***
## day.Season-188 -9.270e+00 1.239e+00 -7.483 9.27e-14 ***
## day.Season-189 -8.100e+00 1.239e+00 -6.539 7.18e-11 ***
## day.Season-190 -8.250e+00 1.239e+00 -6.660 3.20e-11 ***
## day.Season-191 -9.600e+00 1.239e+00 -7.749 1.22e-14 ***
## day.Season-192 -9.160e+00 1.239e+00 -7.394 1.80e-13 ***
## day.Season-193 -8.850e+00 1.239e+00 -7.144 1.11e-12 ***
## day.Season-194 -9.470e+00 1.239e+00 -7.644 2.74e-14 ***
## day.Season-195 -1.003e+01 1.239e+00 -8.097 7.89e-16 ***
## day.Season-196 -9.400e+00 1.239e+00 -7.588 4.21e-14 ***
## day.Season-197 -9.710e+00 1.239e+00 -7.838 6.13e-15 ***
## day.Season-198 -9.380e+00 1.239e+00 -7.572 4.75e-14 ***
## day.Season-199 -9.060e+00 1.239e+00 -7.314 3.25e-13 ***
## day.Season-200 -8.760e+00 1.239e+00 -7.071 1.87e-12 ***
## day.Season-201 -9.570e+00 1.239e+00 -7.725 1.47e-14 ***
## day.Season-202 -9.070e+00 1.239e+00 -7.322 3.07e-13 ***
## day.Season-203 -9.910e+00 1.239e+00 -8.000 1.71e-15 ***
## day.Season-204 -9.640e+00 1.239e+00 -7.782 9.51e-15 ***
## day.Season-205 -9.660e+00 1.239e+00 -7.798 8.39e-15 ***
## day.Season-206 -9.890e+00 1.239e+00 -7.984 1.95e-15 ***
## day.Season-207 -9.300e+00 1.239e+00 -7.507 7.73e-14 ***
## day.Season-208 -9.520e+00 1.239e+00 -7.685 2.01e-14 ***
## day.Season-209 -8.850e+00 1.239e+00 -7.144 1.11e-12 ***
## day.Season-210 -7.350e+00 1.239e+00 -5.933 3.28e-09 ***
## day.Season-211 -8.900e+00 1.239e+00 -7.184 8.32e-13 ***
## day.Season-212 -8.310e+00 1.239e+00 -6.708 2.31e-11 ***
## day.Season-213 -7.980e+00 1.239e+00 -6.442 1.35e-10 ***
## day.Season-214 -7.170e+00 1.239e+00 -5.788 7.80e-09 ***
## day.Season-215 -7.720e+00 1.239e+00 -6.232 5.20e-10 ***
## day.Season-216 -7.460e+00 1.239e+00 -6.022 1.91e-09 ***
## day.Season-217 -7.970e+00 1.239e+00 -6.434 1.43e-10 ***
## day.Season-218 -8.250e+00 1.239e+00 -6.660 3.20e-11 ***
## day.Season-219 -8.220e+00 1.239e+00 -6.635 3.77e-11 ***
## day.Season-220 -8.410e+00 1.239e+00 -6.789 1.34e-11 ***
## day.Season-221 -8.340e+00 1.239e+00 -6.732 1.96e-11 ***
## day.Season-222 -8.120e+00 1.239e+00 -6.555 6.45e-11 ***
## day.Season-223 -9.360e+00 1.239e+00 -7.556 5.37e-14 ***
## day.Season-224 -9.270e+00 1.239e+00 -7.483 9.27e-14 ***
## day.Season-225 -9.230e+00 1.239e+00 -7.451 1.18e-13 ***
## day.Season-226 -7.870e+00 1.239e+00 -6.353 2.40e-10 ***
## day.Season-227 -6.580e+00 1.239e+00 -5.312 1.16e-07 ***
## day.Season-228 -6.570e+00 1.239e+00 -5.304 1.21e-07 ***
## day.Season-229 -7.230e+00 1.239e+00 -5.836 5.86e-09 ***
## day.Season-230 -8.840e+00 1.239e+00 -7.136 1.18e-12 ***
## day.Season-231 -8.250e+00 1.239e+00 -6.660 3.20e-11 ***
## day.Season-232 -7.430e+00 1.239e+00 -5.998 2.22e-09 ***
## day.Season-233 -7.660e+00 1.239e+00 -6.183 7.05e-10 ***
## day.Season-234 -7.720e+00 1.239e+00 -6.232 5.20e-10 ***
## day.Season-235 -7.790e+00 1.239e+00 -6.288 3.63e-10 ***
## day.Season-236 -7.390e+00 1.239e+00 -5.965 2.70e-09 ***
## day.Season-237 -7.590e+00 1.239e+00 -6.127 1.00e-09 ***
## day.Season-238 -7.920e+00 1.239e+00 -6.393 1.85e-10 ***
## day.Season-239 -9.050e+00 1.239e+00 -7.305 3.45e-13 ***
## day.Season-240 -8.290e+00 1.239e+00 -6.692 2.58e-11 ***
## day.Season-241 -6.710e+00 1.239e+00 -5.417 6.51e-08 ***
## day.Season-242 -8.570e+00 1.239e+00 -6.918 5.48e-12 ***
## day.Season-243 -8.090e+00 1.239e+00 -6.530 7.57e-11 ***
## day.Season-244 -7.450e+00 1.239e+00 -6.014 2.01e-09 ***
## day.Season-245 -6.060e+00 1.239e+00 -4.892 1.05e-06 ***
## day.Season-246 -6.640e+00 1.239e+00 -5.360 8.90e-08 ***
## day.Season-247 -7.900e+00 1.239e+00 -6.377 2.06e-10 ***
## day.Season-248 -7.950e+00 1.239e+00 -6.417 1.58e-10 ***
## day.Season-249 -7.400e+00 1.239e+00 -5.974 2.57e-09 ***
## day.Season-250 -8.100e+00 1.239e+00 -6.539 7.18e-11 ***
## day.Season-251 -7.380e+00 1.239e+00 -5.957 2.83e-09 ***
## day.Season-252 -6.310e+00 1.239e+00 -5.094 3.71e-07 ***
## day.Season-253 -6.390e+00 1.239e+00 -5.158 2.64e-07 ***
## day.Season-254 -5.400e+00 1.239e+00 -4.359 1.35e-05 ***
## day.Season-255 -6.870e+00 1.239e+00 -5.546 3.16e-08 ***
## day.Season-256 -7.600e+00 1.239e+00 -6.135 9.53e-10 ***
## day.Season-257 -8.250e+00 1.239e+00 -6.660 3.20e-11 ***
## day.Season-258 -8.270e+00 1.239e+00 -6.676 2.88e-11 ***
## day.Season-259 -6.730e+00 1.239e+00 -5.433 5.96e-08 ***
## day.Season-260 -6.110e+00 1.239e+00 -4.932 8.54e-07 ***
## day.Season-261 -6.160e+00 1.239e+00 -4.973 6.95e-07 ***
## day.Season-262 -5.780e+00 1.239e+00 -4.666 3.20e-06 ***
## day.Season-263 -6.540e+00 1.239e+00 -5.279 1.38e-07 ***
## day.Season-264 -7.860e+00 1.239e+00 -6.345 2.53e-10 ***
## day.Season-265 -7.420e+00 1.239e+00 -5.990 2.33e-09 ***
## day.Season-266 -6.780e+00 1.239e+00 -5.473 4.76e-08 ***
## day.Season-267 -6.650e+00 1.239e+00 -5.368 8.51e-08 ***
## day.Season-268 -5.270e+00 1.239e+00 -4.254 2.16e-05 ***
## day.Season-269 -6.830e+00 1.239e+00 -5.513 3.79e-08 ***
## day.Season-270 -6.040e+00 1.239e+00 -4.876 1.14e-06 ***
## day.Season-271 -6.290e+00 1.239e+00 -5.077 4.04e-07 ***
## day.Season-272 -6.610e+00 1.239e+00 -5.336 1.02e-07 ***
## day.Season-273 -6.520e+00 1.239e+00 -5.263 1.51e-07 ***
## day.Season-274 -6.230e+00 1.239e+00 -5.029 5.19e-07 ***
## day.Season-275 -5.320e+00 1.239e+00 -4.294 1.80e-05 ***
## day.Season-276 -5.780e+00 1.239e+00 -4.666 3.20e-06 ***
## day.Season-277 -5.580e+00 1.239e+00 -4.504 6.89e-06 ***
## day.Season-278 -5.470e+00 1.239e+00 -4.416 1.04e-05 ***
## day.Season-279 -6.750e+00 1.239e+00 -5.449 5.44e-08 ***
## day.Season-280 -6.320e+00 1.239e+00 -5.102 3.56e-07 ***
## day.Season-281 -6.220e+00 1.239e+00 -5.021 5.41e-07 ***
## day.Season-282 -5.830e+00 1.239e+00 -4.706 2.63e-06 ***
## day.Season-283 -6.270e+00 1.239e+00 -5.061 4.39e-07 ***
## day.Season-284 -6.640e+00 1.239e+00 -5.360 8.90e-08 ***
## day.Season-285 -5.900e+00 1.239e+00 -4.763 1.99e-06 ***
## day.Season-286 -5.080e+00 1.239e+00 -4.101 4.22e-05 ***
## day.Season-287 -5.220e+00 1.239e+00 -4.214 2.58e-05 ***
## day.Season-288 -5.390e+00 1.239e+00 -4.351 1.40e-05 ***
## day.Season-289 -4.860e+00 1.239e+00 -3.923 8.92e-05 ***
## day.Season-290 -6.720e+00 1.239e+00 -5.425 6.23e-08 ***
## day.Season-291 -5.420e+00 1.239e+00 -4.375 1.25e-05 ***
## day.Season-292 -5.340e+00 1.239e+00 -4.311 1.68e-05 ***
## day.Season-293 -7.140e+00 1.239e+00 -5.764 8.99e-09 ***
## day.Season-294 -5.360e+00 1.239e+00 -4.327 1.56e-05 ***
## day.Season-295 -6.250e+00 1.239e+00 -5.045 4.78e-07 ***
## day.Season-296 -5.430e+00 1.239e+00 -4.383 1.21e-05 ***
## day.Season-297 -5.190e+00 1.239e+00 -4.190 2.87e-05 ***
## day.Season-298 -5.200e+00 1.239e+00 -4.198 2.77e-05 ***
## day.Season-299 -4.980e+00 1.239e+00 -4.020 5.95e-05 ***
## day.Season-300 -4.280e+00 1.239e+00 -3.455 0.000557 ***
## day.Season-301 -4.750e+00 1.239e+00 -3.834 0.000128 ***
## day.Season-302 -4.630e+00 1.239e+00 -3.737 0.000189 ***
## day.Season-303 -4.040e+00 1.239e+00 -3.261 0.001121 **
## day.Season-304 -4.930e+00 1.239e+00 -3.980 7.05e-05 ***
## day.Season-305 -4.200e+00 1.239e+00 -3.390 0.000706 ***
## day.Season-306 -3.330e+00 1.239e+00 -2.688 0.007223 **
## day.Season-307 -4.050e+00 1.239e+00 -3.269 0.001089 **
## day.Season-308 -3.320e+00 1.239e+00 -2.680 0.007399 **
## day.Season-309 -3.030e+00 1.239e+00 -2.446 0.014501 *
## day.Season-310 -2.840e+00 1.239e+00 -2.293 0.021938 *
## day.Season-311 -3.450e+00 1.239e+00 -2.785 0.005384 **
## day.Season-312 -3.170e+00 1.239e+00 -2.559 0.010544 *
## day.Season-313 -3.080e+00 1.239e+00 -2.486 0.012958 *
## day.Season-314 -3.710e+00 1.239e+00 -2.995 0.002766 **
## day.Season-315 -4.590e+00 1.239e+00 -3.705 0.000215 ***
## day.Season-316 -4.490e+00 1.239e+00 -3.624 0.000294 ***
## day.Season-317 -3.430e+00 1.239e+00 -2.769 0.005658 **
## day.Season-318 -2.350e+00 1.239e+00 -1.897 0.057916 .
## day.Season-319 -3.600e+00 1.239e+00 -2.906 0.003685 **
## day.Season-320 -4.770e+00 1.239e+00 -3.850 0.000120 ***
## day.Season-321 -4.130e+00 1.239e+00 -3.334 0.000866 ***
## day.Season-322 -4.100e+00 1.239e+00 -3.310 0.000944 ***
## day.Season-323 -3.620e+00 1.239e+00 -2.922 0.003500 **
## day.Season-324 -3.290e+00 1.239e+00 -2.656 0.007951 **
## day.Season-325 -3.800e+00 1.239e+00 -3.067 0.002176 **
## day.Season-326 -4.430e+00 1.239e+00 -3.576 0.000354 ***
## day.Season-327 -2.660e+00 1.239e+00 -2.147 0.031848 *
## day.Season-328 -2.440e+00 1.239e+00 -1.970 0.048963 *
## day.Season-329 -3.000e+00 1.239e+00 -2.422 0.015502 *
## day.Season-330 -2.770e+00 1.239e+00 -2.236 0.025417 *
## day.Season-331 -2.400e+00 1.239e+00 -1.937 0.052788 .
## day.Season-332 -2.570e+00 1.239e+00 -2.075 0.038103 *
## day.Season-333 -1.880e+00 1.239e+00 -1.518 0.129213
## day.Season-334 -2.460e+00 1.239e+00 -1.986 0.047140 *
## day.Season-335 -3.000e+00 1.239e+00 -2.422 0.015502 *
## day.Season-336 -2.940e+00 1.239e+00 -2.373 0.017689 *
## day.Season-337 -2.100e+00 1.239e+00 -1.695 0.090135 .
## day.Season-338 -2.510e+00 1.239e+00 -2.026 0.042830 *
## day.Season-339 -2.140e+00 1.239e+00 -1.727 0.084176 .
## day.Season-340 -1.240e+00 1.239e+00 -1.001 0.316917
## day.Season-341 -8.800e-01 1.239e+00 -0.710 0.477529
## day.Season-342 -2.970e+00 1.239e+00 -2.397 0.016564 *
## day.Season-343 -2.090e+00 1.239e+00 -1.687 0.091677 .
## day.Season-344 -2.020e+00 1.239e+00 -1.631 0.103069
## day.Season-345 -1.830e+00 1.239e+00 -1.477 0.139709
## day.Season-346 -2.000e+00 1.239e+00 -1.614 0.106523
## day.Season-347 -2.280e+00 1.239e+00 -1.840 0.065787 .
## day.Season-348 -2.930e+00 1.239e+00 -2.365 0.018079 *
## day.Season-349 -1.880e+00 1.239e+00 -1.518 0.129213
## day.Season-350 -1.130e+00 1.239e+00 -0.912 0.361746
## day.Season-351 -1.070e+00 1.239e+00 -0.864 0.387795
## day.Season-352 -1.150e+00 1.239e+00 -0.928 0.353312
## day.Season-353 -2.300e+00 1.239e+00 -1.857 0.063453 .
## day.Season-354 -2.200e+00 1.239e+00 -1.776 0.075841 .
## day.Season-355 -2.770e+00 1.239e+00 -2.236 0.025417 *
## day.Season-356 -3.290e+00 1.239e+00 -2.656 0.007951 **
## day.Season-357 -2.780e+00 1.239e+00 -2.244 0.024892 *
## day.Season-358 -2.300e+00 1.239e+00 -1.857 0.063453 .
## day.Season-359 -1.150e+00 1.239e+00 -0.928 0.353312
## day.Season-360 -1.660e+00 1.239e+00 -1.340 0.180337
## day.Season-361 -2.250e+00 1.239e+00 -1.816 0.069420 .
## day.Season-362 -2.840e+00 1.239e+00 -2.293 0.021938 *
## day.Season-363 -2.210e+00 1.239e+00 -1.784 0.074519 .
## day.Season-364 -3.000e-01 1.239e+00 -0.242 0.808664
## day.Season-365 -2.300e-01 1.239e+00 -0.186 0.852720
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.77 on 3285 degrees of freedom
## Multiple R-squared: 0.5834, Adjusted R-squared: 0.5372
## F-statistic: 12.64 on 364 and 3285 DF, p-value: < 2.2e-16
#output hidden due to large output
month.=season(monthlyMinTempTS) # period added to improve table display and this line sets up indicators
model2=lm(monthlyMinTempTS~month.-1) # -1 removes the intercept term
summary(model2)
##
## Call:
## lm(formula = monthlyMinTempTS ~ month. - 1)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.05065 -0.62012 0.03393 0.55556 2.68258
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## month.January 15.0303 0.3092 48.60 <2e-16 ***
## month.February 15.3783 0.3092 49.73 <2e-16 ***
## month.March 14.5655 0.3092 47.10 <2e-16 ***
## month.April 12.0883 0.3092 39.09 <2e-16 ***
## month.May 9.8665 0.3092 31.91 <2e-16 ***
## month.June 7.2783 0.3092 23.54 <2e-16 ***
## month.July 6.6926 0.3092 21.64 <2e-16 ***
## month.August 7.8913 0.3092 25.52 <2e-16 ***
## month.September 8.9763 0.3092 29.03 <2e-16 ***
## month.October 10.3094 0.3092 33.34 <2e-16 ***
## month.November 12.4797 0.3092 40.36 <2e-16 ***
## month.December 13.8532 0.3092 44.80 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.9779 on 108 degrees of freedom
## Multiple R-squared: 0.9936, Adjusted R-squared: 0.9929
## F-statistic: 1405 on 12 and 108 DF, p-value: < 2.2e-16
model3=lm(monthlyMinTempTS~month.) # remove -1 to include the intercept term in the model
summary(model3)
##
## Call:
## lm(formula = monthlyMinTempTS ~ month.)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2.05065 -0.62012 0.03393 0.55556 2.68258
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 15.0303 0.3092 48.605 < 2e-16 ***
## month.February 0.3480 0.4373 0.796 0.42792
## month.March -0.4648 0.4373 -1.063 0.29019
## month.April -2.9420 0.4373 -6.727 8.56e-10 ***
## month.May -5.1639 0.4373 -11.808 < 2e-16 ***
## month.June -7.7520 0.4373 -17.726 < 2e-16 ***
## month.July -8.3377 0.4373 -19.065 < 2e-16 ***
## month.August -7.1390 0.4373 -16.324 < 2e-16 ***
## month.September -6.0540 0.4373 -13.843 < 2e-16 ***
## month.October -4.7210 0.4373 -10.795 < 2e-16 ***
## month.November -2.5507 0.4373 -5.832 5.77e-08 ***
## month.December -1.1772 0.4373 -2.692 0.00824 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.9779 on 108 degrees of freedom
## Multiple R-squared: 0.912, Adjusted R-squared: 0.9031
## F-statistic: 101.8 on 11 and 108 DF, p-value: < 2.2e-16
all of the differences between January and the other months are statistically significant at 5% level in both models model2 and model3
#Model specification
#Plotting ACF with max 36 lags Because we have strong correlation at lags 12,24,36 and so on we consider the existence of seasonal auto correlation relationship.There is also a substantial correlation that needs to be considered.
par(mfrow=c(1,2))
acf(monthlyMinTempTS,lag.max=36)
pacf(monthlyMinTempTS, lag.max=36)
##Time series plot,ACF AND PACF of Minimum Monthly temperature after taking first difference
Although the general upward trend is resolved, we still have a seasonal effect pattern in time series plot.
plot(diff(monthlyMinTempTS),ylab='First Difference of Temperature',xlab='Time',main = "Figure-Time series plot of the first differences of Minimum Monthly temperature levels")
## ACF of first difference of Min Monthly temp levels
acf(as.vector(diff(monthlyMinTempTS)),lag.max=36,main="Figure-ACF of the first differences of Min monthly temp levels.")
pacf(as.vector(diff(monthlyMinTempTS)),lag.max=36,main="Figure-PACF of the first differences of Min monthly temp levels.")
Although the general upward trend is resolved, we still have a seasonal effect pattern in time series plot. So, we consider taking a seasonal difference along with the ordinary difference
plot(diff(diff(monthlyMinTempTS),lag=12),xlab='Time',ylab='First and Seasonal Difference of monthly min temp levels',main= "Figure-Time series plot of the first and seasonal differences of monthly min temp levels.")
###ACF of the first and seasonal differences of Monthly min temp levels
acf(as.vector(diff(diff(monthlyMinTempTS),lag=12)),lag.max=36,ci.type='ma',main="Figure 12. ACF of the first and seasonal differences of")
###PACF of the first and seasonal differences of Monthly min temp levels
pacf(as.vector(diff(diff(monthlyMinTempTS),lag=12)),lag.max=36,ci.type='ma',main="Figure 12. PACF of the first and seasonal differences of monthly min temp levels")
After taking a seasonal difference, we nearly get rid of the seasonality in the series and very little autocorrelation remains in the series. This plot also suggests that a simple model which incorporates the lag 1 and lag 12 autocorrelations might be adequate. We will consider specifying an ARIMA(0,1,1)×(0,1,1)12 model to this series
##Residuals approach
###When D=1 ###Fit SARIMA(0,0,0)x(0,1,0)12 model and display time series plots of the residuals
m1.monthlyMinTempTS = arima(monthlyMinTempTS,order=c(0,0,0),seasonal=list(order=c(0,1,0), period=12))
res.m1 = residuals(m1.monthlyMinTempTS);
plot(res.m1,xlab='Time',ylab='Residuals',main="m1-Time series plot of the residuals")
###ACF and PACF of residuals-m1
par(mfrow=c(1,2))
acf(res.m1, lag.max = 36, main = "m1-ACF of residuals")
pacf(res.m1, lag.max = 36, main = "m1-PACF of residuals")
When we focus on the autocorrelations at seasonal lags, there is no pattern implying the existence of a seasonal trend. However, the existence of an ordinary trend is obvious from the time series, ACF and PACF plots.
To get rid of the ordinary trend seen in the residuals, we will fit the SARIMA(0,1,0)x(0,1,0)12 model
m2.monthlyMinTempTS = arima(monthlyMinTempTS,order=c(0,1,0),seasonal=list(order=c(0,1,0), period=12))
res.m2 = residuals(m2.monthlyMinTempTS);
plot(res.m2,xlab='Time',ylab='Residuals',main="m2-Time series plot of the residuals")
###ACF and PACF of residuals-m2
par(mfrow=c(1,2))
acf(res.m2, lag.max = 36, main = "m2-ACF of residuals")
pacf(res.m2, lag.max = 36, main = "m2-PACF of residuals")
There is no evidence of an ordinary trend left in the latest residuals. The residuals of the model SARIMA(0,1,0)x(0,1,0)12 now includes SARMA and ARMA components.For the orders of SARMA component, we will consider the lags s,2s,3,…, i.e. 12, 24, 36, … These are shown as 1, 2, 3, … in both the ACF and PACF plots.
When we consider the lags 1, 2, 3, … of ACF plot, the correlation at lag 1 is significant, and in PACF there is a decreasing pattern at lags 1, 2, 3, … This implies the existence of an SMA(1) component.
m3.monthlyMinTempTS = arima(monthlyMinTempTS,order=c(0,1,0),seasonal=list(order=c(0,1,1), period=12))
res.m3 = residuals(m3.monthlyMinTempTS);
plot(res.m3,xlab='Time',ylab='Residuals',main="m3-Time series plot of the residuals")
###ACF and PACF of residuals-m3
par(mfrow=c(1,2))
acf(res.m3, lag.max = 36, main = "m3-ACF of residuals")
pacf(res.m3, lag.max = 36, main = "m3-PACF of residuals")
At the seasonal lags, especially at the first seasonal lag in ACF, the autocorrelations became insignificant or slightly significant after adding the seasonal component. We will use the resulting ACF and PACF plots to specify the orders of ARMA component as there is no highly significant correlation at the lags s,2s,3s,….
The last ACF-PACF pair has significant pikes at the first lags implying an ARMA(1,1) model or due to the (insignificant) decrease of correlations in PACF, we would specify ARMA(0,1) for the residuals.
m4.monthlyMinTempTS = arima(monthlyMinTempTS,order=c(0,1,1),seasonal=list(order=c(0,1,1), period=12))
res.m4 = residuals(m4.monthlyMinTempTS);
plot(res.m4,xlab='Time',ylab='Residuals',main="m4-Time series plot of the residuals")
###ACF and PACF of residuals-m4
par(mfrow=c(1,2))
acf(res.m4, lag.max = 36, main = "m4-ACF of residuals")
pacf(res.m4, lag.max = 36, main = "m4-PACF of residuals")
m5.monthlyMinTempTS = arima(monthlyMinTempTS,order=c(1,1,1),seasonal=list(order=c(0,1,1), period=12))
res.m5 = residuals(m5.monthlyMinTempTS);
plot(res.m5,xlab='Time',ylab='Residuals',main="m5-Time series plot of the residuals")
###ACF and PACF of residuals-m5
par(mfrow=c(1,2))
acf(res.m5, lag.max = 36, main = "m5-ACF of residuals")
pacf(res.m5, lag.max = 36, main = "m5-PACF of residuals")
We got nearly white noise residual series for both of the SARIMA(0,1,1)x(0,1,1)12 and SARIMA(1,1,1)x(0,1,1)12 models. The residuals of SARIMA(0,1,1)x(0,1,1)12 model are closer to the white noise. So, we can conclude with the orders p=0, d=1, q=1, P=0, D=1, Q=1, and s=12 of SARIMA(p,d,q)x(P,D,Q)s model
we use EACF on the residuals of the non seasonary differencing model (i.e. res.m3), to see information about AR and MA parts lefts in residuals. The EACF table also clearly suggests a (0,1,1) model
eacf(res.m3)
## AR/MA
## 0 1 2 3 4 5 6 7 8 9 10 11 12 13
## 0 x o o o o o o x x x o o o o
## 1 x o o o o o o o o o o o o o
## 2 x o x o o o o o o o o o o o
## 3 x x o o o o o o o o o o o o
## 4 x x o o o o o o o o o o o o
## 5 x x o x o o o o o o o o o o
## 6 o x x x o o o o o o o o o o
## 7 o x x o x o o o o o o o o o
So, we can conclude from residual approach and EACF that the suitable models for this series are SARIMA(0,1,1)*(0,1,1)s=12 of SARIMA(p,d,q)x(P,D,Q)s model
Along with this, other candidate models are SARIMA(0,1,0) * (0,1,1)s=12 and (1,1,1)*(0,1,1)s=12
###**Fitting the SARIMA(0,1,0)*(0,1,1)S=12 model using ML method**
mf_010_ml = arima(monthlyMinTempTS,order=c(0,1,1),seasonal=list(order=c(0,1,1),
period=12),method = "ML")
coeftest(mf_010_ml)
##
## z test of coefficients:
##
## Estimate Std. Error z value Pr(>|z|)
## ma1 -0.785576 0.088072 -8.9197 < 2.2e-16 ***
## sma1 -0.801445 0.137944 -5.8099 6.25e-09 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
**Fitting the same model above with lambda parameter to find AICc,BIC and AIC value
mf_010_lambda <- Arima(monthlyMinTempTS, order=c(0,1,0), seasonal=c(0,1,1),
lambda=0)
mf_010_lambda
## Series: monthlyMinTempTS
## ARIMA(0,1,0)(0,1,1)[12]
## Box Cox transformation: lambda= 0
##
## Coefficients:
## sma1
## -0.9998
## s.e. 0.2219
##
## sigma^2 estimated as 0.01344: log likelihood=65.5
## AIC=-127 AICc=-126.88 BIC=-121.65
**Fitting the same SARIMA(0,1,0)*(0,1,1)S=12 model using CSS method**
mf_010_css = arima(monthlyMinTempTS,order=c(0,1,1),seasonal=list(order=c(0,1,1),
period=12),method = "CSS")
coeftest(mf_010_css)
##
## z test of coefficients:
##
## Estimate Std. Error z value Pr(>|z|)
## ma1 -0.787922 0.065622 -12.0070 < 2.2e-16 ***
## sma1 -0.586463 0.081213 -7.2213 5.151e-13 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
###**Fitting the SARIMA(1,1,1)*(0,1,1)S=12 model**
mf_111_ml = arima(monthlyMinTempTS,order=c(1,1,1),seasonal=list(order=c(0,1,1),
period=12),method = "ML")
coeftest(mf_111_ml)
##
## z test of coefficients:
##
## Estimate Std. Error z value Pr(>|z|)
## ar1 0.079905 0.158437 0.5043 0.614
## ma1 -0.836734 0.122602 -6.8248 8.804e-12 ***
## sma1 -0.824361 0.154570 -5.3333 9.646e-08 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
**Fitting the same model above with lambda parameter to find AICc,BIC and AIC value
mf_111_lambda <- Arima(monthlyMinTempTS, order=c(1,1,1), seasonal=c(0,1,1),
lambda=0)
mf_111_lambda
## Series: monthlyMinTempTS
## ARIMA(1,1,1)(0,1,1)[12]
## Box Cox transformation: lambda= 0
##
## Coefficients:
## ar1 ma1 sma1
## -0.0083 -0.7410 -0.8670
## s.e. 0.2168 0.1982 0.1664
##
## sigma^2 estimated as 0.009828: log likelihood=88.59
## AIC=-169.17 AICc=-168.78 BIC=-158.48
**Fitting the same SARIMA(1,1,1)*(0,1,1)S=12 model using CSS method**
mf_111_css = arima(monthlyMinTempTS,order=c(1,1,1),seasonal=list(order=c(0,1,1),
period=12),method = "CSS")
coeftest(mf_111_css)
##
## z test of coefficients:
##
## Estimate Std. Error z value Pr(>|z|)
## ar1 -0.135634 0.140075 -0.9683 0.3329
## ma1 -0.675582 0.117202 -5.7643 8.202e-09 ***
## sma1 -0.551512 0.084746 -6.5078 7.626e-11 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
###**Fitting the SARIMA(0,1,1)*(0,1,1)S=12 model**
mf_011_ml = arima(monthlyMinTempTS,order=c(0,1,1),seasonal=list(order=c(0,1,1),
period=12),method = "ML")
coeftest(mf_011_ml)
##
## z test of coefficients:
##
## Estimate Std. Error z value Pr(>|z|)
## ma1 -0.785576 0.088072 -8.9197 < 2.2e-16 ***
## sma1 -0.801445 0.137944 -5.8099 6.25e-09 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
**Fitting the same model above with lambda parameter to find AICc,BIC and AIC value
mf_011_lambda <- Arima(monthlyMinTempTS, order=c(0,1,1), seasonal=c(0,1,1),
lambda=0)
mf_011_lambda
## Series: monthlyMinTempTS
## ARIMA(0,1,1)(0,1,1)[12]
## Box Cox transformation: lambda= 0
##
## Coefficients:
## ma1 sma1
## -0.7477 -0.8687
## s.e. 0.0894 0.1613
##
## sigma^2 estimated as 0.009722: log likelihood=88.59
## AIC=-171.17 AICc=-170.94 BIC=-163.15
**Fitting the same SARIMA(0,1,1)*(0,1,1)S=12 model using CSS method**
mf_011_css = arima(monthlyMinTempTS,order=c(0,1,1),seasonal=list(order=c(0,1,1),
period=12),method = "CSS")
coeftest(mf_011_css)
##
## z test of coefficients:
##
## Estimate Std. Error z value Pr(>|z|)
## ma1 -0.787922 0.065622 -12.0070 < 2.2e-16 ***
## sma1 -0.586463 0.081213 -7.2213 5.151e-13 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
###AIC values comparison The SARIMA model (0,1,1)*(0,1,1) has the lease AIC value and hence is considered to be the best fit
AIC(mf_010_lambda,mf_111_lambda,mf_011_lambda)
## df AIC
## mf_010_lambda 2 -126.9971
## mf_111_lambda 4 -169.1723
## mf_011_lambda 3 -171.1708
###BIC values comparison The SARIMA model (0,1,1)*(0,1,1) has the lease BIC value and hence is considered to be the best fit
BIC(mf_010_lambda,mf_111_lambda,mf_011_lambda)
## df BIC
## mf_010_lambda 2 -121.6515
## mf_111_lambda 4 -158.4809
## mf_011_lambda 3 -163.1523
plot(window(rstandard(mf_011_ml),start=c(1981,1)), ylab='Standardized Residuals',type='o', main="Residuals from the ARIMA(0,1,1)x(0,1,1)_12 model.")
abline(h=0)
Since we have some strange behaviour near 1983 , we will have to investigate this best model further for outliers
**plot the ACF of standardised residuals of our best model(0,1,1)*(0,1,1)s=12**
acf(as.vector(window(rstandard(mf_011_ml),start=c(1981,1))),lag.max=36,main="ACF of residuals from the ARIMA(0,1,1)x(0,1,1)_12 model.")
Except for the slightly significant autocorrelation at lag 28, there is not any sign of violation of the independence of residuals.
Function for residual analysis
residual.analysis <- function(model, std = TRUE){
library(TSA)
library(FitAR)
if (std == TRUE){
res.model = rstandard(model)
}else{
res.model = residuals(model)
}
par(mfrow=c(3,2))
plot(res.model,type='o',ylab='Standardized residuals', main="Time series plot of standardized residuals")
abline(h=0)
hist(res.model,main="Histogram of standardized residuals")
qqnorm(res.model,main="QQ plot of standardized residuals")
qqline(res.model, col = 2)
acf(res.model,main="ACF of standardized residuals")
print(shapiro.test(res.model))
k=0
LBQPlot(res.model, lag.max = length(model$residuals)-1 , StartLag = k + 1, k = 0, SquaredQ = FALSE)
}
Please perform Box test,hist,qqnorm,qqline,shapiro-wilk test for all 3 models given below
residual.analysis(model=mf_010_ml)
##
## Shapiro-Wilk normality test
##
## data: res.model
## W = 0.9922, p-value = 0.7394
## Warning in (ra^2)/(n - (1:lag.max)): longer object length is not a multiple of
## shorter object length
SARIMA(0,1,0)x(0,1,1)_12 1. Time Series plots does not have any trend except for some intervention. 2. Histogram shows residuals normally distributed. 3. QQplot is normally distributed with 1 outlier. 4. ACF plot highlights the white noise presence. 5. Ljung Box test shows the presence of residuals.
residual.analysis(model=mf_111_ml)
##
## Shapiro-Wilk normality test
##
## data: res.model
## W = 0.99279, p-value = 0.7935
## Warning in (ra^2)/(n - (1:lag.max)): longer object length is not a multiple of
## shorter object length
SARIMA(1,1,1)x(0,1,1)_12 1. Time Series plots does not have any trend except for some intervention. 2. Histogram is slightly skewed to the right. 3. QQplot is normally distributed except for some points not lying on the line. 4. ACF plot highlights the white noise presence. 5. Ljung Box test shows the presence of residuals.
residual.analysis(model=mf_011_ml)
##
## Shapiro-Wilk normality test
##
## data: res.model
## W = 0.9922, p-value = 0.7394
## Warning in (ra^2)/(n - (1:lag.max)): longer object length is not a multiple of
## shorter object length
SARIMA(0,1,1)x(0,1,1)_12 1. Time Series plots does not have any trend except for some intervention. 2. Histogram is slightly skewed to the right. 3. QQplot is normally distributed except for one point in outlier. 4. ACF plot highlights the white noise presence. 5. Ljung Box test shows the presence of residuals.
With SARIMA(0,1,1) * (0,1,1) being the best model with the S is equal to 12, below is the forcast for next 10 years.
sarima.for(monthlyMinTempTS,120,0,1,1,0,1,1,12)
## $pred
## Jan Feb Mar Apr May Jun Jul
## 1991 15.447837 15.650637 15.063298 12.787054 10.442440 7.810201 7.342003
## 1992 15.487655 15.690455 15.103116 12.826872 10.482258 7.850019 7.381821
## 1993 15.527473 15.730272 15.142934 12.866690 10.522075 7.889837 7.421638
## 1994 15.567290 15.770090 15.182752 12.906507 10.561893 7.929655 7.461456
## 1995 15.607108 15.809908 15.222570 12.946325 10.601711 7.969473 7.501274
## 1996 15.646926 15.849726 15.262388 12.986143 10.641529 8.009291 7.541092
## 1997 15.686744 15.889544 15.302206 13.025961 10.681347 8.049108 7.580910
## 1998 15.726562 15.929362 15.342023 13.065779 10.721165 8.088926 7.620728
## 1999 15.766380 15.969179 15.381841 13.105597 10.760982 8.128744 7.660545
## 2000 15.806198 16.008997 15.421659 13.145414 10.800800 8.168562 7.700363
## Aug Sep Oct Nov Dec
## 1991 8.212052 9.443779 10.836433 12.950881 14.387385
## 1992 8.251870 9.483597 10.876251 12.990699 14.427203
## 1993 8.291688 9.523415 10.916069 13.030517 14.467020
## 1994 8.331506 9.563233 10.955887 13.070335 14.506838
## 1995 8.371324 9.603051 10.995705 13.110152 14.546656
## 1996 8.411141 9.642869 11.035523 13.149970 14.586474
## 1997 8.450959 9.682686 11.075341 13.189788 14.626292
## 1998 8.490777 9.722504 11.115158 13.229606 14.666110
## 1999 8.530595 9.762322 11.154976 13.269424 14.705927
## 2000 8.570413 9.802140 11.194794 13.309242 14.745745
##
## $se
## Jan Feb Mar Apr May Jun Jul Aug
## 1991 1.024924 1.048196 1.070962 1.093255 1.115102 1.136529 1.157559 1.178215
## 1992 1.328409 1.354364 1.379831 1.404836 1.429405 1.453557 1.477315 1.500697
## 1993 1.659877 1.688194 1.716043 1.743447 1.770428 1.797003 1.823191 1.849008
## 1994 2.016801 2.047255 2.077263 2.106843 2.136014 2.164791 2.193191 2.221228
## 1995 2.397292 2.429717 2.461715 2.493302 2.524494 2.555306 2.585750 2.615840
## 1996 2.799858 2.834124 2.867980 2.901442 2.934522 2.967233 2.999587 3.031596
## 1997 3.223280 3.259281 3.294888 3.330115 3.364973 3.399474 3.433628 3.467445
## 1998 3.666531 3.704178 3.741447 3.778348 3.814893 3.851090 3.886950 3.922483
## 1999 4.128728 4.167947 4.206801 4.245299 4.283451 4.321266 4.358753 4.395921
## 2000 4.609103 4.649829 4.690201 4.730228 4.769920 4.809284 4.848329 4.887061
## Sep Oct Nov Dec
## 1991 1.198514 1.218475 1.238114 1.257447
## 1992 1.523721 1.546401 1.568754 1.590792
## 1993 1.874470 1.899590 1.924382 1.948859
## 1994 2.248916 2.276266 2.303292 2.330005
## 1995 2.645588 2.675005 2.704102 2.732889
## 1996 3.063271 3.094621 3.125657 3.156388
## 1997 3.500936 3.534110 3.566975 3.599540
## 1998 3.957697 3.992600 4.027200 4.061506
## 1999 4.432777 4.469329 4.505584 4.541550
## 2000 4.925489 4.963620 5.001460 5.039015
###Using auto.arima function To automatically fit the data we have and check the best model that could be fitted for our data using auto.arima function This result also comes as SARIMA(0,1,1)*(0,1,1)S=12
autoArimaModel = auto.arima(monthlyMinTempTS, d = 1)
autoArimaModel
## Series: monthlyMinTempTS
## ARIMA(0,1,1)(0,1,1)[12]
##
## Coefficients:
## ma1 sma1
## -0.7856 -0.8014
## s.e. 0.0881 0.1379
##
## sigma^2 estimated as 1.065: log likelihood=-160.79
## AIC=327.58 AICc=327.81 BIC=335.6