ts_lag_correlation: Time Series Lag Correlation Analysis

View source: R/ts-lag-correlation.R

ts_lag_correlationR Documentation

Time Series Lag Correlation Analysis

Description

This function outputs a list object of both data and plots.

The data output are the following:

  • lag_list

  • lag_tbl

  • correlation_lag_matrix

  • correlation_lag_tbl

The plots output are the following:

  • lag_plot

  • plotly_lag_plot

  • correlation_heatmap

  • plotly_heatmap

Usage

ts_lag_correlation(
  .data,
  .date_col,
  .value_col,
  .lags = 1,
  .heatmap_color_low = "white",
  .heatmap_color_hi = "steelblue"
)

Arguments

.data

A tibble of time series data

.date_col

A date column

.value_col

The value column being analyzed

.lags

This is a vector of integer lags, ie 1 or c(1,6,12)

.heatmap_color_low

What color should the low values of the heatmap of the correlation matrix be, the default is 'white'

.heatmap_color_hi

What color should the low values of the heatmap of the correlation matrix be, the default is 'steelblue'

Details

This function takes in a time series data in the form of a tibble and outputs a list object of data and plots. This function will take in an argument of '.lags' and get those lags in your data, outputting a correlation matrix, heatmap and lag plot among other things of the input data.

Value

A list object

Author(s)

Steven P. Sanderson II, MPH

See Also

Other Utility: auto_stationarize(), calibrate_and_plot(), internal_ts_backward_event_tbl(), internal_ts_both_event_tbl(), internal_ts_forward_event_tbl(), model_extraction_helper(), ts_get_date_columns(), ts_info_tbl(), ts_is_date_class(), ts_model_auto_tune(), ts_model_compare(), ts_model_rank_tbl(), ts_model_spec_tune_template(), ts_qq_plot(), ts_scedacity_scatter_plot(), ts_to_tbl(), util_difflog_ts(), util_doublediff_ts(), util_doubledifflog_ts(), util_log_ts(), util_singlediff_ts()

Examples

library(dplyr)

df <- ts_to_tbl(AirPassengers) %>% select(-index)
lags <- c(1,3,6,12)

output <- ts_lag_correlation(
  .data = df,
  .date_col = date_col,
  .value_col = value,
  .lags = lags
)

output$data$correlation_lag_matrix
output$plots$lag_plot


healthyR.ts documentation built on Nov. 15, 2023, 9:07 a.m.