plot_acf: Calculate the autocorrelation function (ACF) for a time...

Description Usage Arguments Details Value Examples

View source: R/rutils.R

Description

Calculate the autocorrelation function (ACF) for a time series of returns, and plot it.

Usage

1
2
3
4
5
6
7
8
9
plot_acf(
  x_ts,
  lagg = 10,
  plo_t = TRUE,
  xlab = "Lag",
  ylab = "",
  main = "",
  ...
)

Arguments

x_ts

A vector, matrix, or time series of returns.

lagg

The maximum lag at which to calculate the ACF (default is 10).

plo_t

A Boolean argument: should a plot be made? (default is TRUE)

xlab

A string with the x-axis label.

ylab

A string with the y-axis label.

main

A string with the plot title.

...

Additional arguments to the function stats::acf().

Details

The function plot_acf() calculates the autocorrelation function (ACF) for a time series of returns, and plots it. The function plot_acf() is just a wrapper for the function stats::acf(). The function stats::acf() calculates the autocorrelation function, including the lag zero autocorrelation, which is by definition equal to 1.

The function plot_acf() calls the function stats::acf(), removes the spurious lag zero autocorrelation, creates a plot, and returns the ACF data invisibly.

Value

Returns the ACF data invisibly and creates a plot.

Examples

1
2
3
4
# Plot the ACF of random returns
rutils::plot_acf(rnorm(1e4), lag=10, main="ACF of Random Returns")
# Plot the ACF of VTI returns
rutils::plot_acf(na.omit(rutils::etf_env$re_turns$VTI), lag=10, main="ACF of VTI Returns")

algoquant/rutils documentation built on Feb. 26, 2021, 1:30 a.m.