2.1

library(fpp2)
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo
## ── Attaching packages ──────────────────────────────────────────── fpp2 2.5.1 ──
## ✔ ggplot2   4.0.1      ✔ fma       2.5   
## ✔ forecast  8.24.0     ✔ expsmooth 2.3
## 
#help('gold')
#help('woolyrnq')
#help('gas')

#a
autoplot(gold)

autoplot(woolyrnq)

autoplot(gas)

#b
frequency(gold) #1
## [1] 1
frequency(woolyrnq) #4
## [1] 4
frequency(gas) #12
## [1] 12
#c
which.max(gold) #770 
## [1] 770

2.2

#a
tute1 <- read.csv("tute1.csv", header=TRUE)
View(tute1)

#b
mytimeseries <- ts(tute1[,-1], start=1981, frequency=4)

#c
autoplot(mytimeseries, facets=TRUE)

2.3

#a
retaildata <- readxl::read_excel("retail.xlsx", skip=1)

#b
myts <- ts(retaildata[,"A3349338X"], frequency=12, start=c(1982,4))

#c
autoplot(myts)

ggseasonplot(myts, year.labels=TRUE, year.labels.left=TRUE)
## Warning in fortify(data, ...): Arguments in `...` must be used.
## ✖ Problematic argument:
## • na.rm = TRUE
## ℹ Did you misspell an argument name?

ggsubseriesplot(myts)
## Warning in fortify(data, ...): Arguments in `...` must be used.
## ✖ Problematic argument:
## • na.rm = TRUE
## ℹ Did you misspell an argument name?

gglagplot(myts)

ggAcf(myts)

There is an upwards trend in sales with a very big growth overall. There is a large spike of sales occurring during December, while June has the worst sales for pretty much every season. # 2.4

autoplot(bicoal)

autoplot(chicken)

autoplot(dole)

autoplot(usdeaths)

autoplot(lynx)

autoplot(goog) +
  ggtitle("Google Stock Price") +
  xlab("Day") +
  ylab("Closing Price (USD)")

autoplot(writing)

autoplot(fancy)

autoplot(a10)

autoplot(h02)

# 2.5

ggseasonplot(writing)
## Warning in fortify(data, ...): Arguments in `...` must be used.
## ✖ Problematic argument:
## • na.rm = TRUE
## ℹ Did you misspell an argument name?

ggsubseriesplot(writing)
## Warning in fortify(data, ...): Arguments in `...` must be used.
## ✖ Problematic argument:
## • na.rm = TRUE
## ℹ Did you misspell an argument name?

ggseasonplot(fancy)
## Warning in fortify(data, ...): Arguments in `...` must be used.
## ✖ Problematic argument:
## • na.rm = TRUE
## ℹ Did you misspell an argument name?

ggsubseriesplot(fancy)
## Warning in fortify(data, ...): Arguments in `...` must be used.
## ✖ Problematic argument:
## • na.rm = TRUE
## ℹ Did you misspell an argument name?

ggseasonplot(a10)
## Warning in fortify(data, ...): Arguments in `...` must be used.
## ✖ Problematic argument:
## • na.rm = TRUE
## ℹ Did you misspell an argument name?

ggsubseriesplot(a10)
## Warning in fortify(data, ...): Arguments in `...` must be used.
## ✖ Problematic argument:
## • na.rm = TRUE
## ℹ Did you misspell an argument name?

ggseasonplot(h02)
## Warning in fortify(data, ...): Arguments in `...` must be used.
## ✖ Problematic argument:
## • na.rm = TRUE
## ℹ Did you misspell an argument name?

ggsubseriesplot(h02)
## Warning in fortify(data, ...): Arguments in `...` must be used.
## ✖ Problematic argument:
## • na.rm = TRUE
## ℹ Did you misspell an argument name?

For writing: A massive dip in August, otherwise steady seasonally, but has increased throughout the years. For fancy: A massive increase in December, and a big drop immediately after that. Very seasonal pattern. For a10: An increase in January (likely affected by late December too), dip in February. Steady throughout the seasons, but has increased throughout the years. For h02: Jump in January and then a massive dip in February. An upwards trend can be seen, but varies more year-to-year.

2.8

1 - B 2 - A 3 - D 4 - C