auto_corr: Empirical ACF and PACF

View source: R/ACF.R

auto_corrR Documentation

Empirical ACF and PACF

Description

This function can estimate either the autocovariance / autocorrelation for univariate time series, or the partial autocovariance / autocorrelation for univariate time series.

Usage

auto_corr(
  x,
  lag.max = NULL,
  pacf = FALSE,
  type = "correlation",
  demean = TRUE,
  robust = FALSE
)

Arguments

x

A vector or ts object (of length N > 1).

lag.max

An integer indicating the maximum lag up to which to compute the empirical ACF / PACF.

pacf

A boolean indicating whether to output the PACF. If it's TRUE, then the function will only estimate the empirical PACF. If it's FALSE (the default), then the function will only estimate the empirical ACF.

type

A character string giving the type of acf to be computed. Allowed values are "correlation" (the default) and "covariance".

demean

A boolean indicating whether the data should be detrended (TRUE) or not (FALSE). Defaults to TRUE.

robust

A boolean indicating whether a robust estimator should be used (TRUE) or not (FALSE). Defaults to FALSE. This only works when the function is estimating ACF.

Details

lagmax default is 10*log10(N/m) where N is the number of observations and m is the number of time series being compared. If lagmax supplied is greater than the number of observations N, then one less than the total will be taken (i.e. N - 1).

Value

An array of dimensions N \times 1 \times 1.

Author(s)

Yuming Zhang

Examples

m = auto_corr(datasets::AirPassengers)
m = auto_corr(datasets::AirPassengers, pacf = TRUE)

simts documentation built on Aug. 31, 2023, 5:07 p.m.