Learn R Programming

rtrend (version 0.1.5)

acf.fft: faster autocorrelation based on ffw

Description

This function is 4-times faster than stats::acf()

Usage

acf.fft(x, lag.max = NULL)

Value

An array with the same dimensions as x containing the estimated autocorrelation.

Arguments

lag.max

maximum lag at which to calculate the acf. Default is \(10\log_{10}(N/m)\) where \(N\) is the number of observations and \(m\) the number of series. Will be automatically limited to one less than the number of observations in the series.

References

  1. https://github.com/santiagobarreda/phonTools/blob/main/R/fastacf.R

  2. https://gist.github.com/FHedin/05d4d6d74e67922dfad88038b04f621c

  3. https://gist.github.com/ajkluber/f293eefba2f946f47bfa

  4. http://www.tibonihoo.net/literate_musing/autocorrelations.html#wikispecd

  5. https://lingpipe-blog.com/2012/06/08/autocorrelation-fft-kiss-eigen

Examples

Run this code
set.seed(1)
x <- rnorm(100)
r_fast <- acf.fft(x)
r <- acf(x, plot=FALSE, lag.max=100)$acf[,,1]

Run the code above in your browser using DataLab