acf_vec: Estimate autocorrelations of a numeric vector

View source: R/analyze_data.R

acf_vecR Documentation

Estimate autocorrelations of a numeric vector

Description

Estimate the sample autocorrelation function of a numeric vector.

Usage

acf_vec(x, lag_max = 24, ...)

Arguments

x

Numeric vector.

lag_max

Integer. Maximum lag for which the autocorrelation is estimated.

...

Further arguments passed to stats::acf().

Details

acf_vec() is a small wrapper around stats::acf(). It returns the sample autocorrelations as a numeric vector and removes lag 0 from the output, because lag 0 is always equal to 1 and is usually not needed for diagnostics.

Value

A numeric vector containing the sample autocorrelations for lags 1 to lag_max.

See Also

Other data analysis: estimate_acf(), estimate_kurtosis(), estimate_mode(), estimate_pacf(), estimate_skewness(), pacf_vec(), summarise_data(), summarise_split(), summarise_stats()

Examples

library(dplyr)

x <- M4_monthly_data |>
  filter(series == first(series)) |>
  pull(value)

acf_vec(
  x = x,
  lag_max = 12
)

tscv documentation built on May 13, 2026, 9:07 a.m.