ccf_plot: Time Series Cross Correlation Lags Visualization

View source: R/correlation_functions.R

ccf_plotR Documentation

Time Series Cross Correlation Lags Visualization

Description

Visualize the series y against the series x lags (according to the setting of the lags argument) and return the corresponding cross-correlation value for each lag

Usage

ccf_plot(x, y, lags = 0:12, margin = 0.02, n_plots = 3,
  Xshare = TRUE, Yshare = TRUE, title = NULL)

Arguments

x

A univariate time series object of a class "ts"

y

A univariate time series object of a class "ts"

lags

An integer, set the lags range, by default will plot the two series along with the first 12 lags

margin

Plotly parameter, either a single value or four values (all between 0 and 1). If four values provided, the first will be used as the left margin, the second will be used as the right margin, the third will be used as the top margin, and the fourth will be used as the bottom margin. If a single value provided, it will be used as all four margins.

n_plots

An integer, define the number of plots per row

Xshare

Plotly parameter, should the x-axis be shared amongst the subplots?

Yshare

Plotly parameter, should the y-axis be shared amongst the subplots?

title

A character, optional, set the plot title

Value

Plot

Examples


data("USUnRate")
data("USVSales")

ccf_plot(x = USVSales, y = USUnRate)

#Plotting the first 6 lead and lags of the USVSales with the USUnRate
ccf_plot(x = USVSales, y = USUnRate, lags = -6:6)

# Setting the plot margin and number of plots in each raw
ccf_plot(x = USVSales, y = USUnRate, lags = c(0, 6, 12, 24), 
margin = 0.01,  n_plots = 2)

TSstudio documentation built on Aug. 9, 2023, 9:06 a.m.