library(recipes)
library(dplyr)
FB_tbl <- FANG %>%
filter(symbol == "FB") %>%
select(symbol, date, adjusted)
# Create a recipe object with a timeseries signature step
# - 252 Trade days per year
# - period = c(252/4, 252): Adds quarterly and yearly fourier series
# - K = 2: Adds 1st and 2nd fourier orders
rec_obj <- recipe(adjusted ~ ., data = FB_tbl) %>%
step_fourier(date, period = c(252/4, 252), K = 2)
# View the recipe object
rec_obj
# Prepare the recipe object
prep(rec_obj)
# Bake the recipe object - Adds the Fourier Series
bake(prep(rec_obj), FB_tbl)
# Tidy shows which features have been added during the 1st step
# in this case, step 1 is the step_timeseries_signature step
tidy(prep(rec_obj))
tidy(prep(rec_obj), number = 1)
Run the code above in your browser using DataLab