tidy_fft | R Documentation |
Perform an fft using stats::fft()
and return a tidier style output list with plots.
tidy_fft(
.data,
.date_col,
.value_col,
.frequency = 12L,
.harmonics = 1L,
.upsampling = 10L
)
.data |
The data.frame/tibble you will pass for analysis. |
.date_col |
The column that holds the date. |
.value_col |
The column that holds the data to be analyzed. |
.frequency |
The frequency of the data, 12 = monthly for example. |
.harmonics |
How many harmonic waves do you want to produce. |
.upsampling |
The up sampling of the time series. |
This function will perform a few different things, but primarily it will
compute the Fast Discrete Fourier Transform (FFT) using stats::fft()
. The
formula is given as:
y[h] = sum_{k=1}^n z[k]*exp(-2*pi*1i*(k-1)*(h-1)/n)
There are many items returned inside of a list invisibly. There are four primary categories of data returned in the list. Below are the primary categories and the items inside of them.
data:
data
error_data
input_vector
maximum_harmonic_tbl
differenced_value_tbl
dff_tbl
ts_obj
plots:
harmonic_plot
diff_plot
max_har_plot
harmonic_plotly
max_har_plotly
parameters:
harmonics
upsampling
start_date
end_date
freq
model:
m
harmonic_obj
harmonic_model
model_summary
A list object returned invisibly.
Steven P. Sanderson II, MPH
Other Data Generator:
ts_brownian_motion()
,
ts_brownian_motion_augment()
,
ts_geometric_brownian_motion()
,
ts_geometric_brownian_motion_augment()
,
ts_random_walk()
suppressPackageStartupMessages(library(dplyr))
data_tbl <- AirPassengers %>%
ts_to_tbl() %>%
select(-index)
a <- tidy_fft(
.data = data_tbl,
.value_col = value,
.date_col = date_col,
.harmonics = 3,
.frequency = 12
)
a$plots$max_har_plot
a$plots$harmonic_plot
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.