Problem 2.1

Explore the following four time series: Bricks from aus_production, Lynx from pelt, Close from gafa_stock, Demand from vic_elec.

library(fpp3)
## Warning: package 'fpp3' was built under R version 4.3.3
## Registered S3 method overwritten by 'tsibble':
##   method               from 
##   as_tibble.grouped_df dplyr
## ── Attaching packages ──────────────────────────────────────────── fpp3 1.0.1 ──
## ✔ tibble      3.2.1     ✔ tsibble     1.1.5
## ✔ dplyr       1.1.4     ✔ tsibbledata 0.4.1
## ✔ tidyr       1.3.1     ✔ feasts      0.4.1
## ✔ lubridate   1.9.4     ✔ fable       0.4.1
## ✔ ggplot2     3.5.1
## Warning: package 'lubridate' was built under R version 4.3.3
## Warning: package 'tsibble' was built under R version 4.3.3
## Warning: package 'feasts' was built under R version 4.3.3
## Warning: package 'fabletools' was built under R version 4.3.3
## Warning: package 'fable' was built under R version 4.3.3
## ── Conflicts ───────────────────────────────────────────────── fpp3_conflicts ──
## ✖ lubridate::date()    masks base::date()
## ✖ dplyr::filter()      masks stats::filter()
## ✖ tsibble::intersect() masks base::intersect()
## ✖ tsibble::interval()  masks lubridate::interval()
## ✖ dplyr::lag()         masks stats::lag()
## ✖ tsibble::setdiff()   masks base::setdiff()
## ✖ tsibble::union()     masks base::union()

Bricks Data

Quarterly time interval

help(aus_production)
autoplot(aus_production, Bricks)
## Warning: Removed 20 rows containing missing values or values outside the scale range
## (`geom_line()`).

Lynx Data

Annual time interval

help(pelt)
autoplot(pelt, Lynx)

Close Data

Daily time interval (Stock market close)

help(gafa_stock)
autoplot(gafa_stock, Close)

Demand Data

30 minute time interval

help(vic_elec)
autoplot(vic_elec, Demand) + 
  labs(title="Half-hourly Electricity demand for Victoria, Australia",
        x = "Time (30 Minute intervals)", 
        y="Electricity Demand" 
       )

Problem 2.2

Use filter() to find what days corresponded to the peak closing price for each of the four stocks in gafa_stock.

peak_close <- gafa_stock %>%
  group_by(Symbol) %>%
  filter(Close == max(Close)) %>%
  select(Symbol, Close, Date)
peak_close
## # A tsibble: 4 x 3 [!]
## # Key:       Symbol [4]
## # Groups:    Symbol [4]
##   Symbol Close Date      
##   <chr>  <dbl> <date>    
## 1 AAPL    232. 2018-10-03
## 2 AMZN   2040. 2018-09-04
## 3 FB      218. 2018-07-25
## 4 GOOG   1268. 2018-07-26

Problem 2.3

Download the file tute1.csv from the book website, open it in Excel (or some other spreadsheet application), and review its contents. You should find four columns of information. Columns B through D each contain a quarterly series, labelled Sales, AdBudget and GDP. Sales contains the quarterly sales for a small company over the period 1981-2005. AdBudget is the advertising budget and GDP is the gross domestic product. All series have been adjusted for inflation.

tute1 <- readr::read_csv("tute1.csv")
## Rows: 100 Columns: 4
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## dbl  (3): Sales, AdBudget, GDP
## date (1): Quarter
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
tute1
## # A tibble: 100 × 4
##    Quarter    Sales AdBudget   GDP
##    <date>     <dbl>    <dbl> <dbl>
##  1 1981-03-01 1020.     659.  252.
##  2 1981-06-01  889.     589   291.
##  3 1981-09-01  795      512.  291.
##  4 1981-12-01 1004.     614.  292.
##  5 1982-03-01 1058.     647.  279.
##  6 1982-06-01  944.     602   254 
##  7 1982-09-01  778.     531.  296.
##  8 1982-12-01  932.     608.  272.
##  9 1983-03-01  996.     638.  260.
## 10 1983-06-01  908.     582.  280.
## # ℹ 90 more rows
mytimeseries <- tute1 |>
  mutate(Quarter = yearquarter(Quarter)) |>
  as_tsibble(index = Quarter)
print(mytimeseries)
## # A tsibble: 100 x 4 [1Q]
##    Quarter Sales AdBudget   GDP
##      <qtr> <dbl>    <dbl> <dbl>
##  1 1981 Q1 1020.     659.  252.
##  2 1981 Q2  889.     589   291.
##  3 1981 Q3  795      512.  291.
##  4 1981 Q4 1004.     614.  292.
##  5 1982 Q1 1058.     647.  279.
##  6 1982 Q2  944.     602   254 
##  7 1982 Q3  778.     531.  296.
##  8 1982 Q4  932.     608.  272.
##  9 1983 Q1  996.     638.  260.
## 10 1983 Q2  908.     582.  280.
## # ℹ 90 more rows
mytimeseries |>
  pivot_longer(-Quarter) |>
  ggplot(aes(x = Quarter, y = value, colour = name)) +
  geom_line() +
  facet_grid(name ~ ., scales = "free_y")

mytimeseries |>
  pivot_longer(-Quarter) |>
  ggplot(aes(x = Quarter, y = value, colour = name)) +
  geom_line() 

Problem 2.4

Create a tsibble from us_total with year as the index and state as the key.

us_total <- USgas::us_total %>%
  as_tibble(index= year, key = state)
us_total
## # A tibble: 1,266 × 3
##     year state        y
##    <int> <chr>    <int>
##  1  1997 Alabama 324158
##  2  1998 Alabama 329134
##  3  1999 Alabama 337270
##  4  2000 Alabama 353614
##  5  2001 Alabama 332693
##  6  2002 Alabama 379343
##  7  2003 Alabama 350345
##  8  2004 Alabama 382367
##  9  2005 Alabama 353156
## 10  2006 Alabama 391093
## # ℹ 1,256 more rows

Plot the annual natural gas consumption by state for the New England area (comprising the states of Maine, Vermont, New Hampshire, Massachusetts, Connecticut and Rhode Island).

ne_states <- c("Maine", "Vermont", "New Hampshire", "Massachusetts", "Connecticut", "Rhode Island")
ne_data<-us_total %>%
  mutate(nat_gas_in_thousands = y/1000) %>%
  filter(state %in% ne_states) %>%
  group_by(state)
ne_data
## # A tibble: 138 × 4
## # Groups:   state [6]
##     year state            y nat_gas_in_thousands
##    <int> <chr>        <int>                <dbl>
##  1  1997 Connecticut 144708                 145.
##  2  1998 Connecticut 131497                 131.
##  3  1999 Connecticut 152237                 152.
##  4  2000 Connecticut 159712                 160.
##  5  2001 Connecticut 146278                 146.
##  6  2002 Connecticut 177587                 178.
##  7  2003 Connecticut 154075                 154.
##  8  2004 Connecticut 162642                 163.
##  9  2005 Connecticut 168067                 168.
## 10  2006 Connecticut 172682                 173.
## # ℹ 128 more rows
ne_data |>
  ggplot(aes(x = year, y = nat_gas_in_thousands, colour = state)) +
  ggtitle("Annual Natural Gas Consumption by State for the New England Area") +
  xlab("Year") +
  ylab("Natural Gas Consumption in thousands") +
  geom_line() +
  geom_point() 

Problem 2.5

Create a tsibble which is identical to the tourism tsibble from the tsibble package.

toursim_ex <- readxl::read_excel("tourism.xlsx") %>%
  mutate(Quarter = yearquarter(Quarter)) %>%
  as_tibble(index=Quarter)
toursim_ex
## # A tibble: 24,320 × 5
##    Quarter Region   State           Purpose  Trips
##      <qtr> <chr>    <chr>           <chr>    <dbl>
##  1 1998 Q1 Adelaide South Australia Business  135.
##  2 1998 Q2 Adelaide South Australia Business  110.
##  3 1998 Q3 Adelaide South Australia Business  166.
##  4 1998 Q4 Adelaide South Australia Business  127.
##  5 1999 Q1 Adelaide South Australia Business  137.
##  6 1999 Q2 Adelaide South Australia Business  200.
##  7 1999 Q3 Adelaide South Australia Business  169.
##  8 1999 Q4 Adelaide South Australia Business  134.
##  9 2000 Q1 Adelaide South Australia Business  154.
## 10 2000 Q2 Adelaide South Australia Business  169.
## # ℹ 24,310 more rows

Find what combination of Region and Purpose had the maximum number of overnight trips on average.

toursim_ex %>%
  group_by(Region, Purpose) %>%
  summarise(avgTrips=mean(Trips)) %>%
  arrange(desc(avgTrips))
## `summarise()` has grouped output by 'Region'. You can override using the
## `.groups` argument.
## # A tibble: 304 × 3
## # Groups:   Region [76]
##    Region          Purpose  avgTrips
##    <chr>           <chr>       <dbl>
##  1 Sydney          Visiting     747.
##  2 Melbourne       Visiting     619.
##  3 Sydney          Business     602.
##  4 North Coast NSW Holiday      588.
##  5 Sydney          Holiday      550.
##  6 Gold Coast      Holiday      528.
##  7 Melbourne       Holiday      507.
##  8 South Coast     Holiday      495.
##  9 Brisbane        Visiting     493.
## 10 Melbourne       Business     478.
## # ℹ 294 more rows

Sydney for Visiting had the highest average amount of trips.

Create a new tsibble which combines the Purposes and Regions, and just has total trips by State.

tourism_combined <- toursim_ex %>%
  group_by(State) %>%
  select(-c("Region", "Purpose"))
tourism_combined
## # A tibble: 24,320 × 3
## # Groups:   State [8]
##    Quarter State           Trips
##      <qtr> <chr>           <dbl>
##  1 1998 Q1 South Australia  135.
##  2 1998 Q2 South Australia  110.
##  3 1998 Q3 South Australia  166.
##  4 1998 Q4 South Australia  127.
##  5 1999 Q1 South Australia  137.
##  6 1999 Q2 South Australia  200.
##  7 1999 Q3 South Australia  169.
##  8 1999 Q4 South Australia  134.
##  9 2000 Q1 South Australia  154.
## 10 2000 Q2 South Australia  169.
## # ℹ 24,310 more rows

Problem 2.8

Use the following graphics functions: autoplot(), gg_season(), gg_subseries(), gg_lag(), ACF() and explore features from the following time series: “Total Private” Employed from us_employment, Bricks from aus_production, Hare from pelt, “H02” Cost from PBS, and Barrels from us_gasoline

US Employment Data

us_employment
## # A tsibble: 143,412 x 4 [1M]
## # Key:       Series_ID [148]
##       Month Series_ID     Title         Employed
##       <mth> <chr>         <chr>            <dbl>
##  1 1939 Jan CEU0500000001 Total Private    25338
##  2 1939 Feb CEU0500000001 Total Private    25447
##  3 1939 Mar CEU0500000001 Total Private    25833
##  4 1939 Apr CEU0500000001 Total Private    25801
##  5 1939 May CEU0500000001 Total Private    26113
##  6 1939 Jun CEU0500000001 Total Private    26485
##  7 1939 Jul CEU0500000001 Total Private    26481
##  8 1939 Aug CEU0500000001 Total Private    26848
##  9 1939 Sep CEU0500000001 Total Private    27468
## 10 1939 Oct CEU0500000001 Total Private    27830
## # ℹ 143,402 more rows
us_total_private <- us_employment %>%
  filter(Title == "Total Private")
us_total_private %>%
  autoplot(Employed)

us_total_private %>%
  gg_season(Employed)

us_total_private %>%
  gg_subseries(Employed)

us_total_private %>%
  gg_lag(Employed, geom = "point") 

us_total_private %>%
  ACF(Employed )
## # A tsibble: 29 x 3 [1M]
## # Key:       Series_ID [1]
##    Series_ID          lag   acf
##    <chr>         <cf_lag> <dbl>
##  1 CEU0500000001       1M 0.997
##  2 CEU0500000001       2M 0.993
##  3 CEU0500000001       3M 0.990
##  4 CEU0500000001       4M 0.986
##  5 CEU0500000001       5M 0.983
##  6 CEU0500000001       6M 0.980
##  7 CEU0500000001       7M 0.977
##  8 CEU0500000001       8M 0.974
##  9 CEU0500000001       9M 0.971
## 10 CEU0500000001      10M 0.968
## # ℹ 19 more rows

Can you spot any seasonality, cyclicity and trend?

The autoplot shows a strong upward overall trend in employment over the years along with a cyclical effect of economic downturns like the 2008 recession and huge dips in employment. The gg_season plot shows that there is some seasonality in the employment data as we tend to see peaks about halfway through the year around summertime and then dips towards the end of the year this could be due to seasonal summer jobs starting and ending. In the gg_subseries plot we can see that there is a repeating monthly cycle that occurs indicating a repeating seasonal effect however this effect is not very pronounced.

What did you learn about the series?

I learned that the employment data is pretty persistent to long term growth but is highly influenced from economic factors like the 2008 recession. We can see that there is consistent long term growth for the employment force as shown in the gg_lag and ACF results. There is also some seasonality that effects employment but it pales in comparison to cyclical economic events like the 2008 recession.

What can you say about the seasonal patterns?

The gg_series shows that the employment data does have some seasonality with small peaks midway through the year with dips at the end which can be explained by seasonal summer jobs causing the peaks and then also causing the dips when they end. We can also see some monthly trends in the gg_subseries plot that shows consistent monthly patterns in the data as well but that are not as pronounced as economic cycle effects such as the 2008 recession.

Can you identify any unusual years?

Yes 2008 was an unusual year as it saw a huge dip in employment this was due to the 2008 recession.

Bricks Data

aus_production
## # A tsibble: 218 x 7 [1Q]
##    Quarter  Beer Tobacco Bricks Cement Electricity   Gas
##      <qtr> <dbl>   <dbl>  <dbl>  <dbl>       <dbl> <dbl>
##  1 1956 Q1   284    5225    189    465        3923     5
##  2 1956 Q2   213    5178    204    532        4436     6
##  3 1956 Q3   227    5297    208    561        4806     7
##  4 1956 Q4   308    5681    197    570        4418     6
##  5 1957 Q1   262    5577    187    529        4339     5
##  6 1957 Q2   228    5651    214    604        4811     7
##  7 1957 Q3   236    5317    227    603        5259     7
##  8 1957 Q4   320    6152    222    582        4735     6
##  9 1958 Q1   272    5758    199    554        4608     5
## 10 1958 Q2   233    5641    229    620        5196     7
## # ℹ 208 more rows
aus_production %>%
  autoplot(Bricks)
## Warning: Removed 20 rows containing missing values or values outside the scale range
## (`geom_line()`).

aus_production %>%
  gg_season(Bricks)
## Warning: Removed 20 rows containing missing values or values outside the scale range
## (`geom_line()`).

aus_production %>%
  gg_subseries(Bricks)
## Warning: Removed 5 rows containing missing values or values outside the scale range
## (`geom_line()`).

aus_production %>%
  gg_lag(Bricks, geom = "point")
## Warning: Removed 20 rows containing missing values (gg_lag).

aus_production %>%
  ACF(Bricks)
## # A tsibble: 22 x 2 [1Q]
##         lag   acf
##    <cf_lag> <dbl>
##  1       1Q 0.900
##  2       2Q 0.815
##  3       3Q 0.813
##  4       4Q 0.828
##  5       5Q 0.720
##  6       6Q 0.642
##  7       7Q 0.655
##  8       8Q 0.692
##  9       9Q 0.609
## 10      10Q 0.556
## # ℹ 12 more rows

Can you spot any seasonality, cyclicity and trend?

The autoplot shows an upward trend up until the mid 1980s followed by a huge drop and then recovery and then another decline in brick production. The gg_series plot shows some seasonality with upward trends in Q2-Q3 followed by lower production in Q4 and Q1. This is confirmed in the gg_subseries plot where we can see consistent trends in each quarter over the years. The autoplot shows that there is some cyclical trends in the data

What did you learn about the series?

I learned that brick production in Australia saw a steady increase in production until the mid 1980s when it saw a steep decline followed by a recovery and then decline over the years. I also learned that brick production is seasonal and cyclical. Also the lag plot and ACF results show that the current production is highly dependent on past recent production as recent lags are highly correlated.

What can you say about the seasonal patterns?

The gg_series and gg_subseries both show that there tends to be higher brick production in Q2 and Q3 compared to Q1 and Q4. The production in Q4 is only slightly less than Q2 and Q3 but its still consistently lower. This could be due to the weather/seasons and construction cycles.

Can you identify any unusual years?

There was a huge dip in the mid 1980s that suggests an outside factor or industry shift or just economic downturn that caused the huge dip. After the huge dip the production was able to recover but never to its previous peaks suggesting that there could have been and industry shift to using another material in construction.

Hare Data

pelt
## # A tsibble: 91 x 3 [1Y]
##     Year  Hare  Lynx
##    <dbl> <dbl> <dbl>
##  1  1845 19580 30090
##  2  1846 19600 45150
##  3  1847 19610 49150
##  4  1848 11990 39520
##  5  1849 28040 21230
##  6  1850 58000  8420
##  7  1851 74600  5560
##  8  1852 75090  5080
##  9  1853 88480 10170
## 10  1854 61280 19600
## # ℹ 81 more rows
pelt %>%
  autoplot(Hare)

pelt %>%
  gg_subseries(Hare)

pelt %>%
  gg_lag(Hare, geom = "point")

pelt %>%
  ACF(Hare)
## # A tsibble: 19 x 2 [1Y]
##         lag     acf
##    <cf_lag>   <dbl>
##  1       1Y  0.658 
##  2       2Y  0.214 
##  3       3Y -0.155 
##  4       4Y -0.401 
##  5       5Y -0.493 
##  6       6Y -0.401 
##  7       7Y -0.168 
##  8       8Y  0.113 
##  9       9Y  0.307 
## 10      10Y  0.340 
## 11      11Y  0.296 
## 12      12Y  0.206 
## 13      13Y  0.0372
## 14      14Y -0.153 
## 15      15Y -0.285 
## 16      16Y -0.295 
## 17      17Y -0.202 
## 18      18Y -0.0676
## 19      19Y  0.0956

Can you spot any seasonality, cyclicity and trend?

The autoplot does not show any inherent trend or seasonality but it does show a strong cyclical pattern. We see peaks and drops at consistent cyclical periods over time.

What did you learn about the series?

I learned that while the hare population does not follow a seasonal trend like someone might expect and instead follows a more cyclical trend that’s very boom or bust with big peaks followed by equally big drops.

What can you say about the seasonal patterns?

There does not seem to be any seasonality for the hare population and instead it seems to follow a longer cyclical pattern. This is most likely due to hare reproduction patterns and ecological factors rather than just the weather.

Can you identify any unusual years?

Yes there were huge booms in the 1860s and 1880s that were unusual. Those booms were never recreated and post 1880s we see much more consistent peaks and dips not as high as the ones in the 1860s and 1880s.

PBS Data

PBS
## # A tsibble: 67,596 x 9 [1M]
## # Key:       Concession, Type, ATC1, ATC2 [336]
##       Month Concession   Type      ATC1  ATC1_desc ATC2  ATC2_desc Scripts  Cost
##       <mth> <chr>        <chr>     <chr> <chr>     <chr> <chr>       <dbl> <dbl>
##  1 1991 Jul Concessional Co-payme… A     Alimenta… A01   STOMATOL…   18228 67877
##  2 1991 Aug Concessional Co-payme… A     Alimenta… A01   STOMATOL…   15327 57011
##  3 1991 Sep Concessional Co-payme… A     Alimenta… A01   STOMATOL…   14775 55020
##  4 1991 Oct Concessional Co-payme… A     Alimenta… A01   STOMATOL…   15380 57222
##  5 1991 Nov Concessional Co-payme… A     Alimenta… A01   STOMATOL…   14371 52120
##  6 1991 Dec Concessional Co-payme… A     Alimenta… A01   STOMATOL…   15028 54299
##  7 1992 Jan Concessional Co-payme… A     Alimenta… A01   STOMATOL…   11040 39753
##  8 1992 Feb Concessional Co-payme… A     Alimenta… A01   STOMATOL…   15165 54405
##  9 1992 Mar Concessional Co-payme… A     Alimenta… A01   STOMATOL…   16898 61108
## 10 1992 Apr Concessional Co-payme… A     Alimenta… A01   STOMATOL…   18141 65356
## # ℹ 67,586 more rows
h02_cost <- PBS %>%
  filter(ATC2 == "H02") %>%
  mutate(cost_thousands = Cost / 1000)
h02_cost
## # A tsibble: 816 x 10 [1M]
## # Key:       Concession, Type, ATC1, ATC2 [4]
##       Month Concession   Type     ATC1  ATC1_desc ATC2  ATC2_desc Scripts   Cost
##       <mth> <chr>        <chr>    <chr> <chr>     <chr> <chr>       <dbl>  <dbl>
##  1 1991 Jul Concessional Co-paym… H     Systemic… H02   CORTICOS…   63261 317384
##  2 1991 Aug Concessional Co-paym… H     Systemic… H02   CORTICOS…   53528 269891
##  3 1991 Sep Concessional Co-paym… H     Systemic… H02   CORTICOS…   52822 269703
##  4 1991 Oct Concessional Co-paym… H     Systemic… H02   CORTICOS…   54016 280418
##  5 1991 Nov Concessional Co-paym… H     Systemic… H02   CORTICOS…   49281 268070
##  6 1991 Dec Concessional Co-paym… H     Systemic… H02   CORTICOS…   51798 277139
##  7 1992 Jan Concessional Co-paym… H     Systemic… H02   CORTICOS…   42436 221772
##  8 1992 Feb Concessional Co-paym… H     Systemic… H02   CORTICOS…   52913 272345
##  9 1992 Mar Concessional Co-paym… H     Systemic… H02   CORTICOS…   62908 325700
## 10 1992 Apr Concessional Co-paym… H     Systemic… H02   CORTICOS…   68499 349271
## # ℹ 806 more rows
## # ℹ 1 more variable: cost_thousands <dbl>
h02_cost %>% 
  autoplot(cost_thousands)

h02_cost %>%
  gg_season(cost_thousands)

h02_cost %>%
  gg_subseries(cost_thousands)

h02_cost %>%
  filter(Concession == "General") %>%
  filter(Type == "Safety net") %>%
  gg_lag(cost_thousands)

h02_cost %>%
  filter(Concession == "General") %>%
  filter(Type == "Co-payments") %>%
  gg_lag(cost_thousands)

h02_cost %>%
  filter(Concession == "Concessional") %>%
  filter(Type == "Co-payments") %>%
  gg_lag(cost_thousands)

h02_cost %>%
  filter(Concession == "Concessional") %>%
  filter(Type == "Safety net") %>%
  gg_lag(cost_thousands)

h02_cost %>%
  filter(Concession == "General") %>%
  filter(Type == "Safety net") %>%
  ACF(cost_thousands)
## # A tsibble: 23 x 6 [1M]
## # Key:       Concession, Type, ATC1, ATC2 [1]
##    Concession Type       ATC1  ATC2       lag     acf
##    <chr>      <chr>      <chr> <chr> <cf_lag>   <dbl>
##  1 General    Safety net H     H02         1M  0.616 
##  2 General    Safety net H     H02         2M  0.225 
##  3 General    Safety net H     H02         3M -0.0443
##  4 General    Safety net H     H02         4M -0.263 
##  5 General    Safety net H     H02         5M -0.412 
##  6 General    Safety net H     H02         6M -0.454 
##  7 General    Safety net H     H02         7M -0.396 
##  8 General    Safety net H     H02         8M -0.255 
##  9 General    Safety net H     H02         9M -0.0557
## 10 General    Safety net H     H02        10M  0.194 
## # ℹ 13 more rows
h02_cost %>%
  filter(Concession == "General") %>%
  filter(Type == "Co-payments") %>%
  ACF(cost_thousands)
## # A tsibble: 23 x 6 [1M]
## # Key:       Concession, Type, ATC1, ATC2 [1]
##    Concession Type        ATC1  ATC2       lag   acf
##    <chr>      <chr>       <chr> <chr> <cf_lag> <dbl>
##  1 General    Co-payments H     H02         1M 0.525
##  2 General    Co-payments H     H02         2M 0.484
##  3 General    Co-payments H     H02         3M 0.417
##  4 General    Co-payments H     H02         4M 0.386
##  5 General    Co-payments H     H02         5M 0.320
##  6 General    Co-payments H     H02         6M 0.357
##  7 General    Co-payments H     H02         7M 0.346
##  8 General    Co-payments H     H02         8M 0.239
##  9 General    Co-payments H     H02         9M 0.272
## 10 General    Co-payments H     H02        10M 0.197
## # ℹ 13 more rows
h02_cost %>%
  filter(Concession == "Concessional") %>%
  filter(Type == "Co-payments") %>%
  ACF(cost_thousands)
## # A tsibble: 23 x 6 [1M]
## # Key:       Concession, Type, ATC1, ATC2 [1]
##    Concession   Type        ATC1  ATC2       lag   acf
##    <chr>        <chr>       <chr> <chr> <cf_lag> <dbl>
##  1 Concessional Co-payments H     H02         1M 0.834
##  2 Concessional Co-payments H     H02         2M 0.679
##  3 Concessional Co-payments H     H02         3M 0.514
##  4 Concessional Co-payments H     H02         4M 0.352
##  5 Concessional Co-payments H     H02         5M 0.264
##  6 Concessional Co-payments H     H02         6M 0.219
##  7 Concessional Co-payments H     H02         7M 0.253
##  8 Concessional Co-payments H     H02         8M 0.337
##  9 Concessional Co-payments H     H02         9M 0.464
## 10 Concessional Co-payments H     H02        10M 0.574
## # ℹ 13 more rows
h02_cost %>%
  filter(Concession == "Concessional") %>%
  filter(Type == "Safety net") %>%
  ACF(cost_thousands)
## # A tsibble: 23 x 6 [1M]
## # Key:       Concession, Type, ATC1, ATC2 [1]
##    Concession   Type       ATC1  ATC2       lag     acf
##    <chr>        <chr>      <chr> <chr> <cf_lag>   <dbl>
##  1 Concessional Safety net H     H02         1M  0.710 
##  2 Concessional Safety net H     H02         2M  0.349 
##  3 Concessional Safety net H     H02         3M  0.0247
##  4 Concessional Safety net H     H02         4M -0.253 
##  5 Concessional Safety net H     H02         5M -0.436 
##  6 Concessional Safety net H     H02         6M -0.496 
##  7 Concessional Safety net H     H02         7M -0.426 
##  8 Concessional Safety net H     H02         8M -0.248 
##  9 Concessional Safety net H     H02         9M  0.0168
## 10 Concessional Safety net H     H02        10M  0.322 
## # ℹ 13 more rows

Can you spot any seasonality, cyclicity and trend?

We see a steady upward trend over the years for Concessional co payments cost over the years while the others tend to rise and fall. There seems to be a strong cyclical trend for all of the categories spanning multiple years with large peaks and dips. There also seems to be some seasonality in the safety net payments where they start high at the beginning of each year then drop off and steadily rise until the end of the year.

What did you learn about the series?

I learned that H02 costs have risen pretty steadily over the years. I also learned that there is a seasonal effect on H02 costs where they seem to be higher at the beginning of each year. I also observed a cyclical effect on the price that could be linked to policy terms. Finally I learned that concessional costs seem to be highly correlated to the past price from the gg_lag and ACF results while General costs are not highly correlated with past costs.

What can you say about the seasonal patterns?

There are seasonal patterns for the safety net payments where we see high initial cost then a dip followed by a steady increase until the end of each year. While the Co-payments do not seem to follow any strong seasonal pattern.

Can you identify any unusual years?

While there are some years with bigger peaks and dips I do not notice any glaringly obvious unusual years.

Barrels Data

us_gasoline
## # A tsibble: 1,355 x 2 [1W]
##        Week Barrels
##      <week>   <dbl>
##  1 1991 W06    6.62
##  2 1991 W07    6.43
##  3 1991 W08    6.58
##  4 1991 W09    7.22
##  5 1991 W10    6.88
##  6 1991 W11    6.95
##  7 1991 W12    7.33
##  8 1991 W13    6.78
##  9 1991 W14    7.50
## 10 1991 W15    6.92
## # ℹ 1,345 more rows
us_gasoline %>%
  autoplot(Barrels)

us_gasoline %>%
  gg_season(Barrels)

us_gasoline %>%
  gg_subseries(Barrels)

us_gasoline %>%
  gg_lag(Barrels, geom = "point")

us_gasoline %>%
  ACF(Barrels)
## # A tsibble: 31 x 2 [1W]
##         lag   acf
##    <cf_lag> <dbl>
##  1       1W 0.893
##  2       2W 0.882
##  3       3W 0.873
##  4       4W 0.866
##  5       5W 0.847
##  6       6W 0.844
##  7       7W 0.832
##  8       8W 0.831
##  9       9W 0.822
## 10      10W 0.808
## # ℹ 21 more rows

Can you spot any seasonality, cyclicity and trend?

The autoplot shows that there is a clear upward trend in US gas use with the consumption of gas increasing over the years consistently. There are some dips and peaks but for the most part the overall consumption of gas has be steadily increasing over the years. The gg_subseries plot does seem to show some seasonality in the data with peaks and dips around the same time each year. The autoplot also shows some cyclical patterns in the data with bigger dips spread out across multiple years which although somewhat irregular are still indicating of a larger cyclical pattern.

What did you learn about the series?

I learned that gas consumption has increased over the years which could be due to a higher reliance on gas and also population increases in the US. I also learned that gas consumption has a seasonal pattern but, I also learned that there is a broader cyclical pattern on gas consumption that could be tied to policy changes and also administration changes every 4 years. The gg_lag and ACF results also shows a high correlation between current and past prices that decreases as the lag increases.

What can you say about the seasonal patterns?

The gg_subseries and gg_season plots show that there is seasonality with the consumption of gas with lower consumption at the beginning of each year followed by an increase until the middle of the year where it peaks during the summer months and then decreases again. This could be due to increased travel in the warmer summer months.

Can you identify any unusual years?

There are some years where we see much larger drops like in the early 1990s and early 2000s these could have been due to external economic or ecologial factors.