Module 1 Discussion 2

Author

Ethan Wright

Question 1

library(fpp3)
Warning: package 'fpp3' was built under R version 4.5.2
Registered S3 method overwritten by 'tsibble':
  method               from 
  as_tibble.grouped_df dplyr
── Attaching packages ──────────────────────────────────────────── fpp3 1.0.2 ──
✔ tibble      3.3.0     ✔ tsibble     1.1.6
✔ dplyr       1.1.4     ✔ tsibbledata 0.4.1
✔ tidyr       1.3.1     ✔ feasts      0.4.2
✔ lubridate   1.9.4     ✔ fable       0.5.0
✔ ggplot2     3.5.2     
Warning: package 'tsibble' was built under R version 4.5.2
Warning: package 'tsibbledata' was built under R version 4.5.2
Warning: package 'feasts' was built under R version 4.5.2
Warning: package 'fabletools' was built under R version 4.5.2
Warning: package 'fable' was built under R version 4.5.2
── 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()
data(package = "fpp3")

fpp3 is a forecasting package created by Hydman that includes other packages that are necessary for forecasting. The packages it loads are tibble, dplyr, tidyr, lubridate, ggplot2, tsibble, tsibbledata, feasts, and fable. It has 25 data sets (found using data(package = )).

tsibble is a time series data frame that can handle multiple time series at a time, regardless of the time periods.

feasts is a package that helps visualise and study features of time series such as ACFs, seasonality, and more.

fable is the modeling package that helps us fit data after studying it using methods such as arima, random walk, and naive, to name a few.

Question 2

library(fredr)
Warning: package 'fredr' was built under R version 4.5.2
require(fredr)
fredr_set_key("18f0dfa970a5782481171e8fa3980e41")

4 Plots From CPI Data

library(feasts)
cpi<-fredr(
  series_id = "CPIAUCSL",
  observation_start = as.Date("2010-01-01"),
  frequency = 'm'
)
cpi<-cpi|>
  select(date, value)|>
  mutate(date = yearmonth(date))|>
  as_tsibble(index = date)

cpi|>
  feasts::autoplot(value) + labs(
    title = "U.S CPI",
    y = "Index",
    x = "Year"
  )

cpi|>
  gg_season(value) + labs(
    title = "Seasonal CPI",
    y = "Index"
  )
Warning: `gg_season()` was deprecated in feasts 0.4.2.
ℹ Please use `ggtime::gg_season()` instead.

cpi|>
  gg_subseries(value) + labs(
    title = "Seasonal Subseries CPI",
    y = "Index"
  )
Warning: `gg_subseries()` was deprecated in feasts 0.4.2.
ℹ Please use `ggtime::gg_subseries()` instead.