##I The fpp3 package is from the testxtbook Data for “Forecasting: Principles and Practice” (3rd Edition).It includes several packages; tsibble, feasts, fable, dplyr, ggplot2, tidyr, tsibbledata, and lubridate. All of these packages are helpful for running time series analysis or creating data visuals. The package also includes 25 data sets. There are also additonal data sets within the other packages.

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()
library(tsibbledata)

data(package = "fpp3")
length(data(package = "fpp3")$results[, "Item"])
## [1] 25
library(tsibble)

The tsibble package tells R that the dataset is a time series. It requires an index, which tells r what the time intervals for the data are.

library(feasts)

The feasts package is Feature Extraction and Statistics for Time Series. It includes “a collection of features, decomposition methods, statistical summaries and graphics functions for the analysing tidy time series data” (R Help). These functions allow for pulling out data characteristics like sorting into seasons.

library(fable)

The fable package includes forecasting models for time series. These include, “automatically selected exponential smoothing (ETS) and autoregressive integrated moving average (ARIMA) models” (R Help).

##II

library(readr)
wfh <- read_csv("FULLREMOTECURR.csv")
## Rows: 46 Columns: 2
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## dbl  (1): FULLREMOTECURR
## date (1): observation_date
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
summary(wfh)
##  observation_date     FULLREMOTECURR 
##  Min.   :2021-11-01   Min.   :10.72  
##  1st Qu.:2022-10-08   1st Qu.:12.13  
##  Median :2023-09-16   Median :12.83  
##  Mean   :2023-09-16   Mean   :13.07  
##  3rd Qu.:2024-08-24   3rd Qu.:13.72  
##  Max.   :2025-08-01   Max.   :17.75
head(wfh)
## # A tibble: 6 × 2
##   observation_date FULLREMOTECURR
##   <date>                    <dbl>
## 1 2021-11-01                 15.3
## 2 2021-12-01                 14.0
## 3 2022-01-01                 17.8
## 4 2022-02-01                 17.7
## 5 2022-03-01                 15.5
## 6 2022-04-01                 13.0
#To make the data time series with tsibble first need to make sure it reads the dates correctly since they are monthly. 
library(lubridate)

wfh <- wfh  %>% 
     mutate(observation_date = ymd(observation_date)) %>%  
     filter(!is.na(observation_date)) %>%
     mutate(observation_date = yearmonth(observation_date)) %>%
    as_tsibble(index = observation_date)

head(wfh)
## # A tsibble: 6 x 2 [1M]
##   observation_date FULLREMOTECURR
##              <mth>          <dbl>
## 1         2021 Nov           15.3
## 2         2021 Dec           14.0
## 3         2022 Jan           17.8
## 4         2022 Feb           17.7
## 5         2022 Mar           15.5
## 6         2022 Apr           13.0

I used the data from from FRED, “All Full-Time Wage and Salary Workers: Working Fully Remote (FULLREMOTECURR)” The data set includes percent of US full-time wage and salary workers with all work-from-home days (no days working on their employer or client worksite) the prior week.

#Autoplot Time Series

 autoplot(wfh, FULLREMOTECURR) +
     labs(y = "Percent (%)",
          title = "Working Fully Remote")

#Seasonal Time Series

#wfh |>
   # ggtime::gg_season(FULLREMOTECURR, labels = "both") 
    #labs(y = "Percent (%)",
    #title = "Seasonal Plot: Working Fully Remote")
    
wfh |>
   feasts::gg_season(FULLREMOTECURR, labels = "both") +
    labs(y = "Percent (%)",
    title = "Seasonal Plot: Working Fully Remote")
## Warning: `gg_season()` was deprecated in feasts 0.4.2.
## ℹ Please use `ggtime::gg_season()` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.

#Seasonal Subseries

wfh |>
  gg_subseries(FULLREMOTECURR) +
  labs(
    y = "Percent (%)",
    title = "Seasonal Subseries Plot: Working Fully Remote"
  )
## Warning: `gg_subseries()` was deprecated in feasts 0.4.2.
## ℹ Please use `ggtime::gg_subseries()` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.