Exercise 1

  1. Use the help function to explore what the series gold, woolyrnq and gas represent.
library(fpp2)
## Loading required package: ggplot2
## Loading required package: forecast
## Loading required package: fma
## Loading required package: expsmooth
help(gold)
help(woolyrnq)
help(gas)

Gold - Daily morning gold prices in US dollars for the period from 1 January 1985 to 31 March 1989.

Woolyrnq - Quarterly production of woollen yarn in Australia (tonnes) for the period from Mar 1965 to Sep 1994.

Gas - Australian monthly gas production for the period from 1956 to 1995.

  1. Use autoplot() to plot each of these in separate plots.
autoplot(gold) + ggtitle("Daily Morning Gold Prices In US Dollars (1 January 1985 – 31 March 1989)")

autoplot(woolyrnq) + ggtitle("Quarterly Production Of Woolen Yarn In Australia")

autoplot(gas) + ggtitle("Australian Monthly Gas Production: 1956 - 1995")

  1. What is the frequency of each series? Hint: apply the frequency() function.
frequency(gold)
## [1] 1
frequency(woolyrnq)
## [1] 4
frequency(gas)
## [1] 12

The “frequency” is the number of observations before the seasonal pattern repeats.

The frequency of gold series is 1 (annual)

The frequency of woolyrnq is 4 (quaterly)

The frequency of gas is 12 (monthly)

  1. Use which.max() to spot the outlier in the gold series. Which observation was it?
which.max(gold)
## [1] 770

Observation number 770 has an outlier in Gold series.

Exercise 2

  1. Download some monthly Australian retail data from the book website. These represent retail sales in various categories for different Australian states, and are stored in a MS-Excel file.
  1. You can read the data into R with the following script:
retaildata <- readxl::read_excel("retail.xlsx", skip=1)

The second argument (skip=1) is required because the Excel sheet has two header rows.

  1. Select one of the time series as follows (but replace the column name with your own chosen column):
#  Turnover ;  New South Wales ;  Supermarket and grocery stores
myts <- ts(retaildata[,"A3349335T"],
frequency=12, start=c(1982,4))

Turnover of supermarket and grocery stores in New South Wales (column “A3349335T”“) was selected for further analysis.

  1. Explore your chosen retail time series using the following functions:

autoplot(), ggseasonplot(), ggsubseriesplot(), gglagplot(), ggAcf()

Can you spot any seasonality, cyclicity and trend? What do you learn about the series?

autoplot(myts) + ggtitle("Turnover Of Supermarket And Grocery Stores In New South Wales")

ggseasonplot(myts) + ggtitle("Turnover Of Supermarket And Grocery Stores In New South Wales")

ggsubseriesplot(myts) + ggtitle("Turnover Of Supermarket And Grocery Stores In New South Wales")

gglagplot(myts) + ggtitle("Turnover Of Supermarket And Grocery Stores In New South Wales")

ggAcf(myts, lag = 48) + ggtitle("Turnover Of Supermarket And Grocery Stores In New South Wales")

Turnover of supermarket and grocery stores shows a strong increasing trend. There is no evidence of any cyclic behaviour here, though perhaps the data only demonstrates a portion of the cycling.

It is clear that there is a large jump in sales in December each year which is possibly due to Christmas and New Year holidays. February and June shows the lowest turnover during the year.

The data have a trend, so the autocorrelations for small lags tend to be large and positive because observations nearby in time are also nearby in size. So the ACF of trended time series has positive values that slowly decrease as the lags increase. There is no seasonality in the data.

Overall turnover increasing over the years.