Estimate the sample autocorrelation function of a numeric vector.
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.
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)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
x <- M4_monthly_data |>
filter(series == first(series)) |>
pull(value)
acf_vec(
x = x,
lag_max = 12
)
#> [1] 0.9929581 0.9868445 0.9807885 0.9746906 0.9692508 0.9631796 0.9573904
#> [8] 0.9512882 0.9460969 0.9404290 0.9346511 0.9292045
