Skip to contents

Mirrors the C# Autocorrelation class. Computes the requested function out to max_lag (default floor(min(10*log10(N), N-1)), matching the C# default) and attaches the asymptotic confidence band for ACF/PACF rho values at confidence_level.

Usage

autocorrelation(
  x,
  max_lag = NULL,
  type = c("correlation", "covariance", "partial"),
  confidence_level = 0.95
)

Arguments

x

numeric vector, at least two elements.

max_lag

maximum lag. NULL (the default) uses the C# default rule.

type

one of "correlation" (the default), "covariance", or "partial".

confidence_level

confidence level for the band. Default 0.95.

Value

a corehydro_autocorrelation list with lag, value, type, and the two-element ci (lower, upper).

Examples

x <- c(5, 6, 4, 7, 3, 8, 2, 9, 1, 10, 5, 6, 4, 7, 3, 8, 2, 9, 1, 10)
autocorrelation(x, max_lag = 5)
#> <corehydro_autocorrelation> type = correlation, 6 lag(s)