Module 1 Discussion #2

Author

Adrian Aziza

1 Part I — Package exploration

The fpp3 package is a convenience meta-package associated with the textbook Forecasting: Principles and Practice. It loads the core tidy time-series packages used throughout the course and provides direct access to datasets used in examples. More importantly, its construction reflects the underlying principles of forecasting in a way that is both coherent and extensible. The workflow it enforces is not arbitrary — it mirrors how forecasting problems are actually approached in practice. Its versatility is well aligned with the types of tasks I expect to encounter both in this course and in future professional settings, where reproducibility, clarity, and interpretability matter as much as model performance.

A tsibble is a tidy time-series data structure that explicitly represents time through an index variable and supports multiple time series through key variables, enabling time-aware operations and modeling. This is important because the temporal nature of forecasting is its entire underlying principle. If a series cannot be parsed correctly over time — or related back to its own history in a coherent way — then any confidence interval or forecast output risks losing its intended meaning. The tsibble framework enforces this discipline by design, making it much harder to accidentally violate the assumptions that time-series analysis depends on.

The feasts package focuses on exploratory analysis and diagnostics for time series, including decomposition methods, autocorrelation analysis, and seasonal visualization. This is the stage where the pieces are tied together: before fitting models, you need to understand what structure is actually present in the data. These tools allow patterns to be surfaced and communicated clearly, and they support visualizations that are capable of conveying complex behavior without unnecessary abstraction.

The fable package provides a framework for fitting, comparing, and forecasting statistical time-series models using tsibbles, including ARIMA, ETS, and time-series linear models. The key point here is not just that models can be fit, but that they can be compared and evaluated within a consistent structure. This makes feature extraction and model behavior more explicit and precise, and it allows forecasts to be treated as first-class objects that integrate cleanly with the rest of the workflow.

1.1 Verifying package installation and datasets

library(fpp3)

fpp3_packages()
 [1] "cli"         "crayon"      "dplyr"       "fable"       "feasts"     
 [6] "ggplot2"     "lubridate"   "purrr"       "rstudioapi"  "tibble"     
[11] "tidyr"       "tsibble"     "tsibbledata"
fpp3_data <- as.data.frame(data(package = "fpp3")$results)
nrow(fpp3_data)
[1] 25

2 Part II — FRED monthly data + plots

For Part II, I pulled a monthly time series from FRED using the fredr package. The point here wasn’t just to download data, but to practice the full loop the course emphasizes: retrieve, structure correctly, visualize, and diagnose before moving toward modeling. If the data structure is wrong at the start, everything downstream becomes performative — plots and models may run, but they lose their interpretability.

After setting my API key, I requested the series and immediately converted it into a monthly tsibble. Even when FRED provides monthly observations, the raw date field can encourage treating the index like generic calendar dates. Converting the index to yearmonth() makes the temporal resolution explicit and prevents mismatches in seasonal tools, lag interpretation, and model assumptions. I used transmute() to keep only the time index and value so that every downstream operation remains interpretable.

library(fredr)
library(tsibble)
library(feasts)
library(ggplot2)
library(dplyr)

fredr_set_key(Sys.getenv("FRED_API_KEY"))

fred_raw <- fredr(
  series_id = "RSAFS",
  observation_start = as.Date("1992-01-01")
)

fred_ts <- fred_raw |>
  transmute(
    Month = yearmonth(date),
    value = value
  ) |>
  as_tsibble(index = Month)

fred_ts
# A tsibble: 407 x 2 [1M]
      Month  value
      <mth>  <dbl>
 1 1992 Jan 159177
 2 1992 Feb 159189
 3 1992 Mar 158647
 4 1992 Apr 159921
 5 1992 May 160471
 6 1992 Jun 161205
 7 1992 Jul 162855
 8 1992 Aug 162412
 9 1992 Sep 164361
10 1992 Oct 166063
# ℹ 397 more rows

2.1 Time plot — baseline reality check

fred_ts |>
  autoplot(value) +
  labs(
    title = "Monthly Retail Sales: Food Services (RSAFS)",
    x = "Month",
    y = "Value"
  )

2.2 Seasonal plot and seasonal subseries

fred_ts |>
  gg_season(value, labels = "both") +
  labs(
    title = "Seasonal Plot: RSAFS",
    x = "Month of year",
    y = "Value"
  )

fred_ts |>
  gg_subseries(value) +
  labs(
    title = "Seasonal Subseries Plot: RSAFS",
    x = "Month of year",
    y = "Value"
  )

2.3 Autocorrelation function (ACF)

fred_ts |>
  ACF(value) |>
  autoplot() +
  labs(
    title = "ACF: RSAFS",
    x = "Lag",
    y = "Autocorrelation"
  )

3 Citation

Hyndman and Khandakar discuss automatic forecasting workflows and model selection in R (hyndman2008?).

@article{hyndman2008,
  title   = {Automatic Time Series Forecasting: The forecast Package for R},
  author  = {Hyndman, Rob J. and Khandakar, Yeasmin},
  journal = {Journal of Statistical Software},
  year    = {2008},
  volume  = {27},
  number  = {3},
  pages   = {1--22},
  doi     = {10.18637/jss.v027.i03}
}