library(fpp3)
?fpp3
data(package = "fpp3")Fpp3 Module 1 Discussion 2
1 Discussion Part I
1.1 What is the fpp3 package about? How many datasets does it have? What packages does it load?
First, I loaded in the fpp3, applied the help function to learn more about the package, and displayed all of the different datasets that the fpp3 package comes with.
The fpp3 is an R package created by Rob Hyndman that is specifically designed for conducting time series data analysis (Hyndman 2025). It comes equipped with many popular R packages such ggplot2, dplyr, and tidyr which can be seen above, as well as other packages like tsibble, feasts, and fable which are unique to the fpp3 package.
Additionally, the fpp3 package comes installed with 25 different time series datasets.
1.2 What is a tsibble?
?tsibbleA tsibble is essentially a time series tibble object in R. What makes a tsibble unique is the need for an index variable which specifies the time index of the data (daily, weekly, monthly, quarterly, or yearly data) (Wang, Cook, and Hyndman 2020). Additionally, there is the option to specify a key variable or multiple keys to go along with the time index to identify each individual record in the data. Additionally, the number of unique categories in the key variable will determine how many different time series there will be within the tsibble. The third component of a tsibble are measurable variables and these are the variables that we are interested in measuring over time.
1.3 What is the feasts package about?
?feastsThe feasts package literally stands for “Feature Extraction and Statistics for Time Series”. In short, the feasts package is mainly used for applying decomposition methods to time series to more clearly visualize the trends, seasonality, and cycles that are present in almost all times series data (O’Hara-Wild, Hyndman, and Wang 2025). It is primarily used in exploratory data analysis when you want to graph the time series, seasonality plots, sub series plots, and autocorrelation plots to get a sense of the patterns in the time series.
1.4 What is the fable package about?
?fableHelp on topic 'fable' was found in the following packages:
Package Library
fabletools /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/library
fable /Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/library
Using the first match ...
The fable package provides many useful forecasting methods and models that can be applied to time series data (O’Hara-Wild, Hyndman, and Wang 2024)
2 Discussion Part II: Visualization of Time Series Data
Before plotting any time series using the fredr datasets, I have first loaded in the necessary packages. I also kept getting an error when first using fredr saying “FRED API key must be set. See ?fredr_set_key”. So, I searched the help function and I realized you have to go to the FRED website, create an account, and then request an API key. I then got my API key and set it equal to fred_api_key in a .Renviron file that I had to create.
library(fredr)
fredr_set_key(Sys.getenv("fred_api_key"))Now with the packages set up, I have decided to look at the Global Economic Policy Uncertainty index from 1997 through the end of 2025.
gep <- fredr(series_id = "GEPUCURRENT",
observation_start = as.Date("1997-01-01"),
observation_end = as.Date("2026-01-01"))
gep <- gep |> mutate(month = yearmonth(date)) |>
select(-date) |>
as_tsibble(index = month)
# Graphing the time series
gep |> autoplot(value) +
labs(
title = "Global Economy Policy Uncertainty Index: Current Price Adjusted GDP",
x = "Time",
y = "Index")The overall global Economy Policy Uncertainty Index appears to be trending upward since 1997.
There appears to be some evidence of seasonality and some longer cycles as well.
Seasonality Plot
gep |> gg_season(value) +
labs(
title = "Global Economy Policy Uncertainty Index: Current Price Adjusted GDP",
subtitle = "Seasonality Plot",
x = "Time (Months)",
y = "Index"
)The seasonality plot confirms the upward trend in the uncertainty index over time (the blue, purple, and pink lines represent the most recent years and have the highest uncertainty index.
Appears to be consistent troughs in February, followed by consistent peaks in March. This could be a result of February being the month with the least amount of days.
For each year, it appears that the uncertainty index is slightly increasing from the beginning of the year to the end.
Subseries Plot
gep |> gg_subseries(value) +
labs(
title = "Global Economy Policy Uncertainty Index: Current Price Adjusted GDP",
subtitle = "Subseries Plot",
x = "Time (Years)",
y = "Index"
)The subseries plot confirms that March does have the highest mean level of the uncertainty index from 1997 to 2026. February seems to have the lowest average uncertainty index which we saw in the seasonality plot.
The general upward trend of the uncertainty index is captured here, as we can see the index increasing over the years for every month.
Lag Plot
gep |> gg_lag(value, geom = "point") +
labs(
title = "Global Economy Policy Uncertainty Index: Current Price Adjusted GDP",
subtitle = "Lag Plot",
x = "Lags",
y = "Index"
)Lag plots show how time series data is related with lagged versions of itself.
All of the lag plots show a fairly strong linear relationship between current uncertainty indices and uncertainty levels from a specified number of periods
(in this case months) ago. This suggests that the Economic Policy Uncertainty Index level now depends on what that level was in recent periods. Therefore, there is clear evidence of autocorrelation.