Discussion 2

Author

Tin Vu

1 Part I:

1.1 What is fpp3package about? How many data sets does it have? What all packages does it load?

The fpp3 package contains all the data sets required or the examples and exercises in the book “Forecasting: principles and practice” by Hyndman (n.d.). It has 25 different data sets and loads tsibble, tsibbledata, feasts, fable, ggplot2, and dplyr, and tidyr

library(fpp3)

1.2 What is a tsibble?

A tsibble is a time series data structure with a time awareness built in. A tsibble has a time index, can have one or more keys to help with presenting multiple time series, helps with making sure that observations are in order, and is good for filling and handling any gaps or missing observations in the data. Very helpful for analyzing and visualizing time series data in a proper and consistent manner.

library(tsibble)

1.3 What is feasts package about?

The feasts package is mainly used to help with exploring the time series data before actually running any complicated models. Helps with time series visualization, seasonal plots, helps analyze any autocorrelation, and provides a summary statistic.

library(feasts)

1.4 What is fable package about?

The fable package is used for building, estimating, and creating forecasting time series models from the time series data set. Creates clean and readable forecasting models that fit the tsibble data. Other features are being able to compare multiple forecasting models and evaluating them to observe the accuracy of the models.

library(fable)

2 Part II: Visualization of time series data

library(fredr)
library(scales)
library(ggplot2)
fredr_set_key ("2e2c37e9aafe0f62c76d6bc4ef83765f")
fredr_series_search_id(
  search_text = "UNRATE",
  order_by = "popularity"
)

fredr_series_search_text("Unemployment Rate")
UNRATE_raw <- fredr(
  series_id = "UNRATE",
  observation_start = as.Date("1948-01-01")
)

UNRATE <- UNRATE_raw |> 
  mutate(month = yearmonth(date)) |>
  select(-date) |>
  as_tsibble(index = month)
autoplot(UNRATE, value) +
  labs( 
       title = "U.S. Unemployment Rate Throughout the Years", 
       subtitle = "1948-2025, Monthly", 
       caption = "https://fred.stlouisfed.org/series/UNRATE",
       y = "Rate (%)", 
       x = "Year"
  )

2.1 Sub-series Plots

UNRATE |>
  gg_subseries(value) +
  labs(title = "Seasonality of UNRATE 1948-2025",
    x = "Months",
    y = "Unemployment Rate (%)"
  )

2.2 Lagged Plots

UNRATE |>
  gg_lag(value, geom =  "point", alpha = 0.7) +
  labs(
    title = "Lagged U.S. Unemployment Rate Throughout the Years",
    x = "Years",
    y = "Unemployment Rate"
)

2.3 Smoothed Time Series Plot

UNRATE |>
  ggplot(aes(x = month, y = value)) +
  geom_line() +
  geom_smooth(se = FALSE) +
  labs(
    title = "Smoothed UNRATE 1948-2025",
    x = "Year",
    y = "Unemployment Rate (%)"
  )
`geom_smooth()` using method = 'loess' and formula = 'y ~ x'

2.4 Seasonality Plot

UNRATE |>
  gg_season(value) +
  labs(
    title = "Seasonality of UNRATE 1948-2025",
    x = "Months",
    y = "Unemployment Rate (%)"
  )

3 Additional Resources:

“Why the U.S. Unemployment Rate Is So High” by Kaufman (1978)

“Why Is the U.S. Unemployment Rate so Much Lower?” Shimer (1998)

4 References

Hyndman, Rob. n.d. “Fpp3: Data for "Forecasting: Principles and Practice" (3rd Edition).” https://doi.org/10.32614/CRAN.package.fpp3.
Kaufman, Roger. 1978. “Why the U.S. Unemployment Rate Is So High.” Challenge 21 (2): 40–49. https://doi.org/10.1080/05775132.1978.11470420.
Shimer, Robert. 1998. “Why Is the U.S. Unemployment Rate so Much Lower?” NBER Macroeconomics Annual 13 (January): 11–61. https://doi.org/10.1086/ma.13.4623732.