In: Statistics and Probability
You are applying for a data job, and your assignment is to analyze the following data set for monthly average temperatures at St Catherines in the programming language R.
(a) Prepare some plots that visualize the data.
(b) Find the appropriate time series model and fit the data. Explain your choice of parameters.
(c) Make predictions for the next 3 years, plot these predictions.
(d) Summarize your findings.
The Data is provided below. Please show the R codes as well. Thank you!
"Month","Average monthly temperatures St Cathrines"
“1980-01", 3.3
“1980-02", 5.5
“1980-03", 0.5
“1980-04", 7.4
“1980-05", 14.4
“1980-06", 16.6
“1980-07", 21.8
“1980-08", 22.8
“1980-09", 16.9
“1980-10", 8.4
“1980-11", 3.4
“1980-12", 4.3
“1981-01", 7.6
“1981-02", 0.6
“1981-03”, 1.6
“1981-04", 8.5
“1981-05", 12.4
“1981-06", 19.2
“1981-07", 22.1
“1981-08", 20.7
“1981-09", 16.0
“1981-10", 7.7
“1981-11", 4.5
“1981-12", 1.3
“1982-01", 7.7
“1982-02", 5.3
“1982-03", 0.3
“1982-04", 5.7
“1982-05", 14.0
“1982-06", 15.9
“1982-07", 21.9
“1982-08", 18.4
“1982-09", 15.9
“1982-10", 11.2
“1982-11", 5.8
“1982-12", 3.0
“1983-01", 2.3
“1983-02", 1.6
“1983-03", 1.9
“1983-04", 6.5
“1983-05", 11.6
“1983-06", 19.6
“1983-07", 23.3
“1983-08”, 21.5
“1983-09", 17.5
“1983-10", 10.8
“1983-11", 4.9
“1983-12", 4.2
“1984-01", 6.1
“1984-02", 0.4
“1984-03", 3.0
“1984-04", 7.5
“1984-05", 11.0
“1984-06", 19.6
“1984-07", 21.0
“1984-08", 22.0
“1984-09", 15.4
“1984-10", 11.3
“1984-11", 4.6
“1984-12", 0.9
“1985-01", 6.0
“1985-02", 4.0
“1985-03", 2.3
“1985-04", 8.7
“1985-05", 14.3
“1985-06", 17.0
“1985-07", 21.1
“1985-08", 20.7
“1985-09", 18.3
“1985-10”, 10.9
“1985-11", 4.9
“1985-12", 3.2
“1986-01", 3.6
“1986-02", 4.8
“1986-03", 1.9
“1986-04", 8.1
“1986-05", 15.0
“1986-06", 17.7
“1986-07", 21.9
“1986-08", 19.7
“1986-09", 16.1
“1986-10", 10.4
“1986-11", 2.9
“1986-12", 0.4
“1987-01”, 3.1
“1987-02", 3.7
“1987-03", 2.7
“1987-04", 9.0
“1987-05", 15.0
“1987-06", 20.2
“1987-07", 23.5
“1987-08", 20.3
“1987-09", 16.8
“1987-10", 8.3
“1987-11", 5.3
“1987-12", 1.1
“1988-01", 3.3
“1988-02", 4.5
“1988-03”, 1.1
“1988-04", 6.7
“1988-05", 14.6
“1988-06", 18.4
“1988-07", 23.7
“1988-08", 22.2
“1988-09", 16.4
“1988-10", 8.4
“1988-11", 6.0
“1988-12", 1.1
“1989-01", 0.7
“1989-02", 4.7
“1989-03", 0.3
“1989-04", 5.6
“1989-05", 13.2
“1989-06", 19.2
“1989-07", 22.2
“1989-08", 20.7
“1989-09", 16.8
“1989-10", 11.1
“1989-11", 3.7
“1989-12", 7.5
“1990-01", 0.7
“1990-02", 1.8
“1990-03", 2.1
“1990-04”, 8.9
“1990-05", 12.1
“1990-06", 19.4
“1990-07", 21.5
“1990-08", 21.0
“1990-09", 16.2
“1990-10", 10.7
“1990-11", 5.8
“1990-12", 0.6
“1991-01", 3.9
“1991-02", 0.6
“1991-03", 2.9
“1991-04", 9.1
“1991-05", 16.8
“1991-06", 20.6
“1991-07", 22.1
“1991-08", 21.8
“1991-09", 16.4
“1991-10", 11.4
“1991-11", 4.2
“1991-12”, 0.1
“1992-01", 2.5
“1992-02", 2.1
“1992-03", 0.1
“1992-04", 6.1
“1992-05", 12.8
“1992-06", 16.9
“1992-07", 18.8
“1992-08", 18.9
“1992-09", 15.9
“1992-10", 8.5
“1992-11", 4.2
“1992-12", 0.3
“1993-01", 1.8
“1993-02", 6.8
“1993-03”, 1.7
“1993-04", 7.4
“1993-05", 12.7
“1993-06", 17.8
“1993-07", 22.4
“1993-08", 21.7
“1993-09", 15.1
“1993-10", 9.0
“1993-11", 3.9
“1993-12", 1.7
“1994-01”, 9.1
“1994-02", 6.2
“1994-03", 0.2
“1994-04", 8.2
“1994-05", 11.6
“1994-06", 19.3
“1994-07", 22.2
“1994-08", 19.6
“1994-09", 16.4
“1994-10", 10.6
“1994-11", 6.8
“1994-12", 1.0
“1995-01", 1.2
“1995-02", 5.7
“1995-03", 3.0
“1995-04", 5.2
“1995-05", 13.6
“1995-06", 20.0
“1995-07", 22.1
“1995-08", 21.9
“1995-09", 15.4
“1995-10”, 12.0
“1995-11", 2.4
“1995-12", 3.4
“1996-01", 5.2
“1996-02", 4.4
“1996-03", 2.0
“1996-04", 6.0
“1996-05", 12.2
“1996-06", 19.4
“1996-07", 20.5
“1996-08”, 21.7
“1996-09", 17.3
“1996-10", 10.7
“1996-11", 2.4
“1996-12", 0.8
“1997-01", 4.1
“1997-02", 0.9
“1997-03", 0.4
“1997-04", 6.2
“1997-06", 20.0
“1997-07", 20.7
“1997-08", 19.6
“1997-09", 16.3
“1997-10", 10.1
“1997-11", 3.3
“1997-12", 0.5
“1998-01", 0.6
“1998-02", 0.7
“1998-03", 3.3
“1998-04", 9.0
“1998-05", 16.9
“1998-06", 19.5
“1998-07", 21.8
“1998-08”, 22.1
“1998-09", 19.0
“1998-10", 11.6
“1998-11", 6.1
“1998-12", 2.5
“1999-01", 4.7
“1999-02", 0.5
“1999-03", 0.7
“1999-04", 8.1
“1999-05”, 15.4
“1999-06", 21.2
“1999-07", 24.6
“1999-08", 20.3
“1999-09", 18.5
“1999-10”, 10.6
“1999-11", 6.8
“1999-12", 0.5
rm(list=ls())
## Import Data as data set named rdata
temp<-c(3.3, 5.5, 0.5, 7.4, 14.4, 16.6, 21.8, 22.8, 16.9, 8.4, 3.4, 4.3, 7.6, 0.6, 1.6, 8.5, 12.4, 19.2,
22.1, 20.7, 16, 7.7, 4.5, 1.3, 7.7, 5.3, 0.3, 5.7, 14, 15.9, 21.9, 18.4, 15.9, 11.2, 5.8, 3, 2.3,
1.6, 1.9, 6.5, 11.6, 19.6, 23.3, 21.5, 17.5, 10.8, 4.9, 4.2, 6.1, 0.4, 3, 7.5, 11, 19.6, 21, 22,
15.4, 11.3, 4.6, 0.9, 6, 4, 2.3, 8.7, 14.3, 17, 21.1, 20.7, 18.3, 10.9, 4.9, 3.2, 3.6, 4.8, 1.9,
8.1, 15, 17.7, 21.9, 19.7, 16.1, 10.4, 2.9, 0.4, 3.1, 3.7, 2.7, 9, 15, 20.2, 23.5, 20.3, 16.8, 8.3,
5.3, 1.1, 3.3, 4.5, 1.1, 6.7, 14.6, 18.4, 23.7, 22.2, 16.4, 8.4, 6, 1.1, 0.7, 4.7, 0.3, 5.6,
13.2, 19.2, 22.2, 20.7, 16.8, 11.1, 3.7, 7.5, 0.7, 1.8, 2.1, 8.9, 12.1, 19.4, 21.5, 21, 16.2, 10.7,
5.8, 0.6, 3.9, 0.6, 2.9, 9.1, 16.8, 20.6, 22.1, 21.8, 16.4, 11.4, 4.2, 0.1, 2.5, 2.1, 0.1, 6.1,
12.8, 16.9, 18.8, 18.9, 15.9, 8.5, 4.2, 0.3, 1.8, 6.8, 1.7, 7.4, 12.7, 17.8, 22.4, 21.7, 15.1, 9,
3.9, 1.7, 9.1, 6.2, 0.2, 8.2, 11.6, 19.3, 22.2, 19.6, 16.4, 10.6, 6.8, 1, 1.2, 5.7, 3, 5.2, 13.6,
20, 22.1, 21.9, 15.4, 12, 2.4, 3.4, 5.2, 4.4, 2, 6, 12.2, 19.4, 20.5, 21.7, 17.3, 10.7, 2.4, 0.8, 4.1,
0.9, 0.4, 6.2, 0, 20, 20.7, 19.6, 16.3, 10.1, 3.3, 0.5, 0.6, 0.7, 3.3, 9, 16.9, 19.5, 21.8, 22.1, 19,
11.6, 6.1, 2.5, 4.7, 0.5, 0.7, 8.1, 15.4, 21.2, 24.6, 20.3, 18.5, 10.6, 6.8, 0.5)
# conevert data into time series data
ts_data<-ts(data = temp, start = c(1980,1),end = c(1999,12),frequency = 12)
#### (a) Time series plot
plot(ts_data,xlab="Year",ylab="Temperature",main="Time Series")
#### (b) Appropriate model fitting
fit<-forecast::auto.arima(ts_data)
# Series: ts_data
# ARIMA(1,0,0)(1,1,0)[12] with drift
# Coefficients:
# ar1 sar1 drift
# 0.0466 -0.4651 0.0031
# s.e. 0.0666 0.0586 0.0090
#
# sigma^2 estimated as 5.134: log likelihood=-509.97
# AIC=1027.94 AICc=1028.12 BIC=1041.66
#### (c) prediction for next 3 year
pred<-forecast::forecast(fit,h=36)
Month | Forecast |
Jan-00 | 2.79 |
Feb-00 | 0.64 |
Mar-00 | 1.96 |
Apr-00 | 8.57 |
May-00 | 16.15 |
Jun-00 | 20.46 |
Jul-00 | 23.35 |
Aug-00 | 21.19 |
Sep-00 | 18.79 |
Oct-00 | 11.12 |
Nov-00 | 6.53 |
Dec-00 | 1.48 |
Jan-01 | 3.73 |
Feb-01 | 0.63 |
Mar-01 | 1.43 |
Apr-01 | 8.41 |
May-01 | 15.86 |
Jun-01 | 20.86 |
Jul-01 | 23.99 |
Aug-01 | 20.83 |
Sep-01 | 18.71 |
Oct-01 | 10.93 |
Nov-01 | 6.71 |
Dec-01 | 1.08 |
Jan-02 | 3.35 |
Feb-02 | 0.69 |
Mar-02 | 1.73 |
Apr-02 | 8.54 |
May-02 | 16.05 |
Jun-02 | 20.73 |
Jul-02 | 23.74 |
Aug-02 | 21.05 |
Sep-02 | 18.80 |
Oct-02 | 11.07 |
Nov-02 | 6.68 |
Dec-02 | 1.32 |