Skip to contents

Plots the autocorrelation (or partial autocorrelation) function of a series, with the approximate significance bounds, as a clean lollipop chart.

Usage

acf_plot(
  x,
  lag_max = NULL,
  type = c("correlation", "partial"),
  conf_level = 0.95,
  title = NULL,
  x_lab = "Lag",
  y_lab = NULL
)

Arguments

x

A numeric vector or ts object.

lag_max

Maximum lag (passed to stats::acf() / stats::pacf()).

type

"correlation" for the ACF or "partial" for the PACF.

conf_level

Confidence level for the significance bounds; a single number strictly between 0 and 1.

title, x_lab, y_lab

Title and axis labels.

Value

A ggplot2::ggplot object.

Examples

acf_plot(AirPassengers)

acf_plot(AirPassengers, type = "partial")