CH.2 Homework

Author

Griffin Lessinger

6. Compare quarterly international arrivals to Australia

library(fpp3)
autoplot(aus_arrivals) + theme_bw()

gg_season(aus_arrivals) + theme_bw()

gg_subseries(aus_arrivals) + theme_bw()

We can see a few things from these plots. First of all, arrivals from the US, UK, and NZ all seem to be (mostly) increasing from year to year, while Japan has a clear decline in arrivals from ~1997 onward. Arrivals from the UK also seem to be somewhat decreasing, but this is more recent (and more gradual than Japan), from ~2005 onward.

Also, the quarter to quarter arrivals from NZ and UK are MUCH more variable than arrivals from Japan and the US.

You can get some neat info about the arrival patterns by quarter as well. From 3/4 countries, it seems that there are fewest arrivals to Australia during Q2 and Q3. This is (by far) most pronounced by arrival patterns from the UK, seeing about 70k arrivals fewer (on average) during these quarters, which is about 1/2 the Q1 and Q4 averages. The only country for which this does not hold is NZ, where the trend is actually opposite! We almost see the most arrivals during Q2 and Q3. Maybe this is due to different seasonality, as New Zealand is in the Southern hemisphere, while the other 3 countries are in the North?

7. Analyze retail time series

set.seed(2468)
myseries <- aus_retail |>
  filter(`Series ID` == sample(aus_retail$`Series ID`,1))

autoplot(myseries) + theme_bw()

gg_season(myseries) + theme_bw()

gg_subseries(myseries) + theme_bw()

gg_lag(myseries) + theme_bw()

myseries |> ACF(Turnover) |> autoplot() + theme_bw()

Wow! Strong autocorrelation. This suggests very strong seasonality in the data, especially from month-to-month (but also from year-to-year). We can clearly see monthly seasonality in the lag plot especially, and the subseries plot shows relatively stable turnover for 11/12 months. But the 12th month, December, sees very high (average) turnover.

This is probably a general box store/retailer, where we would expect this trend. Stable monthly turnover from groceries, household goods, and the like, and then high turnover in December (from Christmas shopping).

From the initial autoplot() and gg_season() calls, we also see an overall trend of increasing turnover. Good for the store, I suppose.

Google stock prices

dgoog <- gafa_stock |>
  filter(Symbol == "GOOG", year(Date) >= 2018) |>
  mutate(trading_day = row_number()) |>
  update_tsibble(index = trading_day, regular = TRUE) |>
  mutate(diff = difference(Close))

Note, we need to re-index the tsibble in order to use difference() and other functions that may rely on a regular index, as the original data did not have a regular index.

autoplot(dgoog[, 9:10]) + theme_bw()

dgoog |> ACF(diff) |> autoplot() + theme_bw()

Looking at the ACF plot, we see low autocorrelation. Nearly all points within the 95% confidence interval for no autocorrelation, and we even see relatively even distribution around 0! Also, the plot of diff over time seems chaotic and random, from a glance.