Prep Data for Wavelet Plot
iidda_prep_wavelet.Rd
Prep data for wavelet plot. Prep steps were taken from code provided by Steven Lee (https://github.com/davidearn/StevenLee) and Kevin Zhao (https://github.com/davidearn/KevinZhao).
Usage
iidda_prep_wavelet(
data,
trend_data,
time_variable = "period_end_date",
series_variable = "deaths",
trend_variable = "deaths",
series_suffix = "_series",
trend_suffix = "_trend",
wavelet_variable = "detrend_norm",
output_emd_trend = "emd_trend",
output_norm = "norm",
output_sqrt_norm = "sqrt_norm",
output_log_norm = "log_norm",
output_emd_norm = "emd_norm",
output_emd_sqrt = "emd_sqrt",
output_emd_log = "emd_log",
output_detrend_norm = "detrend_norm",
output_detrend_sqrt = "detrend_sqrt",
output_detrend_log = "detrend_log",
data_harmonizer = SeriesHarmonizer(time_variable, series_variable),
trend_data_harmonizer = SeriesHarmonizer(time_variable, trend_variable),
data_deheaper = WaveletDeheaper(time_variable, series_variable),
trend_deheaper = WaveletDeheaper(time_variable, trend_variable),
joiner = WaveletJoiner(time_variable, series_suffix, trend_suffix),
interpolator = WaveletInterpolator(time_variable, series_variable, trend_variable,
series_suffix, trend_suffix),
normalizer = WaveletNormalizer(time_variable, series_variable, trend_variable,
series_suffix, trend_suffix, output_emd_trend, output_norm, output_sqrt_norm,
output_log_norm, output_emd_norm, output_emd_sqrt, output_emd_log,
output_detrend_norm, output_detrend_sqrt, output_detrend_log),
transformer = WaveletTransformer(time_variable, wavelet_variable, dt = 1/52, dj = 1/50,
lowerPeriod = 1/2, upperPeriod = 10, n.sim = 1000, make.pval = TRUE, date.format =
"%Y-%m-%d")
)
Arguments
- data
data frame containing time series data
- trend_data
data frame containing time series trend data
- time_variable
column name of time variable in `data`, default is "period_end_date"
- series_variable
column name of series variable in `data`, default is "deaths_series"
- trend_variable
column name of series variable in `data`, default is "deaths_trend"
- series_suffix
suffix to be appended to series data fields
- trend_suffix
suffix to be appended to trend data fields
- wavelet_variable
name of the field in `data` to be wavelet transformed
- output_emd_trend
name of output field for the empirical mode decomposition applied to `trend_variable`
- output_norm
name of output field for the `series_variable` normalized by `output_emd_trend`
- output_sqrt_norm
name of output field for the square root of `output_norm`
- output_log_norm
name of output field for the logarithm of (`output_norm` + `eps`)
- output_emd_norm
name of output field for the empirical mode decomposition applied to `output_norm`
- output_emd_sqrt
name of output field for the empirical mode decomposition applied to `output_sqrt_norm`
- output_emd_log
name of output field for the empirical mode decomposition applied to `output_log_norm`
- output_detrend_norm
name of output field for the computed field `output_norm`-`output_emd_norm`
- output_detrend_sqrt
name of output field for the computed field `output_sqrt_norm`-`output_emd_sqrt`
- output_detrend_log
name of output field for the computed field `output_log_norm`-`output_emd_log`
- data_harmonizer
function that harmonizes time scales and series names so there is one data point per time unit
- trend_data_harmonizer
function that harmonizes time scales and trend names so there is one data point per time unit
- data_deheaper
function that fixes heaping errors on series data
- trend_deheaper
function that fixes heaping errors on trend data
- joiner
function that joins series and trend data sets
- interpolator
function that linearly interpolates series and trend data
- normalizer
function that computes normalized fields
- transformer
function that computes wavelet transform
Value
list containing:
* transforemd_data
- wavelet transformed data
* tile_data_to_plot
- data set of the wavelet transformed data
prepped for plotting with ggplot2::geom_tile
* contour_data_to_plot
- data set of the transformed wavelet data prepped
for plotting with ggplot2::geom_contour