ADEC7406 Discussion 2

Author

Fabian Yang

1. Discussion Question 1

1.1. What is fpp3 package about? How many data sets does it have? What all packages does it load?

The fpp3 package is a package designed to support the book Forecasting: Principles and Practice (3rd edition). It provides a unified framework for time series analysis and forecasting in R. It also loads several core packages and example datasets used throughout the textbook (Hyndman, 2019). To identify how many datasets and what packages are included in fpp3, we can run:

library(fpp3)
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.4.1
✔ ggplot2     3.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")

After counting, we see that 25 datasets are included in the package.

1.2. What is a tsibble?

A tsibble is a tidy data structure designed specifically for time series analysis in R. The tsibble provides tools to “easily manipulate and analyse temporal data, such as filling in time gaps and aggregating over calendar periods” (Wang et al., 2018).

1.3. What is feasts package about?

The feasts package focuses on exploratory analysis of time series data. It provides a collection of features, decomposition methods, statistical summaries and graphics functions for the analysing tidy time series data (O’Hara-Wild et al., 2019a).

1.4. What is fable package about?

The fable package is the modeling and forecasting component of the fpp3 ecosystem (although the previous ones are part of that ecosystem as well). It provides a collection of commonly used univariate and multivariate time series forecasting models including ETS and ARIMA models (O’Hara-Wild et al., 2019b).

2. Discussion Question 2

Let us load the essential packages first:

library(fredr)
library(tidyverse)
library(ggplot2)
fredr_set_key(Sys.getenv("FRED_API_KEY"))

For this, I decided to plot 3 graphs: Consumer Price Index for All Urban Consumers (All Items in U.S. City Average), Unemployment Rate, and Federal Funds Effective Rate.

cpiaucsl_data <- fredr(series_id = "CPIAUCSL",
                       observation_start = as.Date("2015-01-01"),
                       observation_end = as.Date("2025-01-01")
                       )

unrate_data <- fredr(series_id = "UNRATE",
                     observation_start = as.Date("2015-01-01"),
                     observation_end = as.Date("2025-01-01")
                     )

fedfunds_data <- fredr(series_id = "FEDFUNDS",
                     observation_start = as.Date("2015-01-01"),
                     observation_end = as.Date("2025-01-01")
                     )

ggplot(cpiaucsl_data, aes(x = date, y = value)) +
  geom_line(color = "deepskyblue3") +
  labs(
    title = "Consumer Price Index for All Urban Consumers: All Items in U.S. City Average",
    subtitle = "FRED: CPIAUCSL",
    x = "Date",
    y = "Index (1982–84 = 100)"
  ) +
  theme_minimal()

ggplot(unrate_data, aes(x = date, y = value)) +
  geom_line(color = "red1") +
  labs(
    title = "U.S. Unemployment Rate",
    subtitle = "FRED: UNRATE",
    x = "Date",
    y = "Percent"
  ) +
  theme_minimal()

ggplot(fedfunds_data, aes(x = date, y = value)) +
  geom_line(color = "cyan3") +
  labs(
    title = "Federal Funds Effective Rate",
    subtitle = "FRED: FEDFUNDS",
    x = "Date",
    y = "Percent"
  ) +
  theme_minimal()

References

Hyndman, R. (2019). fpp3: Data for “forecasting: Principles and practice” (3rd edition). In CRAN: Contributed Packages. The R Foundation. https://doi.org/10.32614/cran.package.fpp3
O’Hara-Wild, M., Hyndman, R., & Wang, E. (2019a). Feasts: Feature extraction and statistics for time series. In CRAN: Contributed Packages. The R Foundation. https://doi.org/10.32614/cran.package.feasts
O’Hara-Wild, M., Hyndman, R., & Wang, E. (2019b). Fable: Forecasting models for tidy time series. In CRAN: Contributed Packages. The R Foundation. https://doi.org/10.32614/cran.package.fable
Wang, E., Cook, D., Hyndman, R., & O’Hara-Wild, M. (2018). Tsibble: Tidy temporal data frames and tools. In CRAN: Contributed Packages. The R Foundation. https://doi.org/10.32614/cran.package.tsibble